void PageRuntimeAgent::reportExecutionContextCreation() { Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tree().traverseNext(m_pageAgent->inspectedFrame())) { if (!frame->isLocalFrame()) continue; LocalFrame* localFrame = toLocalFrame(frame); if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) continue; String frameId = m_pageAgent->frameId(localFrame); // Ensure execution context is created. // If initializeMainWorld returns true, then is registered by didCreateScriptContext if (!localFrame->script().initializeMainWorld()) addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId); localFrame->script().collectIsolatedContexts(isolatedContexts); if (isolatedContexts.isEmpty()) continue; for (const auto& pair : isolatedContexts) { String originString = pair.second ? pair.second->toRawString() : ""; addExecutionContextToFrontend(pair.first, false, originString, frameId); } isolatedContexts.clear(); } }
void WorkerRuntimeAgent::enable(ErrorString* errorString) { if (m_enabled) return; InspectorRuntimeAgent::enable(errorString); addExecutionContextToFrontend(m_workerGlobalScope->script()->scriptState(), true, m_workerGlobalScope->url(), ""); }
void PageRuntimeAgent::didCreateIsolatedContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin) { if (!m_enabled) return; ASSERT(m_frontend); String frameId = m_pageAgent->frameId(frame); addExecutionContextToFrontend(scriptState, false, origin->toRawString(), frameId); }
void PageRuntimeAgent::reportExecutionContextCreation() { Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree().traverseNext()) { if (!frame->isLocalFrame()) continue; LocalFrame* localFrame = toLocalFrame(frame); if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) continue; String frameId = m_pageAgent->frameId(localFrame); ScriptState* scriptState = ScriptState::forMainWorld(localFrame); addExecutionContextToFrontend(scriptState, true, "", frameId); localFrame->script().collectIsolatedContexts(isolatedContexts); if (isolatedContexts.isEmpty()) continue; for (size_t i = 0; i< isolatedContexts.size(); i++) addExecutionContextToFrontend(isolatedContexts[i].first, false, isolatedContexts[i].second->toRawString(), frameId); isolatedContexts.clear(); } }
void PageRuntimeAgent::didCreateScriptContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin, int worldId) { bool isMainWorld = worldId == MainWorldId; // Name the context for debugging. String type = isMainWorld ? "page" : "injected"; PageScriptDebugServer::setContextDebugData(scriptState->context(), type, m_debuggerId); if (!m_enabled) return; ASSERT(frontend()); String originString = origin ? origin->toRawString() : ""; String frameId = m_pageAgent->frameId(frame); addExecutionContextToFrontend(scriptState, isMainWorld, originString, frameId); }
void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) { m_mainWorldContextCreated = true; if (!m_enabled) return; ASSERT(m_frontend); if (frame == m_inspectedPage->mainFrame()) { m_scriptStateToId.clear(); m_frontend->executionContextsCleared(); } String frameId = m_pageAgent->frameId(frame); addExecutionContextToFrontend(ScriptState::forMainWorld(frame), true, "", frameId); }