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::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { LocalDOMWindow* impl = V8Window::toNative(info.Holder()); ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, urlString, info[0]); AtomicString frameName; if (info[1]->IsUndefined() || info[1]->IsNull()) { frameName = "_blank"; } else { TOSTRING_VOID(V8StringResource<>, frameNameResource, info[1]); frameName = frameNameResource; } TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, windowFeaturesString, info[2]); RefPtrWillBeRawPtr<LocalDOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate())); if (!openedWindow) return; v8SetReturnValueFast(info, openedWindow.release(), impl); }
void InspectorRuntimeAgent::addExecutionContextToFrontend(ScriptState* scriptState, bool isPageContext, const String& origin, const String& frameId) { LocalDOMWindow* domWindow = scriptState->domWindow(); LocalFrame* frame = domWindow ? domWindow->frame() : 0; if (frame && frame->page() && frame->page()->mainFrame()) { Frame* main_frame = frame->page()->mainFrame(); Frame* jail_frame = main_frame->getDevtoolsJail(); if (jail_frame) { bool in_jail_frame = false; Frame* f = frame; while (f) { if (f == jail_frame) { in_jail_frame = true; break; } f = f->tree().parent(); } if (!in_jail_frame) return; } } int executionContextId = injectedScriptManager()->injectedScriptIdFor(scriptState); m_scriptStateToId.set(scriptState, executionContextId); DOMWrapperWorld& world = scriptState->world(); String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHumanReadableName() : ""; m_frontend->executionContextCreated(ExecutionContextDescription::create() .setId(executionContextId) .setIsPageContext(isPageContext) .setName(humanReadableName) .setOrigin(origin) .setFrameId(frameId) .release()); }
void V8Window::eventAttributeGetterCustom( const v8::PropertyCallbackInfo<v8::Value>& info) { LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { return; } LocalFrame* frame = impl->frame(); ASSERT(frame); // This is a fast path to retrieve info.Holder()->CreationContext(). v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current(info.GetIsolate())); if (context.IsEmpty()) return; v8::Local<v8::Value> jsEvent = V8HiddenValue::getHiddenValue( ScriptState::current(info.GetIsolate()), context->Global(), V8HiddenValue::event(info.GetIsolate())); if (jsEvent.IsEmpty()) return; v8SetReturnValue(info, jsEvent); }
void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) { LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Window", info.Holder(), info.GetIsolate()); // Do the security check against the parent frame rather than // frameElement() itself, so that a remote parent frame can be handled // properly. In that case, there's no frameElement(), yet we should still // throw a proper exception and deny access. Frame* target = impl->frame() ? impl->frame()->tree().parent() : nullptr; if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), target, exceptionState)) { v8SetReturnValueNull(info); exceptionState.throwIfNeeded(); return; } // The wrapper for an <iframe> should get its prototype from the context of the frame it's in, rather than its own frame. // So, use its containing document as the creation context when wrapping. v8::Local<v8::Value> creationContext = toV8(&impl->frameElement()->document(), info.Holder(), info.GetIsolate()); RELEASE_ASSERT(!creationContext.IsEmpty()); v8::Local<v8::Value> wrapper = toV8(impl->frameElement(), v8::Local<v8::Object>::Cast(creationContext), info.GetIsolate()); v8SetReturnValue(info, wrapper); }
void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { LocalDOMWindow* impl = V8Window::toNative(info.Holder()); ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDialog", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, urlString, info[0]); DialogHandler handler(info[1], ScriptState::current(info.GetIsolate())); TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, dialogFeaturesString, info[2]); impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler); v8SetReturnValue(info, handler.returnValue()); }
void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { LocalDOMWindow* window = V8Window::toNative(info.Holder()); if (!window) return; LocalFrame* frame = window->frame(); // window is detached from a frame. if (!frame) return; // Search sub-frames. AtomicString propName = toCoreAtomicString(name); Frame* child = frame->tree().scopedChild(propName); if (child) { v8SetReturnValueFast(info, child->domWindow(), window); return; } // Search IDL functions defined in the prototype if (!info.Holder()->GetRealNamedProperty(name).IsEmpty()) return; // Search named items in the document. Document* doc = frame->document(); if (doc && doc->isHTMLDocument()) { if (toHTMLDocument(doc)->hasNamedItem(propName) || doc->hasElementWithId(propName.impl())) { RefPtrWillBeRawPtr<HTMLCollection> items = doc->windowNamedItems(propName); if (!items->isEmpty()) { if (items->hasExactlyOneItem()) { v8SetReturnValueFast(info, items->item(0), window); return; } v8SetReturnValueFast(info, items.release(), window); return; } } } }
bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host, isolate); if (window.IsEmpty()) return false; // the frame is gone. LocalDOMWindow* targetWindow = V8Window::toNative(window); ASSERT(targetWindow); LocalFrame* target = targetWindow->frame(); if (!target) return false; // Notify the loader's client if the initial document has been accessed. if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) target->loader().didAccessInitialDocument(); if (key->IsString()) { DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__", AtomicString::ConstructFromLiteral)); AtomicString name = toCoreAtomicString(key.As<v8::String>()); Frame* childFrame = target->tree().scopedChild(name); // Notice that we can't call HasRealNamedProperty for ACCESS_HAS // because that would generate infinite recursion. if (type == v8::ACCESS_HAS && childFrame) return true; // We need to explicitly compare against nameOfProtoProperty because // V8's JSObject::LocalLookup finds __proto__ before // interceptors and even when __proto__ isn't a "real named property". v8::Handle<v8::String> keyString = key.As<v8::String>(); if (type == v8::ACCESS_GET && childFrame && !host->HasRealNamedProperty(keyString) && !window->HasRealNamedProperty(keyString) && name != nameOfProtoProperty) return true; }
DOMWindowCrypto::DOMWindowCrypto(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) { }
DOMWindowWebCL::DOMWindowWebCL(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) , m_window(window) { }
WindowAnimationWorklet::WindowAnimationWorklet(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) {}
DOMWindowIndexedDatabase::DOMWindowIndexedDatabase(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) , m_window(window) { }
DOMWindowPerformance::DOMWindowPerformance(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) , m_window(&window) { }
DOMWindowSpeechSynthesis::DOMWindowSpeechSynthesis(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) {}
DOMWindowStorage::DOMWindowStorage(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) , m_window(&window) { }
DOMWindowQuota::DOMWindowQuota(LocalDOMWindow& window) : DOMWindowProperty(window.frame()) {}