From 020b627cdbebd0ebf5bb3282137e51ba38d9e252 Mon Sep 17 00:00:00 2001 From: "yurys@chromium.org" Date: Wed, 20 Jun 2012 15:07:28 +0000 Subject: [PATCH] Web Inspector: don't report context ids before DidCommitLoad https://bugs.webkit.org/show_bug.cgi?id=89567 Reviewed by Pavel Feldman. When inspector state is restored only report existing context ids if "did commit load" even has already been dispatched. * inspector/InspectorController.cpp: (WebCore::InspectorController::InspectorController): * inspector/PageRuntimeAgent.cpp: (WebCore::PageRuntimeAgent::PageRuntimeAgent): (WebCore::PageRuntimeAgent::restore): * inspector/PageRuntimeAgent.h: (WebCore): (WebCore::PageRuntimeAgent::create): (PageRuntimeAgent): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120822 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 20 ++++++++++++++++++++ Source/WebCore/inspector/InspectorController.cpp | 2 +- Source/WebCore/inspector/PageRuntimeAgent.cpp | 13 ++++++++++--- Source/WebCore/inspector/PageRuntimeAgent.h | 8 +++++--- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index b0b1cdd..81320af 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2012-06-20 Yury Semikhatsky + + Web Inspector: don't report context ids before DidCommitLoad + https://bugs.webkit.org/show_bug.cgi?id=89567 + + Reviewed by Pavel Feldman. + + When inspector state is restored only report existing context ids + if "did commit load" even has already been dispatched. + + * inspector/InspectorController.cpp: + (WebCore::InspectorController::InspectorController): + * inspector/PageRuntimeAgent.cpp: + (WebCore::PageRuntimeAgent::PageRuntimeAgent): + (WebCore::PageRuntimeAgent::restore): + * inspector/PageRuntimeAgent.h: + (WebCore): + (WebCore::PageRuntimeAgent::create): + (PageRuntimeAgent): + 2012-06-20 Zeev Lieber [Chromium] Remove redundant #includes in compositor diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp index 9dac2fe..095e1cc 100644 --- a/Source/WebCore/inspector/InspectorController.cpp +++ b/Source/WebCore/inspector/InspectorController.cpp @@ -121,7 +121,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC m_resourceAgent = resourceAgentPtr.get(); m_agents.append(resourceAgentPtr.release()); - OwnPtr runtimeAgentPtr(PageRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), page, pageAgent)); + OwnPtr runtimeAgentPtr(PageRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), page, pageAgent, m_inspectorAgent)); InspectorRuntimeAgent* runtimeAgent = runtimeAgentPtr.get(); m_agents.append(runtimeAgentPtr.release()); diff --git a/Source/WebCore/inspector/PageRuntimeAgent.cpp b/Source/WebCore/inspector/PageRuntimeAgent.cpp index b2962bd..35d56f5 100644 --- a/Source/WebCore/inspector/PageRuntimeAgent.cpp +++ b/Source/WebCore/inspector/PageRuntimeAgent.cpp @@ -38,6 +38,7 @@ #include "Document.h" #include "InjectedScript.h" #include "InjectedScriptManager.h" +#include "InspectorAgent.h" #include "InspectorPageAgent.h" #include "InspectorState.h" #include "InstrumentingAgents.h" @@ -52,10 +53,11 @@ namespace PageRuntimeAgentState { static const char reportExecutionContextCreation[] = "reportExecutionContextCreation"; }; -PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent) +PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent, InspectorAgent* inspectorAgent) : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) , m_inspectedPage(page) , m_pageAgent(pageAgent) + , m_inspectorAgent(inspectorAgent) , m_frontend(0) { } @@ -81,8 +83,13 @@ void PageRuntimeAgent::restore() { if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreation)) return; - String error; - setReportExecutionContextCreation(&error, true); + // Only report existing contexts if the page did commit load, otherwise we may + // 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_inspectorAgent->didCommitLoadFired()) { + String error; + setReportExecutionContextCreation(&error, true); + } } void PageRuntimeAgent::setReportExecutionContextCreation(ErrorString*, bool enable) diff --git a/Source/WebCore/inspector/PageRuntimeAgent.h b/Source/WebCore/inspector/PageRuntimeAgent.h index 483217f..9c92d80 100644 --- a/Source/WebCore/inspector/PageRuntimeAgent.h +++ b/Source/WebCore/inspector/PageRuntimeAgent.h @@ -40,15 +40,16 @@ namespace WebCore { +class InspectorAgent; class InspectorPageAgent; class Page; class SecurityOrigin; class PageRuntimeAgent : public InspectorRuntimeAgent { public: - static PassOwnPtr create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent) + static PassOwnPtr create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent, InspectorAgent* inspectorAgent) { - return adoptPtr(new PageRuntimeAgent(instrumentingAgents, state, injectedScriptManager, page, pageAgent)); + return adoptPtr(new PageRuntimeAgent(instrumentingAgents, state, injectedScriptManager, page, pageAgent, inspectorAgent)); } virtual ~PageRuntimeAgent(); virtual void setFrontend(InspectorFrontend*); @@ -60,7 +61,7 @@ public: void didCreateIsolatedContext(Frame*, ScriptState*, SecurityOrigin*); private: - PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*); + PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*, InspectorAgent*); virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId); virtual void muteConsole(); @@ -69,6 +70,7 @@ private: Page* m_inspectedPage; InspectorPageAgent* m_pageAgent; + InspectorAgent* m_inspectorAgent; InspectorFrontend::Runtime* m_frontend; }; -- 2.7.4