void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { LocalDOMWindow* impl = V8Window::toNative(info.Holder()); ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } // Opener can be shadowed if it is in the same domain. // Have a special handling of null value to behave // like Firefox. See bug http://b/1224887 & http://b/791706. if (value->IsNull()) { // impl->frame() cannot be null, // otherwise, SameOrigin check would have failed. ASSERT(impl->frame()); impl->frame()->loader().setOpener(0); } // Delete the accessor from this object. info.Holder()->Delete(v8AtomicString(info.GetIsolate(), "opener")); // Put property on the front (this) object. if (info.This()->IsObject()) v8::Handle<v8::Object>::Cast(info.This())->Set(v8AtomicString(info.GetIsolate(), "opener"), value); }
void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { v8::Isolate* isolate = info.GetIsolate(); DOMWindow* impl = V8Window::toImpl(info.Holder()); ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Window", info.Holder(), isolate); if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } // Opener can be shadowed if it is in the same domain. // Have a special handling of null value to behave // like Firefox. See bug http://b/1224887 & http://b/791706. if (value->IsNull()) { // impl->frame() has to be a non-null LocalFrame. Otherwise, the // same-origin check would have failed. ASSERT(impl->frame()); toLocalFrame(impl->frame())->loader().setOpener(0); } // Delete the accessor from this object. info.Holder()->Delete(isolate->GetCurrentContext(), v8AtomicString(isolate, "opener")); // Put property on the front (this) object. if (info.This()->IsObject()) { v8::Maybe<bool> unused = v8::Local<v8::Object>::Cast(info.This())->Set(isolate->GetCurrentContext(), v8AtomicString(isolate, "opener"), value); ALLOW_UNUSED_LOCAL(unused); } }
static void TestInterfaceCheckSecurityReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(info.Holder()); v8::Isolate* isolate = info.GetIsolate(); v8::String::Utf8Value attributeName(name); ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), isolate); if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } if (info.This()->IsObject()) v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); }
static void doNotCheckSecurityUnforgeableVoidMethodOriginSafeMethodGetter(const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); static int domTemplateKey; // This address is used for a key to look up the dom template. V8PerIsolateData* data = V8PerIsolateData::from(isolate); v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate); if (holder.IsEmpty()) { // This is only reachable via |object.__proto__.func|, in which case it // has already passed the same origin security check v8SetReturnValue(info, privateTemplate->GetFunction()); return; } TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder); if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNotReportSecurityError)) { static int sharedTemplateKey; // This address is used for a key to look up the dom template. v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sharedTemplateKey, TestInterfaceCheckSecurityV8Internal::doNotCheckSecurityUnforgeableVoidMethodMethodCallback, v8Undefined(), v8::Signature::New(info.GetIsolate(), V8TestInterfaceCheckSecurity::domTemplate(info.GetIsolate())), 0); v8SetReturnValue(info, sharedTemplate->GetFunction()); return; } v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This())->GetHiddenValue(v8AtomicString(isolate, "doNotCheckSecurityUnforgeableVoidMethod")); if (!hiddenValue.IsEmpty()) { v8SetReturnValue(info, hiddenValue); return; } v8SetReturnValue(info, privateTemplate->GetFunction()); }
void JSInterleavedVideoFrame::JSGetData(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); v8::HandleScope scope(isolate); JSInterleavedVideoFrame* self = UnwrapSelf<JSInterleavedVideoFrame>(info.This()); // Make sure we're writeable. self->MakeWriteable(isolate); if (self->dataInstance.IsEmpty()) { info.GetReturnValue().Set(v8::Null()); } else { info.GetReturnValue().Set(self->dataInstance); } }
void JsSprite::JS_GetTexture(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { DEFINE_HANDLE_SCOPE_AND_GET_SELF_FOR_SPRITE(info); JsSprite * that = GetWrappedObject<JsSprite>(info.This()); if (!that->_texture) { info.GetReturnValue().SetNull(); return; } info.GetReturnValue().Set(that->_texture->handle(info.GetIsolate())); }
void JsSprite::JS_SetTexture(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { DEFINE_HANDLE_SCOPE_AND_GET_SELF_FOR_SPRITE(info); auto obj = Local<Object>::Cast(value); if (obj->InternalFieldCount() < 2) return; Texture * texture = GetSelf<Texture>(obj); self->setTexture(*texture); JsSprite * that = GetWrappedObject<JsSprite>(info.This()); JsTexture * wrapped = GetWrappedObject<JsTexture>(obj); wrapped->Ref(); if (that->_texture) that->_texture->Unref(); that->_texture = wrapped; }
static void TestInterfaceCheckSecurityOriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { v8::Isolate* isolate = info.GetIsolate(); v8::Handle<v8::Object> holder = V8TestInterfaceCheckSecurity::findInstanceInPrototypeChain(info.This(), isolate); if (holder.IsEmpty()) return; TestInterfaceCheckSecurity* impl = V8TestInterfaceCheckSecurity::toNative(holder); v8::String::Utf8Value attributeName(name); ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "TestInterfaceCheckSecurity", info.Holder(), isolate); if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } V8HiddenValue::setHiddenValue(isolate, v8::Handle<v8::Object>::Cast(info.This()), name, v8Value); }
void V8Window::eventAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))); if (holder.IsEmpty()) return; Frame* frame = V8Window::toNative(holder)->frame(); if (!BindingSecurity::shouldAllowAccessToFrame(frame)) return; ASSERT(frame); v8::Local<v8::Context> context = frame->script()->currentWorldContext(); if (context.IsEmpty()) return; v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(); context->Global()->SetHiddenValue(eventSymbol, value); }
static void FXJSE_V8_GenericNamedPropertyGetterCallback( v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> thisObject = info.This(); const FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); v8::String::Utf8Value szPropName(property); CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); lpThisValue->ForceSetValue(thisObject); CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate()); FXJSE_DynPropGetterAdapter( lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName, reinterpret_cast<FXJSE_HVALUE>(lpNewValue)); info.GetReturnValue().Set(lpNewValue->DirectGetValue()); delete lpThisValue; lpThisValue = nullptr; }
void V8Window::openerAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { DOMWindow* imp = V8Window::toNative(info.Holder()); if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame())) return; // Opener can be shadowed if it is in the same domain. // Have a special handling of null value to behave // like Firefox. See bug http://b/1224887 & http://b/791706. if (value->IsNull()) { // imp->frame() cannot be null, // otherwise, SameOrigin check would have failed. ASSERT(imp->frame()); imp->frame()->loader()->setOpener(0); } // Delete the accessor from this object. info.Holder()->Delete(name); // Put property on the front (this) object. info.This()->Set(name, value); }
static void FXJSE_V8_GenericNamedPropertyQueryCallback( v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Integer>& info) { v8::Local<v8::Object> thisObject = info.This(); const FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); v8::Isolate* pIsolate = info.GetIsolate(); v8::HandleScope scope(pIsolate); v8::String::Utf8Value szPropName(property); CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); lpThisValue->ForceSetValue(thisObject); if (FXJSE_DynPropQueryAdapter(lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName)) { info.GetReturnValue().Set(v8::DontDelete); } else { const int32_t iV8Absent = 64; info.GetReturnValue().Set(iV8Absent); } delete lpThisValue; lpThisValue = nullptr; }
void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Window::domTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))); if (holder.IsEmpty()) return; Frame* frame = V8Window::toNative(holder)->frame(); ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessToFrame(frame, exceptionState)) { exceptionState.throwIfNeeded(); return; } ASSERT(frame); v8::Local<v8::Context> context = frame->script().currentWorldContext(); if (context.IsEmpty()) return; v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIsolate()); v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbol); if (jsEvent.IsEmpty()) return; v8SetReturnValue(info, jsEvent); }
static void TestInterfaceNamedConstructorReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { info.This()->ForceSet(name, v8Value); }
static void TestTypedefsReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) { info.This()->ForceSet(name, jsValue); }
static void TestTypedefsReplaceableAttributeSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { if (info.This()->IsObject()) v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); }