REGRESSION (r240644): Layout Test inspector/page/overrideSetting-ICECandidateFilterin...
[WebKit-https.git] / LayoutTests / inspector / page / overrideSetting-ICECandidateFilteringEnabled.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script>
6
7 if (window.internals)
8     window.internals.setICECandidateFiltering(true);
9
10 function createDataChannel() {
11     let receivedCandidate = false;
12
13     let dc = null;
14
15     let pc = new RTCPeerConnection;
16     pc.onicecandidate = (event) => {
17         if (event.candidate) {
18             if (!receivedCandidate)
19                 TestPage.addResult("PASS: received ICE candidate.");
20             receivedCandidate = true;
21             return;
22         }
23
24         TestPage.dispatchEventToFrontend("DataChannel", {success: !!receivedCandidate});
25
26         delete pc.onicecandidate;
27         pc.close();
28         dc.close();
29     };
30
31     TestPage.addResult("Creating data channel...");
32     dc = pc.createDataChannel("sendDataChannel");
33
34     pc.createOffer()
35     .then((offer) => {
36         TestPage.addResult("PASS: created offer");
37         return pc.setLocalDescription(offer);
38     })
39     .catch((error) => {
40         TestPage.addResult("FAIL: " + error);
41     });
42 }
43
44 function test()
45 {
46     let suite = InspectorTest.createAsyncSuite("Page.overrideSetting");
47
48     suite.addTestCase({
49         name: "Page.overrideSetting.ICECandidateFilteringEnabled",
50         description: "Test that changing whether ice candidate filtering is enabled has an effect.",
51         async test() {
52             InspectorTest.log("Overriding ICECandidateFilteringEnabled to false...");
53             await PageAgent.overrideSetting(PageAgent.Setting.ICECandidateFilteringEnabled, false);
54
55             let [overriddenResult] = await Promise.all([
56                 InspectorTest.awaitEvent("DataChannel"),
57                 InspectorTest.evaluateInPage(`createDataChannel()`),
58             ])
59             InspectorTest.expectThat(overriddenResult.data.success, "Should be able to establish a connection when filtering ice candidates.");
60         },
61     });
62
63     suite.runTestCasesAndFinish();
64 }
65
66 </script>
67 </head>
68 <body onload="runTest()">
69     <p>Tests for the Page.overrideSetting command.</p>
70 </body>
71 </html>