Chromium Code Reviews| Index: Source/core/inspector/PageRuntimeAgent.cpp |
| diff --git a/Source/core/inspector/PageRuntimeAgent.cpp b/Source/core/inspector/PageRuntimeAgent.cpp |
| index 9c1d5a2d6d0912b7907f10a6bb0e2972ec1027e8..39c4433de36c7d06a5cb75e211913e23a68245cb 100644 |
| --- a/Source/core/inspector/PageRuntimeAgent.cpp |
| +++ b/Source/core/inspector/PageRuntimeAgent.cpp |
| @@ -105,10 +105,32 @@ void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) |
| m_scriptStateToId.clear(); |
| m_frontend->executionContextsCleared(); |
| } |
| + |
| + registerMainWorldContext(frame); |
|
yurys
2014/10/30 10:23:43
In this case we should not force initialization, i
eustas
2014/10/31 06:59:53
Done.
|
| +} |
| + |
| +void PageRuntimeAgent::registerMainWorldContext(LocalFrame* frame) |
| +{ |
| + // Force creation on main world contect. |
|
aandrey
2014/10/30 10:27:16
maybe add a comment that creation otherwise will h
eustas
2014/10/31 06:59:53
Done.
|
| + // Positive result means that contect was just initialized, |
|
aandrey
2014/10/30 10:27:16
typo: contect
eustas
2014/10/31 06:59:53
Done.
|
| + // so it was registered in didCreateMainWorldContext. |
| + if (frame->script().initializeMainWorld()) |
| + return; |
| + |
| + // Negative result means that context already exists, and we need to register it. |
| 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); |
| + String frameId = m_pageAgent->frameId(frame); |
| + addExecutionContextToFrontend(scriptState, true, origin->toRawString(), frameId); |
| +} |
| + |
| void PageRuntimeAgent::didCreateIsolatedContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin) |
| { |
| if (!m_enabled) |
| @@ -154,8 +176,7 @@ void PageRuntimeAgent::reportExecutionContextCreation() |
| continue; |
| String frameId = m_pageAgent->frameId(localFrame); |
| - ScriptState* scriptState = ScriptState::forMainWorld(localFrame); |
| - addExecutionContextToFrontend(scriptState, true, "", frameId); |
| + registerMainWorldContext(localFrame); |
| localFrame->script().collectIsolatedContexts(isolatedContexts); |
| if (isolatedContexts.isEmpty()) |
| continue; |