Title: [241824] trunk
Revision
241824
Author
[email protected]
Date
2019-02-20 11:23:28 -0800 (Wed, 20 Feb 2019)

Log Message

Fix crash when opening Web Inspector after a WebSocket was blocked by content extensions
https://bugs.webkit.org/show_bug.cgi?id=194819

Patch by Loïc Yhuel <[email protected]> on 2019-02-20
Reviewed by Joseph Pecoraro.

Source/WebCore:

Test: http/tests/inspector/network/contentextensions/blocked-websocket-crash.html

* Modules/websockets/WebSocketChannel.h:
(WebCore::WebSocketChannel::hasCreatedHandshake):
* inspector/agents/page/PageNetworkAgent.cpp:
Ignore WebSocketChannel without an WebSocketHandshake, which would crash in InspectorNetworkAgent::enable.

LayoutTests:

* TestExpectations: Skip the test by default, like http/tests/contentextensions
* http/tests/inspector/network/contentextensions/blocked-websocket-crash-expected.txt: Added.
* http/tests/inspector/network/contentextensions/blocked-websocket-crash.html: Added.
* http/tests/inspector/network/contentextensions/blocked-websocket-crash.html.json: Added.
* platform/gtk/TestExpectations: Unskip the test
* platform/mac-wk2/TestExpectations: Ditto
* platform/wpe/TestExpectations: Ditto

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241823 => 241824)


--- trunk/LayoutTests/ChangeLog	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/LayoutTests/ChangeLog	2019-02-20 19:23:28 UTC (rev 241824)
@@ -1,3 +1,18 @@
+2019-02-20  Loïc Yhuel  <[email protected]>
+
+        Fix crash when opening Web Inspector after a WebSocket was blocked by content extensions
+        https://bugs.webkit.org/show_bug.cgi?id=194819
+
+        Reviewed by Joseph Pecoraro.
+
+        * TestExpectations: Skip the test by default, like http/tests/contentextensions
+        * http/tests/inspector/network/contentextensions/blocked-websocket-crash-expected.txt: Added.
+        * http/tests/inspector/network/contentextensions/blocked-websocket-crash.html: Added.
+        * http/tests/inspector/network/contentextensions/blocked-websocket-crash.html.json: Added.
+        * platform/gtk/TestExpectations: Unskip the test
+        * platform/mac-wk2/TestExpectations: Ditto
+        * platform/wpe/TestExpectations: Ditto
+
 2019-02-20  Shawn Roberts  <[email protected]>
 
         REGRESSION (r240727) [ Mac iOS ] Layout Test http/tests/workers/service/basic-register-exceptions.html is flaky

Modified: trunk/LayoutTests/TestExpectations (241823 => 241824)


--- trunk/LayoutTests/TestExpectations	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/LayoutTests/TestExpectations	2019-02-20 19:23:28 UTC (rev 241824)
@@ -1179,6 +1179,7 @@
 
 # Content extensions are Mac-WK2-only for now
 http/tests/contentextensions [ Skip ]
+http/tests/inspector/network/contentextensions [ Skip ]
 http/tests/websocket/tests/hybi/contentextensions [ Skip ]
 http/wpt/beacon/contentextensions [ Skip ]
 

Added: trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash-expected.txt (0 => 241824)


--- trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash-expected.txt	2019-02-20 19:23:28 UTC (rev 241824)
@@ -0,0 +1,8 @@
+CONSOLE MESSAGE: line 9: Content blocker prevented frame displaying http://127.0.0.1:8000/inspector/network/contentextensions/blocked-websocket-crash.html from loading a resource from ws://127.0.0.1/
+Test opening inspector after a blocked WebSocket connection.
+
+
+== Running test suite: Network.BlockedRequests
+-- Running test case: Network.BlockedRequests.WebSocket
+PASS: Web Inspector initialized.
+

Added: trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash.html (0 => 241824)


--- trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash.html	2019-02-20 19:23:28 UTC (rev 241824)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script>
+// Create a WebSocket before opening the inspector
+// url doesn't matter : it will be blocked by the content extension
+let ws = new WebSocket("ws://127.0.0.1");
+
+function test() {
+    let suite = InspectorTest.createAsyncSuite("Network.BlockedRequests");
+    suite.addTestCase({
+        name: "Network.BlockedRequests.WebSocket",
+        description: "Ensure Web Inspector works even after a blocked WebSocket connection",
+        test(resolve, reject) {
+            InspectorTest.pass("Web Inspector initialized.");
+            resolve();
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test opening inspector after a blocked WebSocket connection.</p>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash.html.json (0 => 241824)


--- trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash.html.json	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/contentextensions/blocked-websocket-crash.html.json	2019-02-20 19:23:28 UTC (rev 241824)
@@ -0,0 +1,10 @@
+[
+    {
+        "trigger": {
+            "url-filter": "^ws://"
+        },
+        "action": {
+            "type": "block"
+        }
+    }
+]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (241823 => 241824)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2019-02-20 19:23:28 UTC (rev 241824)
@@ -3858,6 +3858,7 @@
 fast/text/emoji-gender-fe0f-9.html [ Pass ]
 
 http/tests/contentextensions [ Pass ]
+http/tests/inspector/network/contentextensions [ Pass ]
 
 imported/w3c/web-platform-tests/css/css-scoping/stylesheet-title-001.html [ Pass ]
 imported/w3c/web-platform-tests/css/css-text/text-transform/text-transform-capitalize-026.html [ Pass ]

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (241823 => 241824)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2019-02-20 19:23:28 UTC (rev 241824)
@@ -518,6 +518,7 @@
 
 # Content Extensions tests must be enabled explicitly on mac-wk2.
 http/tests/contentextensions [ Pass ]
+http/tests/inspector/network/contentextensions [ Pass ]
 http/tests/websocket/tests/hybi/contentextensions [ Pass ]
 [ Sierra+ ] http/wpt/beacon/contentextensions [ Pass ]
 

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (241823 => 241824)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2019-02-20 19:23:28 UTC (rev 241824)
@@ -613,6 +613,7 @@
 
 # Content Extensions
 http/tests/contentextensions [ Pass ]
+http/tests/inspector/network/contentextensions [ Pass ]
 
 #////////////////////////////////////////////////////////////////////////////////////////
 # 5. TESTS CRASHING

Modified: trunk/Source/WebCore/ChangeLog (241823 => 241824)


--- trunk/Source/WebCore/ChangeLog	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/Source/WebCore/ChangeLog	2019-02-20 19:23:28 UTC (rev 241824)
@@ -1,3 +1,17 @@
+2019-02-20  Loïc Yhuel  <[email protected]>
+
+        Fix crash when opening Web Inspector after a WebSocket was blocked by content extensions
+        https://bugs.webkit.org/show_bug.cgi?id=194819
+
+        Reviewed by Joseph Pecoraro.
+
+        Test: http/tests/inspector/network/contentextensions/blocked-websocket-crash.html
+
+        * Modules/websockets/WebSocketChannel.h:
+        (WebCore::WebSocketChannel::hasCreatedHandshake):
+        * inspector/agents/page/PageNetworkAgent.cpp:
+        Ignore WebSocketChannel without an WebSocketHandshake, which would crash in InspectorNetworkAgent::enable.
+
 2019-02-20  Zalan Bujtas  <[email protected]>
 
         [LFC][Floats] Make FloatAvoider::resetPosition implicit

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h (241823 => 241824)


--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h	2019-02-20 19:23:28 UTC (rev 241824)
@@ -116,6 +116,7 @@
     void didFail(int errorCode) override;
 
     unsigned identifier() const { return m_identifier; }
+    bool hasCreatedHandshake() { return !!m_handshake; }
     ResourceRequest clientHandshakeRequest();
     const ResourceResponse& serverHandshakeResponse() const;
     WebSocketHandshake::Mode handshakeMode() const;

Modified: trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp (241823 => 241824)


--- trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp	2019-02-20 19:19:26 UTC (rev 241823)
+++ trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp	2019-02-20 19:23:28 UTC (rev 241824)
@@ -69,6 +69,9 @@
         if (!channel)
             continue;
 
+        if (!channel->hasCreatedHandshake())
+            continue;
+
         if (!is<Document>(webSocket->scriptExecutionContext()))
             continue;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to