Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1118)

Unified Diff: Source/core/inspector/PageRuntimeAgent.cpp

Issue 686763002: Fix Runtime.executionContextCreated for crafted iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« Source/core/inspector/InjectedScriptManager.cpp ('K') | « Source/core/inspector/PageRuntimeAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698