bool ScriptController::shouldBypassMainWorldContentSecurityPolicy() { DOMWrapperWorld* world = DOMWrapperWorld::current(m_isolate); if (world && world->isIsolatedWorld()) return world->isolatedWorldHasContentSecurityPolicy(); return false; }
bool ScriptController::shouldBypassMainWorldContentSecurityPolicy() { v8::Handle<v8::Context> context = m_isolate->GetCurrentContext(); if (context.IsEmpty() || !toDOMWindow(context)) return false; DOMWrapperWorld* world = DOMWrapperWorld::current(m_isolate); return world->isIsolatedWorld() ? world->isolatedWorldHasContentSecurityPolicy() : false; }
bool ScriptController::shouldBypassMainWorldContentSecurityPolicy() { CallFrame* callFrame = JSDOMWindow::commonVM()->topCallFrame; if (!callFrame || callFrame == CallFrame::noCaller()) return false; DOMWrapperWorld* domWrapperWorld = currentWorld(callFrame); if (domWrapperWorld->isNormal()) return false; return true; }
v8::Handle<v8::Object> wrap(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) { ASSERT(impl); v8::Handle<v8::Object> wrapper = V8TestInterfaceDocument::createWrapper(impl, creationContext, isolate); if (wrapper.IsEmpty()) return wrapper; DOMWrapperWorld* world = DOMWrapperWorld::current(isolate); if (world->isMainWorld()) { if (Frame* frame = impl->frame()) frame->script().windowShell(world)->updateDocumentWrapper(wrapper); } return wrapper; }
DOMDataStore* DOMDataStore::current(v8::Isolate* isolate) { V8PerIsolateData* data = isolate ? V8PerIsolateData::from(isolate) : V8PerIsolateData::current(); if (UNLIKELY(!!data->domDataStore())) return data->domDataStore(); if (DOMWrapperWorld::isolatedWorldsExist()) { DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolated(v8::Context::GetEntered()); if (UNLIKELY(!!isolatedWorld)) return isolatedWorld->isolatedWorldDOMDataStore(); } return mainWorldStore(); }
void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { ExecutionContext* context = currentExecutionContext(info.GetIsolate()); RefPtr<SecurityOrigin> securityOrigin; if (context->isDocument()) { DOMWrapperWorld* world = DOMWrapperWorld::current(info.GetIsolate()); if (world->isIsolatedWorld()) securityOrigin = world->isolatedWorldSecurityOrigin(); } RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin); v8::Handle<v8::Object> wrapper = info.Holder(); V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.release(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent); info.GetReturnValue().Set(wrapper); }
v8::Local<v8::Context> ScriptController::currentWorldContext() { if (!v8::Context::InContext()) return contextForWorld(this, mainThreadNormalWorld()); v8::Handle<v8::Context> context = v8::Context::GetEntered(); DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolated(context); if (!isolatedWorld) return contextForWorld(this, mainThreadNormalWorld()); Frame* frame = toFrameIfNotDetached(context); if (!m_frame) return v8::Local<v8::Context>(); if (m_frame == frame) return v8::Local<v8::Context>::New(context); // FIXME: Need to handle weak isolated worlds correctly. if (isolatedWorld->createdFromUnitializedWorld()) return v8::Local<v8::Context>(); return contextForWorld(this, isolatedWorld); }
JSValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode, DOMWrapperWorld& world, ExceptionDetails* exceptionDetails) { JSLockHolder lock(world.vm()); const SourceCode& jsSourceCode = sourceCode.jsSourceCode(); String sourceURL = jsSourceCode.provider()->url(); // evaluate code. Returns the JS return value or 0 // if there was none, an error occurred or the type couldn't be converted. // inlineCode is true for <a href="javascript:doSomething()"> // and false for <script>doSomething()</script>. Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. JSDOMWindowShell* shell = windowShell(world); ExecState* exec = shell->window()->globalExec(); const String* savedSourceURL = m_sourceURL; m_sourceURL = &sourceURL; Ref<Frame> protect(m_frame); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine()); NakedPtr<Exception> evaluationException; JSValue returnValue = JSMainThreadExecState::profiledEvaluate(exec, JSC::ProfilingReason::Other, jsSourceCode, shell, evaluationException); InspectorInstrumentation::didEvaluateScript(cookie, m_frame); if (evaluationException) { reportException(exec, evaluationException, sourceCode.cachedScript(), exceptionDetails); m_sourceURL = savedSourceURL; return { }; } m_sourceURL = savedSourceURL; return returnValue; }
void ScriptController::destroyWindowShell(DOMWrapperWorld& world) { ASSERT(m_windowShells.contains(&world)); m_windowShells.remove(&world); world.didDestroyWindowShell(this); }
void WindowProxy::destroyJSWindowProxy(DOMWrapperWorld& world) { ASSERT(m_jsWindowProxies.contains(&world)); m_jsWindowProxies.remove(&world); world.didDestroyWindowProxy(this); }