Chromium Code Reviews| 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; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 pc.oniceconnectionstatechange = onIceChange2; | 24 pc.oniceconnectionstatechange = onIceChange2; |
| 25 pc.close(); | 25 pc.close(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 function unexpectedCallback() | 28 function unexpectedCallback() |
| 29 { | 29 { |
| 30 testFailed("unexpectedCallback was called."); | 30 testFailed("unexpectedCallback was called."); |
| 31 finishJSTest(); | 31 finishJSTest(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 function expectedTypeError(error) | 34 function expectedTypeError(reason) |
|
philipj_slow
2016/02/24 08:14:03
I think error was a better name :)
Guido Urdaneta
2016/02/24 12:42:10
Done.
| |
| 35 { | 35 { |
| 36 shouldBe(error.name, "TypeError") | 36 window.error = reason; |
| 37 testPassed("expectedTypeError was called.") | 37 shouldBe('error.name', '"TypeError"'); |
| 38 testPassed("expectedTypeError was called."); | |
| 38 } | 39 } |
| 39 | 40 |
| 40 function onIceChange1() | 41 function onIceChange1() |
| 41 { | 42 { |
| 42 if (pc.iceConnectionState === "completed") { | 43 if (pc.iceConnectionState === "completed") { |
| 43 testPassed("iceConnectionState is completed"); | 44 testPassed("iceConnectionState is completed"); |
| 44 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | 45 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); |
| 45 shouldNotThrow('pc.addIceCandidate(null, addIceCandidateSuccess, unexpec tedCallback).catch(expectedTypeError);'); | 46 shouldNotThrow('pc.addIceCandidate(null, addIceCandidateSuccess, unexpec tedCallback).catch(expectedTypeError);'); |
| 46 shouldNotThrow('pc.addIceCandidate(iceCandidate, null, unexpectedCallbac k).catch(expectedTypeError);'); | 47 shouldNotThrow('pc.addIceCandidate(iceCandidate, null, unexpectedCallbac k).catch(expectedTypeError);'); |
| 47 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess, null).catch(expectedTypeError);'); | 48 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess, null).catch(expectedTypeError);'); |
| 48 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess, unexpectedCallback);'); | 49 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess, unexpectedCallback);'); |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 function testExecutionOrderClosedConnection() | 53 function testExecutionOrderClosedConnection() |
| 53 { | 54 { |
| 54 var localPeerConnection = new webkitRTCPeerConnection(null, null); | 55 var localPeerConnection = new webkitRTCPeerConnection(null, null); |
| 55 localPeerConnection.close(); | 56 localPeerConnection.close(); |
| 56 var counter = 0; | 57 var counter = 0; |
| 57 events = []; | 58 window.events = []; |
| 58 Promise.resolve().then(_ => events[counter++] = 1); | 59 Promise.resolve().then(_ => events[counter++] = 1); |
| 59 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | 60 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); |
| 60 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, (error ) => { | 61 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, (error ) => { |
| 61 window.error = error; | 62 window.error = error; |
| 62 shouldBe('error', '"The RTCPeerConnection\'s signalingState is \'closed\ '."'); | 63 shouldBe('error.name', '"InvalidStateError"'); |
|
philipj_slow
2016/02/24 08:14:03
It wouldn't hurt to check error.message as well, i
Guido Urdaneta
2016/02/24 12:42:09
Done.
| |
| 63 events[counter++] = 2; | 64 events[counter++] = 2; |
| 64 }); | 65 }); |
| 65 Promise.resolve().then(_ => { | 66 Promise.resolve().then(_ => { |
| 66 events[counter++] = 3; | 67 events[counter++] = 3; |
| 67 shouldBe('events', '[1,2,3]'); | 68 shouldBe('events', '[1,2,3]'); |
| 68 }); | 69 }); |
| 69 } | 70 } |
| 70 | 71 |
| 71 shouldNotThrow('testExecutionOrderClosedConnection()'); | 72 shouldNotThrow('testExecutionOrderClosedConnection()'); |
| 72 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); | 73 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); |
| 73 pc.oniceconnectionstatechange = onIceChange1; | 74 pc.oniceconnectionstatechange = onIceChange1; |
| 74 | 75 |
| 75 window.jsTestIsAsync = true; | 76 window.jsTestIsAsync = true; |
| 76 window.successfullyParsed = true; | 77 window.successfullyParsed = true; |
| 77 </script> | 78 </script> |
| 78 </body> | 79 </body> |
| 79 </html> | 80 </html> |
| OLD | NEW |