OLD | NEW |
---|---|
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
5 <!-- TODO(guidou): Convert test to testharness.js. crbug.com/614963 --> | 5 <script src="../../resources/testharnessreport.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 description("Tests the RTCPeerConnection Ice functionality."); | |
10 | |
11 var pc = null; | |
12 var iceCandidate = null; | |
13 | |
14 function onIceChange2() | 9 function onIceChange2() |
15 { | 10 { |
16 if (pc.iceConnectionState === "closed") { | 11 if (window.pc.iceConnectionState === "closed") { |
17 testPassed("iceConnectionState is closed."); | 12 calledCallbacks.push("iceConnectionState closed"); |
18 finishJSTest(); | 13 assert_array_equals(calledCallbacks, [ |
14 'iceConnectionState complete', | |
15 'expectedTypeError', | |
16 'expectedTypeError', | |
17 'expectedTypeError', | |
18 'expectedTypeError', | |
19 'success1', | |
20 'success2', | |
21 'success3', | |
22 'success4', | |
23 'iceConnectionState closed' | |
24 ]); | |
25 window.testRTC.done(); | |
qyearsley
2016/09/06 16:09:36
I was experimenting with trying to get convert tes
jeffcarp
2016/09/06 17:26:38
When I was testing this I remember it failing quic
| |
19 } | 26 } |
20 } | 27 } |
21 | 28 |
22 function addIceCandidateSuccess1() | 29 function addIceCandidateSuccess1() |
23 { | 30 { |
24 testPassed("addIceCandidateSuccess1 was called."); | 31 calledCallbacks.push('success1'); |
25 shouldNotThrow('pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addI ceCandidateSuccess2, unexpectedCallback);'); | 32 window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addIceCandida teSuccess2, unexpectedCallback); |
26 } | 33 } |
27 | 34 |
28 function addIceCandidateSuccess2() | 35 function addIceCandidateSuccess2() |
29 { | 36 { |
30 testPassed("addIceCandidateSuccess2 was called."); | 37 calledCallbacks.push('success2'); |
31 shouldNotThrow('pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0 }, addIceCandidateSuccess3, unexpectedCallback);'); | 38 window.pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, addIce CandidateSuccess3, unexpectedCallback); |
32 } | 39 } |
33 | 40 |
34 function addIceCandidateSuccess3() | 41 function addIceCandidateSuccess3() |
35 { | 42 { |
36 testPassed("addIceCandidateSuccess3 was called."); | 43 calledCallbacks.push('success3'); |
37 shouldNotThrow('pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpML ineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback);'); | 44 window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpMLineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback); |
38 } | 45 } |
39 | 46 |
40 function addIceCandidateSuccess4() | 47 function addIceCandidateSuccess4() |
41 { | 48 { |
42 testPassed("addIceCandidateSuccess4 was called."); | 49 calledCallbacks.push('success4'); |
43 pc.oniceconnectionstatechange = onIceChange2; | 50 window.pc.oniceconnectionstatechange = onIceChange2; |
44 pc.close(); | 51 window.pc.close(); |
45 } | 52 } |
46 | 53 |
47 function unexpectedCallback() | 54 function unexpectedCallback() |
48 { | 55 { |
49 testFailed("unexpectedCallback was called."); | 56 calledCallbacks.push('unexpected'); |
50 finishJSTest(); | |
51 } | 57 } |
52 | 58 |
53 function expectedTypeError(error) | 59 function expectedTypeError(error) |
54 { | 60 { |
55 window.error = error; | 61 assert_equals(error.name, 'TypeError'); |
56 shouldBe('error.name', '"TypeError"'); | 62 calledCallbacks.push('expectedTypeError'); |
57 testPassed("expectedTypeError was called."); | |
58 } | 63 } |
59 | 64 |
60 function onIceChange1() | 65 function onIceChange1() |
61 { | 66 { |
62 if (pc.iceConnectionState === "completed") { | 67 if (window.pc.iceConnectionState === "completed") { |
63 testPassed("iceConnectionState is completed"); | 68 calledCallbacks.push('iceConnectionState complete'); |
64 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | 69 var iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); |
65 shouldNotThrow('pc.addIceCandidate(null, unexpectedCallback, unexpectedC allback).catch(expectedTypeError);'); | 70 window.pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback). catch(expectedTypeError); |
66 shouldNotThrow('pc.addIceCandidate({candidate: "candidate"}, unexpectedC allback, unexpectedCallback).catch(expectedTypeError);'); | 71 window.pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError); |
67 shouldNotThrow('pc.addIceCandidate(iceCandidate, null, unexpectedCallbac k).catch(expectedTypeError);'); | 72 window.pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch( expectedTypeError); |
68 shouldNotThrow('pc.addIceCandidate(iceCandidate, unexpectedCallback, nul l).catch(expectedTypeError);'); | 73 window.pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch( expectedTypeError); |
69 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1 , unexpectedCallback);'); | 74 window.pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpec tedCallback); |
70 } | 75 } |
71 } | 76 } |
72 | 77 |
73 function testExecutionOrderClosedConnection() | 78 function testExecutionOrderClosedConnection() |
74 { | 79 { |
75 var localPeerConnection = new webkitRTCPeerConnection(null, null); | 80 var localPeerConnection = new webkitRTCPeerConnection(null, null); |
76 localPeerConnection.close(); | 81 localPeerConnection.close(); |
77 var counter = 0; | 82 var counter = 0; |
78 window.events = []; | 83 window.events = []; |
79 Promise.resolve().then(_ => events[counter++] = 1); | 84 Promise.resolve().then(_ => events[counter++] = 1); |
80 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | 85 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); |
81 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error => { | 86 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error => { |
82 window.error = error; | 87 assert_equals(error.name, 'InvalidStateError'); |
83 shouldBe('error.name', '"InvalidStateError"'); | 88 assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnectio n\'s signalingState is \'closed\'.'); |
84 shouldBe('error.toString()', '"InvalidStateError: The RTCPeerConnection\ 's signalingState is \'closed\'."'); | |
85 events[counter++] = 2; | 89 events[counter++] = 2; |
86 }); | 90 }); |
87 Promise.resolve().then(_ => { | 91 Promise.resolve().then(_ => { |
88 events[counter++] = 3; | 92 events[counter++] = 3; |
89 shouldBe('events', '[1,2,3]'); | 93 assert_array_equals(events, [1, 2, 3]); |
90 }); | 94 }); |
91 } | 95 } |
92 | 96 |
93 shouldNotThrow('testExecutionOrderClosedConnection()'); | 97 window.calledCallbacks = []; |
94 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); | 98 window.testRTC = async_test("Tests the RTCPeerConnection Ice functionality."); |
95 pc.oniceconnectionstatechange = onIceChange1; | |
96 | 99 |
97 window.jsTestIsAsync = true; | 100 testExecutionOrderClosedConnection(); |
98 window.successfullyParsed = true; | 101 window.pc = new webkitRTCPeerConnection(null, null); |
102 window.pc.oniceconnectionstatechange = onIceChange1; | |
99 </script> | 103 </script> |
100 </body> | 104 </body> |
101 </html> | 105 </html> |
OLD | NEW |