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..8894b6caa4257b1f43e5392f1e5008187c05ac22 100644 |
| --- a/Source/core/inspector/PageRuntimeAgent.cpp |
| +++ b/Source/core/inspector/PageRuntimeAgent.cpp |
| @@ -101,21 +101,27 @@ void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) |
| 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); |
| + frame->script().initializeMainWorld(); |
|
yurys
2014/11/13 13:58:30
How can we be sure that this is a scriptless docum
eustas
2014/12/05 10:01:37
No guarantees. But this worked for ages...
|
| } |
| -void PageRuntimeAgent::didCreateIsolatedContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin) |
| +void PageRuntimeAgent::didCreateScriptContext(LocalFrame* frame, ScriptState* scriptState, SecurityOrigin* origin, bool isMainWorldContext) |
| { |
| if (!m_enabled) |
| return; |
| ASSERT(m_frontend); |
| String frameId = m_pageAgent->frameId(frame); |
| - addExecutionContextToFrontend(scriptState, false, origin->toRawString(), frameId); |
| + addExecutionContextToFrontend(scriptState, isMainWorldContext, origin->toRawString(), frameId); |
| +} |
| + |
| +void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState* scriptState) |
| +{ |
| + injectedScriptManager()->discardInjectedScriptFor(scriptState); |
| + ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); |
| + if (it == m_scriptStateToId.end()) |
| + return; |
| + int id = it->value; |
| + m_scriptStateToId.remove(scriptState); |
| + m_frontend->executionContextDestroyed(id); |
| } |
| InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId) |
| @@ -154,8 +160,8 @@ void PageRuntimeAgent::reportExecutionContextCreation() |
| continue; |
| String frameId = m_pageAgent->frameId(localFrame); |
| - ScriptState* scriptState = ScriptState::forMainWorld(localFrame); |
| - addExecutionContextToFrontend(scriptState, true, "", frameId); |
| + if (!localFrame->script().initializeMainWorld()) |
|
yurys
2014/11/13 13:58:30
Mind adding a comment?
eustas
2014/12/05 10:01:37
Done.
|
| + addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId); |
| localFrame->script().collectIsolatedContexts(isolatedContexts); |
| if (isolatedContexts.isEmpty()) |
| continue; |
| @@ -165,19 +171,5 @@ void PageRuntimeAgent::reportExecutionContextCreation() |
| } |
| } |
| -void PageRuntimeAgent::frameWindowDiscarded(LocalDOMWindow* window) |
| -{ |
| - Vector<RefPtr<ScriptState> > scriptStatesToRemove; |
| - for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scriptStateToId.end(); ++it) { |
| - RefPtr<ScriptState> scriptState = it->key; |
| - if (!scriptState->contextIsValid() || window == scriptState->domWindow()) { |
| - scriptStatesToRemove.append(scriptState); |
| - m_frontend->executionContextDestroyed(it->value); |
| - } |
| - } |
| - m_scriptStateToId.removeAll(scriptStatesToRemove); |
| - injectedScriptManager()->discardInjectedScriptsFor(window); |
| -} |
| - |
| } // namespace blink |