Index: LayoutTests/imported/web-platform-tests/webrtc/promises-call.html |
diff --git a/LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html b/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html |
similarity index 57% |
copy from LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html |
copy to LayoutTests/imported/web-platform-tests/webrtc/promises-call.html |
index 0a02b8a1c03de6226eec78d06a452547a4ffba66..e52be7502222917fff4216129a3d9c96fe2cafbb 100644 |
--- a/LayoutTests/imported/web-platform-tests/webrtc/no-media-call.html |
+++ b/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html |
@@ -1,12 +1,12 @@ |
<!doctype html> |
<!-- |
-This test uses no media, and thus does not require fake media devices. |
+This test uses data only, and thus does not require fake media devices. |
--> |
<html> |
<head> |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
- <title>RTCPeerConnection No-Media Connection Test</title> |
+ <title>RTCPeerConnection Data-Only Connection Test with Promises</title> |
</head> |
<body> |
<div id="log"></div> |
@@ -25,50 +25,11 @@ This test uses no media, and thus does not require fake media devices. |
> |
</script> |
<script type="text/javascript"> |
- var test = async_test('Can set up a basic WebRTC call with no data.'); |
+ var test = async_test('Can set up a basic WebRTC call with only data using promises.'); |
var gFirstConnection = null; |
var gSecondConnection = null; |
- var onOfferCreated = test.step_func(function(offer) { |
- // TODO: Switch to promise-based interface. |
- gFirstConnection.setLocalDescription(offer, ignoreSuccess, |
- failed('setLocalDescription first')); |
- |
- // This would normally go across the application's signaling solution. |
- // In our case, the "signaling" is to call this function. |
- receiveCall(offer.sdp); |
- }); |
- |
- function receiveCall(offerSdp) { |
- |
- var parsedOffer = new RTCSessionDescription({ type: 'offer', |
- sdp: offerSdp }); |
- // These functions use the legacy interface extensions to RTCPeerConnection. |
- // TODO: Switch to promise-based interfaces. |
- gSecondConnection.setRemoteDescription(parsedOffer, |
- function() { |
- gSecondConnection.createAnswer(onAnswerCreated, |
- failed('createAnswer')); |
- }, |
- failed('setRemoteDescription second')); |
- }; |
- |
- var onAnswerCreated = test.step_func(function(answer) { |
- gSecondConnection.setLocalDescription(answer, ignoreSuccess, |
- failed('setLocalDescription second')); |
- |
- // Similarly, this would go over the application's signaling solution. |
- handleAnswer(answer.sdp); |
- }); |
- |
- function handleAnswer(answerSdp) { |
- var parsedAnswer = new RTCSessionDescription({ type: 'answer', |
- sdp: answerSdp }); |
- gFirstConnection.setRemoteDescription(parsedAnswer, ignoreSuccess, |
- failed('setRemoteDescription first')); |
- }; |
- |
var onIceCandidateToFirst = test.step_func(function(event) { |
// If event.candidate is null = no more candidates. |
if (event.candidate) { |
@@ -115,17 +76,6 @@ This test uses no media, and thus does not require fake media devices. |
} |
}); |
- // Returns a suitable error callback. |
- function failed(function_name) { |
- return test.step_func(function() { |
- assert_unreached('WebRTC called error callback for ' + function_name); |
- }); |
- } |
- |
- // Returns a suitable do-nothing. |
- function ignoreSuccess(function_name) { |
- } |
- |
// This function starts the test. |
test.step(function() { |
gFirstConnection = new RTCPeerConnection(null); |
@@ -137,11 +87,42 @@ This test uses no media, and thus does not require fake media devices. |
gSecondConnection.onaddstream = onRemoteStream; |
gSecondConnection.oniceconnectionstatechange = onIceConnectionStateChange; |
- // The offerToReceiveVideo is necessary and sufficient to make |
- // an actual connection. |
- // TODO: Use a promise-based API. This is legacy. |
- gFirstConnection.createOffer(onOfferCreated, failed('createOffer'), |
- {offerToReceiveVideo: true}); |
+ // The createDataChannel is necessary and sufficient to make |
+ // sure the ICE connection be attempted. |
+ gFirstConnection.createDataChannel('channel'); |
+ |
+ var atStep = 'Create offer'; |
+ |
+ gFirstConnection.createOffer() |
+ .then(function(offer) { |
+ atStep = 'Set local description at first'; |
+ return gFirstConnection.setLocalDescription(offer); |
+ }) |
+ .then(function() { |
+ atStep = 'Set remote description at second'; |
+ return gSecondConnection.setRemoteDescription( |
+ gFirstConnection.localDescription); |
+ }) |
+ .then(function() { |
+ atStep = 'Create answer'; |
+ return gSecondConnection.createAnswer() |
+ }) |
+ .then(function(answer) { |
+ atStep = 'Set local description at second'; |
+ return gSecondConnection.setLocalDescription(answer); |
+ }) |
+ .then(function() { |
+ atStep = 'Set remote description at first'; |
+ return gFirstConnection.setRemoteDescription( |
+ gSecondConnection.localDescription); |
+ }) |
+ .then(function() { |
+ atStep = 'Negotiation completed'; |
+ }) |
+ .catch(test.step_func(function(e) { |
+ assert_unreached('Error ' + e.name + ': ' + e.message + |
+ ' happened at step ' + atStep); |
+ })); |
}); |
</script> |