| 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 <!-- TODO(guidou): Convert test to testharness.js. crbug.com/614963 --> |
| 5 </head> | 6 </head> |
| 6 <body> | 7 <body> |
| 7 <script> | 8 <script> |
| 8 description("Tests the RTCPeerConnection Ice functionality."); | 9 description("Tests the RTCPeerConnection Ice functionality."); |
| 9 | 10 |
| 10 var pc = null; | 11 var pc = null; |
| 11 var iceCandidate = null; | 12 var iceCandidate = null; |
| 12 | 13 |
| 13 function onIceChange2() | 14 function onIceChange2() |
| 14 { | 15 { |
| 15 if (pc.iceConnectionState === "closed") { | 16 if (pc.iceConnectionState === "closed") { |
| 16 testPassed("iceConnectionState is closed."); | 17 testPassed("iceConnectionState is closed."); |
| 17 finishJSTest(); | 18 finishJSTest(); |
| 18 } | 19 } |
| 19 } | 20 } |
| 20 | 21 |
| 21 function addIceCandidateSuccess() | 22 function addIceCandidateSuccess1() |
| 22 { | 23 { |
| 23 testPassed("addIceCandidateSuccess was called."); | 24 testPassed("addIceCandidateSuccess1 was called."); |
| 25 shouldNotThrow('pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addI
ceCandidateSuccess2, unexpectedCallback);'); |
| 26 } |
| 27 |
| 28 function addIceCandidateSuccess2() |
| 29 { |
| 30 testPassed("addIceCandidateSuccess2 was called."); |
| 31 shouldNotThrow('pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0
}, addIceCandidateSuccess3, unexpectedCallback);'); |
| 32 } |
| 33 |
| 34 function addIceCandidateSuccess3() |
| 35 { |
| 36 testPassed("addIceCandidateSuccess3 was called."); |
| 37 shouldNotThrow('pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpML
ineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback);'); |
| 38 } |
| 39 |
| 40 function addIceCandidateSuccess4() |
| 41 { |
| 42 testPassed("addIceCandidateSuccess4 was called."); |
| 24 pc.oniceconnectionstatechange = onIceChange2; | 43 pc.oniceconnectionstatechange = onIceChange2; |
| 25 pc.close(); | 44 pc.close(); |
| 26 } | 45 } |
| 27 | 46 |
| 28 function unexpectedCallback() | 47 function unexpectedCallback() |
| 29 { | 48 { |
| 30 testFailed("unexpectedCallback was called."); | 49 testFailed("unexpectedCallback was called."); |
| 31 finishJSTest(); | 50 finishJSTest(); |
| 32 } | 51 } |
| 33 | 52 |
| 34 function expectedTypeError(error) | 53 function expectedTypeError(error) |
| 35 { | 54 { |
| 36 window.error = error; | 55 window.error = error; |
| 37 shouldBe('error.name', '"TypeError"'); | 56 shouldBe('error.name', '"TypeError"'); |
| 38 testPassed("expectedTypeError was called."); | 57 testPassed("expectedTypeError was called."); |
| 39 } | 58 } |
| 40 | 59 |
| 41 function onIceChange1() | 60 function onIceChange1() |
| 42 { | 61 { |
| 43 if (pc.iceConnectionState === "completed") { | 62 if (pc.iceConnectionState === "completed") { |
| 44 testPassed("iceConnectionState is completed"); | 63 testPassed("iceConnectionState is completed"); |
| 45 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | 64 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); |
| 46 shouldNotThrow('pc.addIceCandidate(null, addIceCandidateSuccess, unexpec
tedCallback).catch(expectedTypeError);'); | 65 shouldNotThrow('pc.addIceCandidate(null, unexpectedCallback, unexpectedC
allback).catch(expectedTypeError);'); |
| 66 shouldNotThrow('pc.addIceCandidate({candidate: "candidate"}, unexpectedC
allback, unexpectedCallback).catch(expectedTypeError);'); |
| 47 shouldNotThrow('pc.addIceCandidate(iceCandidate, null, unexpectedCallbac
k).catch(expectedTypeError);'); | 67 shouldNotThrow('pc.addIceCandidate(iceCandidate, null, unexpectedCallbac
k).catch(expectedTypeError);'); |
| 48 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess,
null).catch(expectedTypeError);'); | 68 shouldNotThrow('pc.addIceCandidate(iceCandidate, unexpectedCallback, nul
l).catch(expectedTypeError);'); |
| 49 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess,
unexpectedCallback);'); | 69 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1
, unexpectedCallback);'); |
| 50 } | 70 } |
| 51 } | 71 } |
| 52 | 72 |
| 53 function testExecutionOrderClosedConnection() | 73 function testExecutionOrderClosedConnection() |
| 54 { | 74 { |
| 55 var localPeerConnection = new webkitRTCPeerConnection(null, null); | 75 var localPeerConnection = new webkitRTCPeerConnection(null, null); |
| 56 localPeerConnection.close(); | 76 localPeerConnection.close(); |
| 57 var counter = 0; | 77 var counter = 0; |
| 58 window.events = []; | 78 window.events = []; |
| 59 Promise.resolve().then(_ => events[counter++] = 1); | 79 Promise.resolve().then(_ => events[counter++] = 1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 72 | 92 |
| 73 shouldNotThrow('testExecutionOrderClosedConnection()'); | 93 shouldNotThrow('testExecutionOrderClosedConnection()'); |
| 74 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); | 94 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); |
| 75 pc.oniceconnectionstatechange = onIceChange1; | 95 pc.oniceconnectionstatechange = onIceChange1; |
| 76 | 96 |
| 77 window.jsTestIsAsync = true; | 97 window.jsTestIsAsync = true; |
| 78 window.successfullyParsed = true; | 98 window.successfullyParsed = true; |
| 79 </script> | 99 </script> |
| 80 </body> | 100 </body> |
| 81 </html> | 101 </html> |
| OLD | NEW |