- Revision
- 157425
- Author
- [email protected]
- Date
- 2013-10-14 16:08:37 -0700 (Mon, 14 Oct 2013)
Log Message
The content of the DOM panel for iframes is not updated until the "onload" event
https://bugs.webkit.org/show_bug.cgi?id=122653
Reviewed by Darin Adler.
Source/WebCore:
Test: http/tests/inspector-protocol/loading-iframe-document-node.html
Renamed InspectorDOMAgent::loadEventFired to InspectorDOMAgent::didCommitLoad and moved the call site
from InspectorInstrumentation::loadEventFiredImpl to InspectorInstrumentation::didCommitLoadImpl.
This is to make sure that it will invalidate the content of the iframe as soon as the frame navigates
to a different page. This way the new node can be retrieved as soon as the page has some content, and
not just when the page is fully loaded.
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::didCommitLoad): Renamed from loadEventFired, as it is now called from
didCommitLoadImpl instead.
(WebCore::InspectorDOMAgent::frameDocumentUpdated): Updated comment to point to the new function name.
* inspector/InspectorDOMAgent.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::loadEventFiredImpl): Removed call do InspectorDOMAgent.loadEventFired.
(WebCore::InspectorInstrumentation::didCommitLoadImpl): Added call to InspectorDOMAgent.didCommitLoad.
LayoutTests:
Added test to check that immediately after the scripting context is created, the
inspector already has access to the nodeId of the document of the iframe.
* http/tests/inspector-protocol/loading-iframe-document-node-expected.txt: Added.
* http/tests/inspector-protocol/loading-iframe-document-node.html: Added.
* http/tests/inspector-protocol/resources/slow-test-page.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (157424 => 157425)
--- trunk/LayoutTests/ChangeLog 2013-10-14 21:59:41 UTC (rev 157424)
+++ trunk/LayoutTests/ChangeLog 2013-10-14 23:08:37 UTC (rev 157425)
@@ -1,3 +1,17 @@
+2013-10-14 Alexandru Chiculita <[email protected]>
+
+ The content of the DOM panel for iframes is not updated until the "onload" event
+ https://bugs.webkit.org/show_bug.cgi?id=122653
+
+ Reviewed by Darin Adler.
+
+ Added test to check that immediately after the scripting context is created, the
+ inspector already has access to the nodeId of the document of the iframe.
+
+ * http/tests/inspector-protocol/loading-iframe-document-node-expected.txt: Added.
+ * http/tests/inspector-protocol/loading-iframe-document-node.html: Added.
+ * http/tests/inspector-protocol/resources/slow-test-page.html: Added.
+
2013-10-14 Filip Pizlo <[email protected]>
Unreviewed, fix the paths so that the test passes.
Added: trunk/LayoutTests/http/tests/inspector-protocol/loading-iframe-document-node-expected.txt (0 => 157425)
--- trunk/LayoutTests/http/tests/inspector-protocol/loading-iframe-document-node-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector-protocol/loading-iframe-document-node-expected.txt 2013-10-14 23:08:37 UTC (rev 157425)
@@ -0,0 +1,9 @@
+step1_bootstrap
+Main document loaded
+step2_onFrameStartedLoading
+step3_onExecutionContextCreated: Requesting document from iframe's context.
+Received script object for iframe's document node
+step4_requestNode: Requesting DOM node for iframe's document node
+PASS: Received node for iframe's document node
+Test finished
+
Added: trunk/LayoutTests/http/tests/inspector-protocol/loading-iframe-document-node.html (0 => 157425)
--- trunk/LayoutTests/http/tests/inspector-protocol/loading-iframe-document-node.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector-protocol/loading-iframe-document-node.html 2013-10-14 23:08:37 UTC (rev 157425)
@@ -0,0 +1,119 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+
+var frame;
+
+function appendIframe()
+{
+ frame = document.createElement("iframe");
+ frame.src = ""
+ document.body.appendChild(frame);
+}
+
+function removeIframe()
+{
+ frame.remove();
+}
+
+function test()
+{
+ /*
+ Testing that the Node ID can be retrieved before the onload event is triggered:
+ 1. Create an iframe and point it to a page with a slow-loading image.
+ 2. Wait until the JS context is created in the iframe.
+ 3. Use the JS contet to identify the "window.document" object inside the iframe.
+ 4. Use the JS object to retrieve the DOM agent nodeid for the document node.
+ */
+
+ InspectorTest.eventHandler["Page.frameStartedLoading"] = step2_onFrameStartedLoading;
+ InspectorTest.eventHandler["Runtime.executionContextCreated"] = step3_onExecutionContextCreated;
+ InspectorTest.eventHandler["Page.loadEventFired"] = onLoadEventFired;
+
+ var targetFrameId = null;
+
+ function step1_bootstrap() {
+ InspectorTest.log("step1_bootstrap");
+ // Enable the frame events.
+ InspectorTest.sendCommand("Page.enable", {}, function() {
+ // Enable the Runtime.executionContextCreated event.
+ InspectorTest.sendCommand("Runtime.enable", {}, function() {
+ // Initialize the DOM agent.
+ InspectorTest.sendCommand("DOM.getDocument", {}, function() {
+ InspectorTest.log("Main document loaded");
+
+ // Add the iframe to the DOM.
+ InspectorTest.sendCommand("Runtime.evaluate", { "_expression_": "appendIframe()" });
+ });
+ });
+ });
+ }
+
+ function step2_onFrameStartedLoading(response)
+ {
+ InspectorTest.log("step2_onFrameStartedLoading");
+ targetFrameId = response.params.frameId;
+ }
+
+ function step3_onExecutionContextCreated(event)
+ {
+ var frameId = event.params.context.frameId;
+ if (frameId !== targetFrameId)
+ return;
+
+ InspectorTest.log("step3_onExecutionContextCreated: Requesting document from iframe's context.");
+
+ InspectorTest.sendCommand("Runtime.evaluate", {
+ "_expression_": "document",
+ "objectGroup": "console",
+ "includeCommandLineAPI": false,
+ "contextId": event.params.context.id,
+ "doNotPauseOnExceptionsAndMuteConsole": false,
+ "returnByValue": false,
+ "generatePreview": false
+ }, callback);
+
+ function callback(response)
+ {
+ var objectId = response.result.result.objectId;
+ InspectorTest.log("Received script object for iframe's document node");
+ step4_requestNode(frameId, objectId);
+ }
+ }
+
+ function step4_requestNode(frameId, objectId)
+ {
+ function callback(response)
+ {
+ InspectorTest.log(response.result.nodeId ? "PASS: Received node for iframe's document node" : "FAIL: Iframe's document node is not available");
+ completeTest();
+ }
+
+ InspectorTest.log("step4_requestNode: Requesting DOM node for iframe's document node");
+ InspectorTest.sendCommand("DOM.requestNode", { objectId: objectId }, callback);
+ }
+
+ function completeTest()
+ {
+ InspectorTest.log("Test finished");
+ // Stop loading the iframe to avoid timing out the test.
+ InspectorTest.sendCommand("Runtime.evaluate", { "_expression_": "removeIframe()" });
+ InspectorTest.completeTest();
+ }
+
+ function onLoadEventFired()
+ {
+ // We should finish the test before this event is triggered.
+ // If you see this in the output, then the slow-image is not loaded correctly in the iframe.
+ InspectorTest.log("FAIL: Iframe load event fired before the test finished.");
+ }
+
+ step1_bootstrap()
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/inspector-protocol/resources/slow-test-page.html (0 => 157425)
--- trunk/LayoutTests/http/tests/inspector-protocol/resources/slow-test-page.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector-protocol/resources/slow-test-page.html 2013-10-14 23:08:37 UTC (rev 157425)
@@ -0,0 +1,13 @@
+<html>
+<head>
+ <script>
+ // Having a script tag so that we force the creationg of a scripting context.
+ // FIXME: Avoid using Runtime.executionContextCreated to figure out the iframe's contentDocument node.
+ // https://bugs.webkit.org/show_bug.cgi?id=122764
+ </script>
+</head>
+<body>
+ <!-- Delay the onload event using a slow image -->
+ <img src="" />
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (157424 => 157425)
--- trunk/Source/WebCore/ChangeLog 2013-10-14 21:59:41 UTC (rev 157424)
+++ trunk/Source/WebCore/ChangeLog 2013-10-14 23:08:37 UTC (rev 157425)
@@ -1,3 +1,27 @@
+2013-10-14 Alexandru Chiculita <[email protected]>
+
+ The content of the DOM panel for iframes is not updated until the "onload" event
+ https://bugs.webkit.org/show_bug.cgi?id=122653
+
+ Reviewed by Darin Adler.
+
+ Test: http/tests/inspector-protocol/loading-iframe-document-node.html
+
+ Renamed InspectorDOMAgent::loadEventFired to InspectorDOMAgent::didCommitLoad and moved the call site
+ from InspectorInstrumentation::loadEventFiredImpl to InspectorInstrumentation::didCommitLoadImpl.
+ This is to make sure that it will invalidate the content of the iframe as soon as the frame navigates
+ to a different page. This way the new node can be retrieved as soon as the page has some content, and
+ not just when the page is fully loaded.
+
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::didCommitLoad): Renamed from loadEventFired, as it is now called from
+ didCommitLoadImpl instead.
+ (WebCore::InspectorDOMAgent::frameDocumentUpdated): Updated comment to point to the new function name.
+ * inspector/InspectorDOMAgent.h:
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::loadEventFiredImpl): Removed call do InspectorDOMAgent.loadEventFired.
+ (WebCore::InspectorInstrumentation::didCommitLoadImpl): Added call to InspectorDOMAgent.didCommitLoad.
+
2013-10-14 Roger Fong <[email protected]>
https://bugs.webkit.org/show_bug.cgi?id=122774.
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (157424 => 157425)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2013-10-14 21:59:41 UTC (rev 157424)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2013-10-14 23:08:37 UTC (rev 157425)
@@ -1587,7 +1587,7 @@
m_frontend->documentUpdated();
}
-void InspectorDOMAgent::loadEventFired(Document* document)
+void InspectorDOMAgent::didCommitLoad(Document* document)
{
Element* frameOwner = document->ownerElement();
if (!frameOwner)
@@ -1762,7 +1762,7 @@
return;
// Only update the main frame document, nested frame document updates are not required
- // (will be handled by loadEventFired()).
+ // (will be handled by didCommitLoad()).
setDocument(document);
}
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (157424 => 157425)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2013-10-14 21:59:41 UTC (rev 157424)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2013-10-14 23:08:37 UTC (rev 157425)
@@ -164,7 +164,7 @@
void releaseDanglingNodes();
void mainFrameDOMContentLoaded();
- void loadEventFired(Document*);
+ void didCommitLoad(Document*);
void didInsertDOMNode(Node*);
void didRemoveDOMNode(Node*);
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (157424 => 157425)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2013-10-14 21:59:41 UTC (rev 157424)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2013-10-14 23:08:37 UTC (rev 157425)
@@ -860,9 +860,6 @@
void InspectorInstrumentation::loadEventFiredImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
{
- if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
- domAgent->loadEventFired(frame->document());
-
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
timelineAgent->didMarkLoadEvent(frame);
@@ -913,6 +910,8 @@
#endif
inspectorAgent->didCommitLoad();
}
+ if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
+ domAgent->didCommitLoad(loader->frame()->document());
if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
canvasAgent->frameNavigated(loader->frame());
if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())