Title: [253166] trunk
Revision
253166
Author
[email protected]
Date
2019-12-05 12:35:24 -0800 (Thu, 05 Dec 2019)

Log Message

Web Inspector: Avoid using Runtime.executionContextCreated to figure out the iframe's contentDocument node.
https://bugs.webkit.org/show_bug.cgi?id=122764
<rdar://problem/15222136>

Reviewed by Devin Rousso.

Source/WebCore:

Force execution context creation on frame navigation similar to what inspector already
does for all known contexts when Runtime.enable is called. This is a prerequisite for
the injected script to work.

Test: inspector/runtime/execution-context-in-scriptless-page.html

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
* inspector/agents/page/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::frameNavigated):
* inspector/agents/page/PageRuntimeAgent.h:

LayoutTests:

Test that execution context is created and reported for pages without _javascript_.

* inspector/runtime/execution-context-in-scriptless-page-expected.txt: Added.
* inspector/runtime/execution-context-in-scriptless-page.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253165 => 253166)


--- trunk/LayoutTests/ChangeLog	2019-12-05 20:33:09 UTC (rev 253165)
+++ trunk/LayoutTests/ChangeLog	2019-12-05 20:35:24 UTC (rev 253166)
@@ -1,3 +1,16 @@
+2019-12-05  Yury Semikhatsky  <[email protected]>
+
+        Web Inspector: Avoid using Runtime.executionContextCreated to figure out the iframe's contentDocument node.
+        https://bugs.webkit.org/show_bug.cgi?id=122764
+        <rdar://problem/15222136>
+
+        Reviewed by Devin Rousso.
+
+        Test that execution context is created and reported for pages without _javascript_.
+
+        * inspector/runtime/execution-context-in-scriptless-page-expected.txt: Added.
+        * inspector/runtime/execution-context-in-scriptless-page.html: Added.
+
 2019-12-05  youenn fablet  <[email protected]>
 
         maplike should define a set method

Added: trunk/LayoutTests/inspector/runtime/execution-context-in-scriptless-page-expected.txt (0 => 253166)


--- trunk/LayoutTests/inspector/runtime/execution-context-in-scriptless-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/execution-context-in-scriptless-page-expected.txt	2019-12-05 20:35:24 UTC (rev 253166)
@@ -0,0 +1,8 @@
+Test that Runtime.executionContextCreated event is fired even for pages without _javascript_.
+
+
+== Running test suite: Runtime.executionContextCreated.ContextWithoutScript
+-- Running test case: Runtime.executionContextCreated.ContextWithoutScript.SubFrame
+PASS: Should receive Runtime.executionContextCreated notification.
+PASS: Should be able to evaluate in subframe.
+

Added: trunk/LayoutTests/inspector/runtime/execution-context-in-scriptless-page.html (0 => 253166)


--- trunk/LayoutTests/inspector/runtime/execution-context-in-scriptless-page.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/execution-context-in-scriptless-page.html	2019-12-05 20:35:24 UTC (rev 253166)
@@ -0,0 +1,53 @@
+<html>
+<head>
+<script src=""
+<script>
+
+function createFrame()
+{
+  let iframe = document.createElement("iframe");
+  iframe.src = "" _javascript_.</p>";
+  document.body.appendChild(iframe);
+}
+
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite("Runtime.executionContextCreated.ContextWithoutScript");
+
+    suite.addTestCase({
+        name: "Runtime.executionContextCreated.ContextWithoutScript.SubFrame",
+        description: "Test that Runtime.executionContextCreated event is fired when a new iframe is added to the page and its document doesn't have any _javascript_.",
+        async test() {
+            await InspectorProtocol.awaitCommand({method: "Page.enable"});
+            await InspectorProtocol.awaitCommand({method: "Runtime.enable"});
+
+            let [executionContextCreatedEvent] = await Promise.all([
+                InspectorProtocol.awaitEvent({event: "Runtime.executionContextCreated"}),
+                InspectorProtocol.awaitCommand({
+                    method: "Runtime.evaluate",
+                    params: {_expression_: `createFrame()`}
+                })
+            ]);
+
+            ProtocolTest.pass("Should receive Runtime.executionContextCreated notification.");
+
+            let evaluateResult = await InspectorProtocol.awaitCommand({
+                method: "Runtime.evaluate",
+                params: {
+                    contextId: executionContextCreatedEvent.params.context.id,
+                    _expression_: `document.body.textContent`
+                }
+            });
+
+            ProtocolTest.expectEqual(evaluateResult.result.value, "No _javascript_.", "Should be able to evaluate in subframe.");
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test that Runtime.executionContextCreated event is fired even for pages without _javascript_.</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (253165 => 253166)


--- trunk/Source/WebCore/ChangeLog	2019-12-05 20:33:09 UTC (rev 253165)
+++ trunk/Source/WebCore/ChangeLog	2019-12-05 20:35:24 UTC (rev 253166)
@@ -1,3 +1,23 @@
+2019-12-05  Yury Semikhatsky  <[email protected]>
+
+        Web Inspector: Avoid using Runtime.executionContextCreated to figure out the iframe's contentDocument node.
+        https://bugs.webkit.org/show_bug.cgi?id=122764
+        <rdar://problem/15222136>
+
+        Reviewed by Devin Rousso.
+
+        Force execution context creation on frame navigation similar to what inspector already
+        does for all known contexts when Runtime.enable is called. This is a prerequisite for
+        the injected script to work.
+
+        Test: inspector/runtime/execution-context-in-scriptless-page.html
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+        * inspector/agents/page/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::frameNavigated):
+        * inspector/agents/page/PageRuntimeAgent.h:
+
 2019-12-05  Chris Dumez  <[email protected]>
 
         MESSAGE_CHECK BackForwardItemIdentifier on incoming IPC from the WebProcess

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (253165 => 253166)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2019-12-05 20:33:09 UTC (rev 253165)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2019-12-05 20:35:24 UTC (rev 253166)
@@ -717,6 +717,9 @@
             pageHeapAgent->mainFrameNavigated();
     }
 
+    if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent())
+        pageRuntimeAgent->frameNavigated(frame);
+
     if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
         canvasAgent->frameNavigated(frame);
 

Modified: trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp (253165 => 253166)


--- trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp	2019-12-05 20:33:09 UTC (rev 253165)
+++ trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp	2019-12-05 20:35:24 UTC (rev 253166)
@@ -87,6 +87,12 @@
     InspectorRuntimeAgent::disable(errorString);
 }
 
+void PageRuntimeAgent::frameNavigated(Frame& frame)
+{
+    // Ensure execution context is created for the frame even if it doesn't have scripts.
+    mainWorldExecState(&frame);
+}
+
 void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame)
 {
     auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();

Modified: trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h (253165 => 253166)


--- trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h	2019-12-05 20:33:09 UTC (rev 253165)
+++ trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h	2019-12-05 20:35:24 UTC (rev 253166)
@@ -60,6 +60,7 @@
     void callFunctionOn(ErrorString&, const String& objectId, const String& _expression_, const JSON::Array* optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown) override;
 
     // InspectorInstrumentation
+    void frameNavigated(Frame&);
     void didClearWindowObjectInWorld(Frame&);
 
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to