Index: Source/core/inspector/PageRuntimeAgent.cpp |
diff --git a/Source/core/inspector/PageRuntimeAgent.cpp b/Source/core/inspector/PageRuntimeAgent.cpp |
index 9c1d5a2d6d0912b7907f10a6bb0e2972ec1027e8..a2f30647b2ed6012b100fa4de5ca6079bc903d12 100644 |
--- a/Source/core/inspector/PageRuntimeAgent.cpp |
+++ b/Source/core/inspector/PageRuntimeAgent.cpp |
@@ -85,7 +85,7 @@ void PageRuntimeAgent::enable(ErrorString* errorString) |
// unintentionally initialize contexts in the frames which may trigger some listeners |
// that are expected to be triggered only after the load is committed, see http://crbug.com/131623 |
if (m_mainWorldContextCreated) |
- reportExecutionContextCreation(); |
+ reportExecutionContextsToFrontend(); |
} |
void PageRuntimeAgent::run(ErrorString* errorString) |
@@ -105,10 +105,28 @@ void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) |
m_scriptStateToId.clear(); |
m_frontend->executionContextsCleared(); |
} |
+ registerMainWorldContext(frame); |
+} |
+ |
+void PageRuntimeAgent::registerMainWorldContext(LocalFrame* frame) |
+{ |
+ if (!frame->script().isMainWorldInitialized()) |
+ return; |
+ |
String frameId = m_pageAgent->frameId(frame); |
addExecutionContextToFrontend(ScriptState::forMainWorld(frame), true, "", frameId); |
} |
+void PageRuntimeAgent::didCreateMainWorldContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin) |
+{ |
+ if (!m_enabled) |
+ return; |
+ ASSERT(m_frontend); |
+ base::debug::StackTrace().Print(); |
vsevik
2014/10/31 14:58:07
remove
eustas
2014/11/03 20:14:16
Done.
|
+ String frameId = m_pageAgent->frameId(frame); |
+ addExecutionContextToFrontend(scriptState, true, origin->toRawString(), frameId); |
+} |
+ |
void PageRuntimeAgent::didCreateIsolatedContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin) |
{ |
if (!m_enabled) |
@@ -143,7 +161,7 @@ void PageRuntimeAgent::unmuteConsole() |
FrameConsole::unmute(); |
} |
-void PageRuntimeAgent::reportExecutionContextCreation() |
+void PageRuntimeAgent::reportExecutionContextsToFrontend() |
{ |
Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; |
for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree().traverseNext()) { |
@@ -154,8 +172,7 @@ void PageRuntimeAgent::reportExecutionContextCreation() |
continue; |
String frameId = m_pageAgent->frameId(localFrame); |
- ScriptState* scriptState = ScriptState::forMainWorld(localFrame); |
- addExecutionContextToFrontend(scriptState, true, "", frameId); |
+ registerMainWorldContext(localFrame); |
yurys
2014/10/31 15:08:03
Am I right that now we may end up with 0 contexts
eustas
2014/11/03 20:14:16
Yes and no.
Theoretically - yes.
But I've examined
|
localFrame->script().collectIsolatedContexts(isolatedContexts); |
if (isolatedContexts.isEmpty()) |
continue; |