void PageRuntimeAgent::didCreateMainWorldContext(Frame* frame) { m_mainWorldContextCreated = true; if (!m_enabled) return; ASSERT(m_frontendDispatcher); String frameId = m_pageAgent->frameId(frame); JSC::ExecState* scriptState = mainWorldExecState(frame); notifyContextCreated(frameId, scriptState, 0, true); }
InjectedScript PageDebuggerAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId) { if (!executionContextId) { JSC::ExecState* scriptState = mainWorldExecState(m_pageAgent->mainFrame()); return injectedScriptManager()->injectedScriptFor(scriptState); } InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId(*executionContextId); if (injectedScript.hasNoValue()) *errorString = "Execution context with given id not found."; return injectedScript; }
void PageRuntimeAgent::didCreateMainWorldContext(Frame& frame) { m_mainWorldContextCreated = true; if (!enabled()) return; String frameId = m_pageAgent->frameId(&frame); JSC::ExecState* scriptState = mainWorldExecState(&frame); notifyContextCreated(frameId, scriptState, nullptr, true); }
InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId) { if (!executionContextId) { JSC::ExecState* scriptState = mainWorldExecState(&m_inspectedPage->mainFrame()); InjectedScript result = injectedScriptManager()->injectedScriptFor(scriptState); if (result.hasNoValue()) *errorString = "Internal error: main world execution context not found."; return result; } InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId(*executionContextId); if (injectedScript.hasNoValue()) *errorString = "Execution context with given id not found."; return injectedScript; }
void PageRuntimeAgent::reportExecutionContextCreation() { Vector<std::pair<JSC::ExecState*, SecurityOrigin*>> isolatedContexts; for (Frame* frame = &m_inspectedPage->mainFrame(); frame; frame = frame->tree().traverseNext()) { if (!frame->script().canExecuteScripts(NotAboutToExecuteScript)) continue; String frameId = m_pageAgent->frameId(frame); JSC::ExecState* scriptState = mainWorldExecState(frame); notifyContextCreated(frameId, scriptState, 0, true); frame->script().collectIsolatedContexts(isolatedContexts); if (isolatedContexts.isEmpty()) continue; for (size_t i = 0; i< isolatedContexts.size(); i++) notifyContextCreated(frameId, isolatedContexts[i].first, isolatedContexts[i].second, false); isolatedContexts.clear(); } }
void InspectorAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld& world) { if (&world != &mainThreadNormalWorld()) return; if (m_injectedScriptForOrigin.isEmpty()) return; String origin = frame->document()->securityOrigin()->toRawString(); String script = m_injectedScriptForOrigin.get(origin); if (script.isEmpty()) return; int injectedScriptId = m_injectedScriptManager->injectedScriptIdFor(mainWorldExecState(frame)); StringBuilder scriptSource; scriptSource.append(script); scriptSource.append("("); scriptSource.appendNumber(injectedScriptId); scriptSource.append(")"); frame->script().executeScript(scriptSource.toString()); }
bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& expression) { Deprecated::ScriptValue value = m_frontendPage->mainFrame().script().executeScript(expression); return value.toString(mainWorldExecState(&m_frontendPage->mainFrame())) == "true"; }