| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 <!-- TODO(guidou): Convert test to testharness.js. crbug.com/614963 --> | |
| 6 </head> | |
| 7 <body> | |
| 8 <script> | |
| 9 description("Tests the RTCPeerConnection Ice functionality."); | |
| 10 | |
| 11 var pc = null; | |
| 12 var iceCandidate = null; | |
| 13 | |
| 14 function onIceChange2() | |
| 15 { | |
| 16 if (pc.iceConnectionState === "closed") { | |
| 17 testPassed("iceConnectionState is closed."); | |
| 18 finishJSTest(); | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 function addIceCandidateSuccess1() | |
| 23 { | |
| 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."); | |
| 43 pc.oniceconnectionstatechange = onIceChange2; | |
| 44 pc.close(); | |
| 45 } | |
| 46 | |
| 47 function unexpectedCallback() | |
| 48 { | |
| 49 testFailed("unexpectedCallback was called."); | |
| 50 finishJSTest(); | |
| 51 } | |
| 52 | |
| 53 function expectedTypeError(error) | |
| 54 { | |
| 55 window.error = error; | |
| 56 shouldBe('error.name', '"TypeError"'); | |
| 57 testPassed("expectedTypeError was called."); | |
| 58 } | |
| 59 | |
| 60 function onIceChange1() | |
| 61 { | |
| 62 if (pc.iceConnectionState === "completed") { | |
| 63 testPassed("iceConnectionState is completed"); | |
| 64 iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | |
| 65 shouldNotThrow('pc.addIceCandidate(null, unexpectedCallback, unexpectedC
allback).catch(expectedTypeError);'); | |
| 66 shouldNotThrow('pc.addIceCandidate({candidate: "candidate"}, unexpectedC
allback, unexpectedCallback).catch(expectedTypeError);'); | |
| 67 shouldNotThrow('pc.addIceCandidate(iceCandidate, null, unexpectedCallbac
k).catch(expectedTypeError);'); | |
| 68 shouldNotThrow('pc.addIceCandidate(iceCandidate, unexpectedCallback, nul
l).catch(expectedTypeError);'); | |
| 69 shouldNotThrow('pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1
, unexpectedCallback);'); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 function testExecutionOrderClosedConnection() | |
| 74 { | |
| 75 var localPeerConnection = new webkitRTCPeerConnection(null, null); | |
| 76 localPeerConnection.close(); | |
| 77 var counter = 0; | |
| 78 window.events = []; | |
| 79 Promise.resolve().then(_ => events[counter++] = 1); | |
| 80 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | |
| 81 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error
=> { | |
| 82 window.error = error; | |
| 83 shouldBe('error.name', '"InvalidStateError"'); | |
| 84 shouldBe('error.toString()', '"InvalidStateError: The RTCPeerConnection\
's signalingState is \'closed\'."'); | |
| 85 events[counter++] = 2; | |
| 86 }); | |
| 87 Promise.resolve().then(_ => { | |
| 88 events[counter++] = 3; | |
| 89 shouldBe('events', '[1,2,3]'); | |
| 90 }); | |
| 91 } | |
| 92 | |
| 93 shouldNotThrow('testExecutionOrderClosedConnection()'); | |
| 94 shouldNotThrow('pc = new webkitRTCPeerConnection(null, null);'); | |
| 95 pc.oniceconnectionstatechange = onIceChange1; | |
| 96 | |
| 97 window.jsTestIsAsync = true; | |
| 98 window.successfullyParsed = true; | |
| 99 </script> | |
| 100 </body> | |
| 101 </html> | |
| OLD | NEW |