REGRESSION (r240644): Layout Test inspector/page/overrideSetting-ICECandidateFilterin...
[WebKit-https.git] / LayoutTests / inspector / page / overrideSetting-ICECandidateFilteringEnabled.html
index 33d7812..bdb1ff8 100644 (file)
@@ -10,25 +10,34 @@ if (window.internals)
 function createDataChannel() {
     let receivedCandidate = false;
 
-    let pc = new RTCPeerConnection();
-    pc.createDataChannel("sendDataChannel");
+    let dc = null;
+
+    let pc = new RTCPeerConnection;
     pc.onicecandidate = (event) => {
         if (event.candidate) {
+            if (!receivedCandidate)
+                TestPage.addResult("PASS: received ICE candidate.");
             receivedCandidate = true;
             return;
         }
 
-        if (receivedCandidate) {
-            pc.createOffer().then((offer) => {
-                TestPage.dispatchEventToFrontend("DataChannel", {success: true});
-            });
-        } else
-            TestPage.dispatchEventToFrontend("DataChannel", {success: false});
+        TestPage.dispatchEventToFrontend("DataChannel", {success: !!receivedCandidate});
 
         delete pc.onicecandidate;
+        pc.close();
+        dc.close();
     };
-    pc.createOffer().then((offer) => {
-        pc.setLocalDescription(offer);
+
+    TestPage.addResult("Creating data channel...");
+    dc = pc.createDataChannel("sendDataChannel");
+
+    pc.createOffer()
+    .then((offer) => {
+        TestPage.addResult("PASS: created offer");
+        return pc.setLocalDescription(offer);
+    })
+    .catch((error) => {
+        TestPage.addResult("FAIL: " + error);
     });
 }
 
@@ -40,12 +49,6 @@ function test()
         name: "Page.overrideSetting.ICECandidateFilteringEnabled",
         description: "Test that changing whether ice candidate filtering is enabled has an effect.",
         async test() {
-            let [defaultResult] = await Promise.all([
-                InspectorTest.awaitEvent("DataChannel"),
-                InspectorTest.evaluateInPage(`createDataChannel()`),
-            ]);
-            InspectorTest.expectFalse(defaultResult.data.success, "Should not be able to establish a connection when filtering ice candidates.");
-
             InspectorTest.log("Overriding ICECandidateFilteringEnabled to false...");
             await PageAgent.overrideSetting(PageAgent.Setting.ICECandidateFilteringEnabled, false);
 
@@ -53,16 +56,7 @@ function test()
                 InspectorTest.awaitEvent("DataChannel"),
                 InspectorTest.evaluateInPage(`createDataChannel()`),
             ])
-            InspectorTest.expectFalse(defaultResult.data.success, "Should be able to establish a connection when filtering ice candidates.");
-
-            InspectorTest.log("Removing ICECandidateFilteringEnabled override...");
-            await PageAgent.overrideSetting(PageAgent.Setting.ICECandidateFilteringEnabled);
-
-            let [originalResult] = await Promise.all([
-                InspectorTest.awaitEvent("DataChannel"),
-                InspectorTest.evaluateInPage(`createDataChannel()`),
-            ])
-            InspectorTest.expectFalse(defaultResult.data.success, "Should not be able to establish a connection when filtering ice candidates.");
+            InspectorTest.expectThat(overriddenResult.data.success, "Should be able to establish a connection when filtering ice candidates.");
         },
     });