Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2018 20:07:17 +0000 (20:07 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2018 20:07:17 +0000 (20:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188856

Unreviewed test gardening.

* TestExpectations:
    Skipped test since it's only valid on WK2 platforms.
* http/tests/websocket/connection-refusal-in-frame-resource-load-statistics-expected.txt: Added.
* http/tests/websocket/connection-refusal-in-frame-resource-load-statistics.html: Renamed from LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html.
* http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt: Removed.
* http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html: Removed.
* http/tests/websocket/resources/localhost-websocket-connect.html: Added.
* platform/wk2/TestExpectations:
    Marked test as [ Pass ].

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235193 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/websocket/connection-refusal-in-frame-resource-load-statistics-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/connection-refusal-in-frame-resource-load-statistics.html [moved from LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html with 62% similarity]
LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt [deleted file]
LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html [deleted file]
LayoutTests/http/tests/websocket/resources/localhost-websocket-connect.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations

index 986db96..46282e0 100644 (file)
@@ -1,3 +1,20 @@
+2018-08-22  John Wilander  <wilander@apple.com>
+
+        Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
+        https://bugs.webkit.org/show_bug.cgi?id=188856
+
+        Unreviewed test gardening.
+
+        * TestExpectations:
+            Skipped test since it's only valid on WK2 platforms.
+        * http/tests/websocket/connection-refusal-in-frame-resource-load-statistics-expected.txt: Added.
+        * http/tests/websocket/connection-refusal-in-frame-resource-load-statistics.html: Renamed from LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html.
+        * http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt: Removed.
+        * http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html: Removed.
+        * http/tests/websocket/resources/localhost-websocket-connect.html: Added.
+        * platform/wk2/TestExpectations:
+            Marked test as [ Pass ].
+
 2018-08-22  Ryan Haddad  <ryanhaddad@apple.com>
 
         [iOS] Rebaseline table tests
index d8b16af..2b94980 100644 (file)
@@ -115,7 +115,7 @@ http/tests/appcache/decide-navigation-policy-after-delay.html [ Skip ]
 http/tests/misc/will-send-request-with-client-provided-http-body.html [ Skip ]
 http/tests/loading/resourceLoadStatistics/ [ Skip ]
 http/tests/resourceLoadStatistics/ [ Skip ]
-http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html [ Skip ]
+http/tests/websocket/connection-refusal-in-frame-resource-load-statistics.html [ Skip ]
 http/tests/storageAccess/ [ Skip ]
 http/tests/navigation/process-swap-window-open.html [ Skip ]
 http/tests/navigation/useragent-reload.php [ Skip ]
diff --git a/LayoutTests/http/tests/websocket/connection-refusal-in-frame-resource-load-statistics-expected.txt b/LayoutTests/http/tests/websocket/connection-refusal-in-frame-resource-load-statistics-expected.txt
new file mode 100644 (file)
index 0000000..4be267a
--- /dev/null
@@ -0,0 +1,12 @@
+CONSOLE MESSAGE: WebSocket network error: The operation couldn’t be completed. Connection refused
+CONSOLE MESSAGE: WebSocket network error: The operation couldn’t be completed. Connection refused
+Construct a cross-site WebSocket in a frame with server-side refusal. The test passes if Resource Load Statistics logs it properly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS localhost registered as subresource under 127.0.0.1.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
@@ -5,15 +5,10 @@
 </head>
 <body onload="runTest()">
 <script>
-    description('Construct a WebSocket in a detached frame. The test passes if Resource Load Statistics logs it properly.');
+    description('Construct a cross-site WebSocket in a frame with server-side refusal. The test passes if Resource Load Statistics logs it properly.');
 
     window.jsTestIsAsync = true;
 
-    function detachIframe() {
-        var testIframe = document.getElementById('testIframe');
-        testIframe.parentNode.remove(testIframe);
-    }
-
     function completeTest() {
         if (testRunner.isStatisticsRegisteredAsSubresourceUnder("http://localhost", "http://127.0.0.1"))
             testPassed("localhost registered as subresource under 127.0.0.1.");
         setEnableFeature(false, finishJSTest);
     }
 
-    let dataRecordsScanned = false;
-    function didScanDataRecords() {
-        dataRecordsScanned = true;
-        if (createdWebSocket)
-            completeTest();
-    }
-
-    let createdWebSocket = false;
-    function didCreateWebSocket() {
-        createdWebSocket = true;
-        if (dataRecordsScanned)
-            completeTest();
-    }
-
     function runTest() {
         setEnableFeature(true, function() {
             if (testRunner.isStatisticsRegisteredAsSubresourceUnder("http://localhost", "http://127.0.0.1"))
                 testFailed("localhost already registered as subresource under 127.0.0.1.");
 
             testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
-            testRunner.installStatisticsDidScanDataRecordsCallback(didScanDataRecords);
+            testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
 
             let iframeElement = document.createElement("iframe");
-            iframeElement.src = "resources/construct-in-detached-frame-resource-load-statistics.html";
+            iframeElement.src = "resources/localhost-websocket-connect.html";
             iframeElement.id = "testIframe";
             document.body.appendChild(iframeElement);
         });
diff --git a/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt b/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt
deleted file mode 100644 (file)
index 848cf21..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-PASS localhost registered as subresource under 127.0.0.1.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html b/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html
deleted file mode 100644 (file)
index ab7518b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<script>
-    var parentWindow = parent;
-    var webSocketClass = WebSocket;
-
-    parentWindow.detachIframe();
-    try {
-        new webSocketClass('ws://localhost/');
-    } catch (e) {
-        parentWindow.console.log(e.message);
-    }
-    parentWindow.didCreateWebSocket();
-</script>
diff --git a/LayoutTests/http/tests/websocket/resources/localhost-websocket-connect.html b/LayoutTests/http/tests/websocket/resources/localhost-websocket-connect.html
new file mode 100644 (file)
index 0000000..04170e4
--- /dev/null
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<script>
+    new WebSocket('ws://localhost/');
+</script>
index 925fbd2..e1a5679 100644 (file)
@@ -721,7 +721,7 @@ http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
 webkit.org/b/180703 http/tests/resourceLoadStatistics/telemetry-generation.html [ Pass Failure ]
 http/tests/resourceLoadStatistics/prune-statistics.html [ Pass ]
 http/tests/resourceLoadStatistics [ Pass ]
-http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html [ Pass ]
+http/tests/websocket/connection-refusal-in-frame-resource-load-statistics.html [ Pass ]
 # These are only supported behind a compile time flag in macOS High Sierra + iOS 11, and above.
 http/tests/resourceLoadStatistics/cookie-deletion.html [ Skip ]
 http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction.html [ Skip ]