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/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 function onIceChange2() | |
| 10 { | |
| 11 if (window.pc.iceConnectionState === "closed") { | |
| 12 calledCallbacks.push("iceConnectionState closed"); | |
| 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(); | |
| 26 } | |
| 27 } | |
| 28 | 9 |
| 29 function addIceCandidateSuccess1() | 10 function unexpectedCallback() { |
| 30 { | |
| 31 calledCallbacks.push('success1'); | |
| 32 window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addIceCandida teSuccess2, unexpectedCallback); | |
| 33 } | |
| 34 | |
| 35 function addIceCandidateSuccess2() | |
| 36 { | |
| 37 calledCallbacks.push('success2'); | |
| 38 window.pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, addIce CandidateSuccess3, unexpectedCallback); | |
| 39 } | |
| 40 | |
| 41 function addIceCandidateSuccess3() | |
| 42 { | |
| 43 calledCallbacks.push('success3'); | |
| 44 window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpMLineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback); | |
| 45 } | |
| 46 | |
| 47 function addIceCandidateSuccess4() | |
| 48 { | |
| 49 calledCallbacks.push('success4'); | |
| 50 window.pc.oniceconnectionstatechange = onIceChange2; | |
| 51 window.pc.close(); | |
| 52 } | |
| 53 | |
| 54 function unexpectedCallback() | |
| 55 { | |
| 56 assert_unreached('Unexpected callback'); | 11 assert_unreached('Unexpected callback'); |
| 57 } | 12 } |
| 58 | 13 |
| 59 function expectedTypeError(error) | 14 async_test(function(t) { |
| 60 { | 15 const localPeerConnection = new webkitRTCPeerConnection(null, null); |
| 61 assert_equals(error.name, 'TypeError'); | 16 localPeerConnection.close(); |
| 62 calledCallbacks.push('expectedTypeError'); | 17 let counter = 0; |
| 63 } | 18 const events = []; |
| 19 Promise.resolve().then(_ => events[counter++] = 1); | |
| 20 const iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); | |
| 64 | 21 |
| 65 function onIceChange1() | 22 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, t.step _func(error => { |
| 66 { | |
| 67 if (window.pc.iceConnectionState === "completed") { | |
| 68 calledCallbacks.push('iceConnectionState complete'); | |
| 69 var iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); | |
| 70 window.pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback). catch(expectedTypeError); | |
| 71 window.pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError); | |
| 72 window.pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch( expectedTypeError); | |
| 73 window.pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch( expectedTypeError); | |
| 74 window.pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpec tedCallback); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 function testExecutionOrderClosedConnection() | |
| 79 { | |
| 80 var localPeerConnection = new webkitRTCPeerConnection(null, null); | |
| 81 localPeerConnection.close(); | |
| 82 var counter = 0; | |
| 83 window.events = []; | |
| 84 Promise.resolve().then(_ => events[counter++] = 1); | |
| 85 var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); | |
| 86 localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error => { | |
| 87 assert_equals(error.name, 'InvalidStateError'); | 23 assert_equals(error.name, 'InvalidStateError'); |
| 88 assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnectio n\'s signalingState is \'closed\'.'); | 24 assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnectio n\'s signalingState is \'closed\'.'); |
| 89 events[counter++] = 2; | 25 events[counter++] = 2; |
| 90 }); | 26 })); |
| 91 Promise.resolve().then(_ => { | 27 |
| 28 Promise.resolve().then(t.step_func_done(_ => { | |
| 92 events[counter++] = 3; | 29 events[counter++] = 3; |
| 93 assert_array_equals(events, [1, 2, 3]); | 30 assert_array_equals(events, [1, 2, 3]); |
| 31 })); | |
| 32 }, "Test closed connection execution order"); | |
| 33 | |
| 34 // Is there a difference between M53 and content_shell wrt RTCPeerconnection? | |
| 35 // oniceconnectionstatechange is called in content_shell but not in M53 | |
| 36 | |
| 37 async_test(function(t) { | |
| 38 | |
| 39 function expectedTypeError(error) { | |
| 40 assert_equals(error.name, 'TypeError'); | |
| 41 } | |
| 42 | |
| 43 const pc = new webkitRTCPeerConnection(null, null); | |
| 44 pc.oniceconnectionstatechange = t.step_func(function() { | |
| 45 assert_equals(pc.iceConnectionState, "completed"); | |
| 46 | |
| 47 const iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); | |
| 48 | |
| 49 pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback).catch(e xpectedTypeError); | |
| 50 pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpec tedCallback).catch(expectedTypeError); | |
| 51 pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch(expecte dTypeError); | |
| 52 pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch(expecte dTypeError); | |
| 53 | |
| 54 pc.addIceCandidate(iceCandidate, t.step_func(function() { | |
| 55 pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, t.step_func( function() { | |
| 56 pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, t .step_func(function() { | |
| 57 pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpML ineIndex: 0}, t.step_func(function() { | |
| 58 pc.oniceconnectionstatechange = t.step_func_done(functio n() { | |
| 59 assert_equals(pc.iceConnectionState, "closed"); | |
| 60 }); | |
| 61 pc.close(); | |
| 62 }), unexpectedCallback); | |
| 63 }), unexpectedCallback); | |
| 64 | |
| 65 }), unexpectedCallback); | |
| 66 }), unexpectedCallback); | |
|
qyearsley
2016/09/07 18:17:03
I'm ambivalent about whether this is easier to rea
jeffcarp
2016/09/07 18:27:21
Agreed - I think I'm leaning toward named function
| |
| 67 | |
| 94 }); | 68 }); |
| 95 } | |
| 96 | 69 |
| 97 window.calledCallbacks = []; | 70 }, "Test RTCPeerConnection Ice functionality"); |
| 98 window.testRTC = async_test("Tests the RTCPeerConnection Ice functionality."); | |
| 99 | 71 |
| 100 testExecutionOrderClosedConnection(); | |
| 101 window.pc = new webkitRTCPeerConnection(null, null); | |
| 102 window.pc.oniceconnectionstatechange = onIceChange1; | |
| 103 </script> | 72 </script> |
| 104 </body> | 73 </body> |
| 105 </html> | 74 </html> |
| OLD | NEW |