Index: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html |
diff --git a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html |
index 934839020d6996be6d9f682de355e51311e85619..e41faf23567aefb86dbf5d9a56ae73f332eaa7ed 100644 |
--- a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html |
+++ b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-ice.html |
@@ -6,100 +6,69 @@ |
</head> |
<body> |
<script> |
-function onIceChange2() |
-{ |
- if (window.pc.iceConnectionState === "closed") { |
- calledCallbacks.push("iceConnectionState closed"); |
- assert_array_equals(calledCallbacks, [ |
- 'iceConnectionState complete', |
- 'expectedTypeError', |
- 'expectedTypeError', |
- 'expectedTypeError', |
- 'expectedTypeError', |
- 'success1', |
- 'success2', |
- 'success3', |
- 'success4', |
- 'iceConnectionState closed' |
- ]); |
- window.testRTC.done(); |
- } |
-} |
- |
-function addIceCandidateSuccess1() |
-{ |
- calledCallbacks.push('success1'); |
- window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, addIceCandidateSuccess2, unexpectedCallback); |
-} |
- |
-function addIceCandidateSuccess2() |
-{ |
- calledCallbacks.push('success2'); |
- window.pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, addIceCandidateSuccess3, unexpectedCallback); |
-} |
- |
-function addIceCandidateSuccess3() |
-{ |
- calledCallbacks.push('success3'); |
- window.pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpMLineIndex: 0}, addIceCandidateSuccess4, unexpectedCallback); |
-} |
-function addIceCandidateSuccess4() |
-{ |
- calledCallbacks.push('success4'); |
- window.pc.oniceconnectionstatechange = onIceChange2; |
- window.pc.close(); |
-} |
- |
-function unexpectedCallback() |
-{ |
+function unexpectedCallback() { |
assert_unreached('Unexpected callback'); |
} |
-function expectedTypeError(error) |
-{ |
- assert_equals(error.name, 'TypeError'); |
- calledCallbacks.push('expectedTypeError'); |
-} |
- |
-function onIceChange1() |
-{ |
- if (window.pc.iceConnectionState === "completed") { |
- calledCallbacks.push('iceConnectionState complete'); |
- var iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); |
- window.pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback).catch(expectedTypeError); |
- window.pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError); |
- window.pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch(expectedTypeError); |
- window.pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch(expectedTypeError); |
- window.pc.addIceCandidate(iceCandidate, addIceCandidateSuccess1, unexpectedCallback); |
- } |
-} |
- |
-function testExecutionOrderClosedConnection() |
-{ |
- var localPeerConnection = new webkitRTCPeerConnection(null, null); |
+async_test(function(t) { |
+ const localPeerConnection = new webkitRTCPeerConnection(null, null); |
localPeerConnection.close(); |
- var counter = 0; |
- window.events = []; |
+ let counter = 0; |
+ const events = []; |
Promise.resolve().then(_ => events[counter++] = 1); |
- var iceCandidate = new RTCIceCandidate({candidate:"nano nano"}); |
- localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, error => { |
+ const iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); |
+ |
+ localPeerConnection.addIceCandidate(iceCandidate, unexpectedCallback, t.step_func(error => { |
assert_equals(error.name, 'InvalidStateError'); |
assert_equals(error.toString(), 'InvalidStateError: The RTCPeerConnection\'s signalingState is \'closed\'.'); |
events[counter++] = 2; |
- }); |
- Promise.resolve().then(_ => { |
+ })); |
+ |
+ Promise.resolve().then(t.step_func_done(_ => { |
events[counter++] = 3; |
assert_array_equals(events, [1, 2, 3]); |
+ })); |
+}, "Test closed connection execution order"); |
+ |
+// Is there a difference between M53 and content_shell wrt RTCPeerconnection? |
+// oniceconnectionstatechange is called in content_shell but not in M53 |
+ |
+async_test(function(t) { |
+ |
+ function expectedTypeError(error) { |
+ assert_equals(error.name, 'TypeError'); |
+ } |
+ |
+ const pc = new webkitRTCPeerConnection(null, null); |
+ pc.oniceconnectionstatechange = t.step_func(function() { |
+ assert_equals(pc.iceConnectionState, "completed"); |
+ |
+ const iceCandidate = new RTCIceCandidate({candidate: "nano nano"}); |
+ |
+ pc.addIceCandidate(null, unexpectedCallback, unexpectedCallback).catch(expectedTypeError); |
+ pc.addIceCandidate({candidate: "candidate"}, unexpectedCallback, unexpectedCallback).catch(expectedTypeError); |
+ pc.addIceCandidate(iceCandidate, null, unexpectedCallback).catch(expectedTypeError); |
+ pc.addIceCandidate(iceCandidate, unexpectedCallback, null).catch(expectedTypeError); |
+ |
+ pc.addIceCandidate(iceCandidate, t.step_func(function() { |
+ pc.addIceCandidate({candidate: "candidate", sdpMid: 0}, t.step_func(function() { |
+ pc.addIceCandidate({candidate: "candidate", sdpMLineIndex: 0}, t.step_func(function() { |
+ pc.addIceCandidate({candidate: "candidate", sdpMid: 0, sdpMLineIndex: 0}, t.step_func(function() { |
+ pc.oniceconnectionstatechange = t.step_func_done(function() { |
+ assert_equals(pc.iceConnectionState, "closed"); |
+ }); |
+ pc.close(); |
+ }), unexpectedCallback); |
+ }), unexpectedCallback); |
+ |
+ }), unexpectedCallback); |
+ }), 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
|
+ |
}); |
-} |
-window.calledCallbacks = []; |
-window.testRTC = async_test("Tests the RTCPeerConnection Ice functionality."); |
+}, "Test RTCPeerConnection Ice functionality"); |
-testExecutionOrderClosedConnection(); |
-window.pc = new webkitRTCPeerConnection(null, null); |
-window.pc.oniceconnectionstatechange = onIceChange1; |
</script> |
</body> |
</html> |