OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #if ENABLE(INSPECTOR) | 33 #if ENABLE(INSPECTOR) |
34 | 34 |
35 #include "PageRuntimeAgent.h" | 35 #include "PageRuntimeAgent.h" |
36 | 36 |
37 #include "Console.h" | 37 #include "Console.h" |
38 #include "Document.h" | 38 #include "Document.h" |
39 #include "InjectedScript.h" | 39 #include "InjectedScript.h" |
40 #include "InjectedScriptManager.h" | 40 #include "InjectedScriptManager.h" |
| 41 #include "InspectorAgent.h" |
41 #include "InspectorPageAgent.h" | 42 #include "InspectorPageAgent.h" |
42 #include "InspectorState.h" | 43 #include "InspectorState.h" |
43 #include "InstrumentingAgents.h" | 44 #include "InstrumentingAgents.h" |
44 #include "Page.h" | 45 #include "Page.h" |
45 #include "SecurityOrigin.h" | 46 #include "SecurityOrigin.h" |
46 | 47 |
47 using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; | 48 using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; |
48 | 49 |
49 namespace WebCore { | 50 namespace WebCore { |
50 | 51 |
51 namespace PageRuntimeAgentState { | 52 namespace PageRuntimeAgentState { |
52 static const char reportExecutionContextCreation[] = "reportExecutionContextCrea
tion"; | 53 static const char reportExecutionContextCreation[] = "reportExecutionContextCrea
tion"; |
53 }; | 54 }; |
54 | 55 |
55 PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Ins
pectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, In
spectorPageAgent* pageAgent) | 56 PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Ins
pectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, In
spectorPageAgent* pageAgent, InspectorAgent* inspectorAgent) |
56 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) | 57 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) |
57 , m_inspectedPage(page) | 58 , m_inspectedPage(page) |
58 , m_pageAgent(pageAgent) | 59 , m_pageAgent(pageAgent) |
| 60 , m_inspectorAgent(inspectorAgent) |
59 , m_frontend(0) | 61 , m_frontend(0) |
60 { | 62 { |
61 } | 63 } |
62 | 64 |
63 PageRuntimeAgent::~PageRuntimeAgent() | 65 PageRuntimeAgent::~PageRuntimeAgent() |
64 { | 66 { |
65 } | 67 } |
66 | 68 |
67 void PageRuntimeAgent::setFrontend(InspectorFrontend* frontend) | 69 void PageRuntimeAgent::setFrontend(InspectorFrontend* frontend) |
68 { | 70 { |
69 m_frontend = frontend->runtime(); | 71 m_frontend = frontend->runtime(); |
70 m_instrumentingAgents->setPageRuntimeAgent(this); | 72 m_instrumentingAgents->setPageRuntimeAgent(this); |
71 } | 73 } |
72 | 74 |
73 void PageRuntimeAgent::clearFrontend() | 75 void PageRuntimeAgent::clearFrontend() |
74 { | 76 { |
75 m_instrumentingAgents->setPageRuntimeAgent(0); | 77 m_instrumentingAgents->setPageRuntimeAgent(0); |
76 m_frontend = 0; | 78 m_frontend = 0; |
77 m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, f
alse); | 79 m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, f
alse); |
78 } | 80 } |
79 | 81 |
80 void PageRuntimeAgent::restore() | 82 void PageRuntimeAgent::restore() |
81 { | 83 { |
82 if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreati
on)) | 84 if (!m_state->getBoolean(PageRuntimeAgentState::reportExecutionContextCreati
on)) |
83 return; | 85 return; |
84 String error; | 86 // Only report existing contexts if the page did commit load, otherwise we m
ay |
85 setReportExecutionContextCreation(&error, true); | 87 // unintentionally initialize contexts in the frames which may trigger some
listeners |
| 88 // that are expected to be triggered only after the load is committed, see h
ttp://crbug.com/131623 |
| 89 if (m_inspectorAgent->didCommitLoadFired()) { |
| 90 String error; |
| 91 setReportExecutionContextCreation(&error, true); |
| 92 } |
86 } | 93 } |
87 | 94 |
88 void PageRuntimeAgent::setReportExecutionContextCreation(ErrorString*, bool enab
le) | 95 void PageRuntimeAgent::setReportExecutionContextCreation(ErrorString*, bool enab
le) |
89 { | 96 { |
90 m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, e
nable); | 97 m_state->setBoolean(PageRuntimeAgentState::reportExecutionContextCreation, e
nable); |
91 if (!enable) | 98 if (!enable) |
92 return; | 99 return; |
93 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; | 100 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; |
94 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree
()->traverseNext()) { | 101 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree
()->traverseNext()) { |
95 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) | 102 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 .setId(executionContextId) | 164 .setId(executionContextId) |
158 .setIsPageContext(isPageContext) | 165 .setIsPageContext(isPageContext) |
159 .setName(name) | 166 .setName(name) |
160 .setFrameId(frameId) | 167 .setFrameId(frameId) |
161 .release()); | 168 .release()); |
162 } | 169 } |
163 | 170 |
164 } // namespace WebCore | 171 } // namespace WebCore |
165 | 172 |
166 #endif // ENABLE(INSPECTOR) | 173 #endif // ENABLE(INSPECTOR) |
OLD | NEW |