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/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 description("Tests the RTCPeerConnection Ice functionality."); | 8 description("Tests the RTCPeerConnection Ice functionality."); |
9 | 9 |
10 var pc = null; | 10 var pc = null; |
11 var iceCandidate = null; | 11 var iceCandidate = null; |
12 | 12 |
13 function onIceChange2() | 13 function onIceChange2() |
14 { | 14 { |
15 if (pc.iceConnectionState === "closed") { | 15 if (pc.iceConnectionState === "closed") { |
16 testPassed("iceConnectionState is closed."); | 16 testPassed("iceConnectionState is closed."); |
17 finishJSTest(); | 17 finishJSTest(); |
18 } | 18 } |
19 } | 19 } |
20 | 20 |
21 function addIceCandidateSuccess() | 21 function addIceCandidateSuccess() |
22 { | 22 { |
23 testPassed("addIceCandidateSuccess was called."); | 23 testPassed("addIceCandidateSuccess was called."); |
24 pc.oniceconnectionstatechange = onIceChange2; | 24 pc.oniceconnectionstatechange = onIceChange2; |
25 pc.close(); | 25 pc.close(); |
26 } | 26 } |
27 | 27 |
28 function addIceCandidateFailure() | 28 function addIceCandidateFailure() |
29 { | 29 { |
30 testFailed("addIceCandidateFailue was called."); | 30 testFailed("addIceCandidateFailure was called."); |
31 finishJSTest(); | 31 finishJSTest(); |
32 } | 32 } |
33 | 33 |
34 function unexpectedSuccess() | |
35 { | |
36 testFailed("unexpectedSuccess was called."); | |
37 finishJSTest(); | |
38 } | |
39 | |
40 function expectedTypeError(error) | |
41 { | |
42 shouldBe(error.name, "TypeError") | |
philipj_slow
2016/02/15 10:22:21
"error.name" so that the output makes more sense?
Guido Urdaneta
2016/02/15 16:56:51
Done.
| |
43 testPassed("expectedTypeError was called.") | |
44 } | |
45 | |
34 function onIceChange1() | 46 function onIceChange1() |
35 { | 47 { |
36 if (pc.iceConnectionState === "completed") { | 48 if (pc.iceConnectionState === "completed") { |
37 testPassed("iceConnectionState is completed"); | 49 testPassed("iceConnectionState is completed"); |
38 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | 50 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); |
39 shouldThrow('pc.addIceCandidate(null, addIceCandidateSuccess, addIceCand idateFailure);'); | 51 shouldNotThrow('pc.addIceCandidate(null).then(unexpectedSuccess, expecte dTypeError);'); |
40 shouldThrow('pc.addIceCandidate(iceCandidate, null, addIceCandidateFailu re);'); | 52 shouldNotThrow('pc.addIceCandidate(iceCandidate).then(addIceCandidateSuc cess, addIceCandidateFailure);'); |
41 shouldThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess, nu ll);'); | |
42 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess, addIceCandidateFailure);'); | |
43 } | 53 } |
44 } | 54 } |
45 | 55 |
46 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); | 56 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); |
47 pc.oniceconnectionstatechange = onIceChange1; | 57 pc.oniceconnectionstatechange = onIceChange1; |
48 | 58 |
49 window.jsTestIsAsync = true; | 59 window.jsTestIsAsync = true; |
50 window.successfullyParsed = true; | 60 window.successfullyParsed = true; |
51 </script> | 61 </script> |
52 </body> | 62 </body> |
53 </html> | 63 </html> |
OLD | NEW |