| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <!-- | 2 <!-- |
| 3 This test uses data only, and thus does not require fake media devices. | 3 This test uses data only, and thus does not require fake media devices. |
| 4 --> | 4 --> |
| 5 | 5 |
| 6 <html> | 6 <html> |
| 7 <head> | 7 <head> |
| 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 9 <title>RTCPeerConnection Data-Only Connection Test with Promises</title> | 9 <title>RTCPeerConnection Data-Only Connection Test with Promises</title> |
| 10 </head> | 10 </head> |
| 11 <body> | 11 <body> |
| 12 <div id="log"></div> | 12 <div id="log"></div> |
| 13 <h2>iceConnectionState info</h2> | 13 <h2>iceConnectionState info</h2> |
| 14 <div id="stateinfo"> | 14 <div id="stateinfo"> |
| 15 </div> | 15 </div> |
| 16 | 16 |
| 17 <!-- These files are in place when executing on W3C. --> | 17 <!-- These files are in place when executing on W3C. --> |
| 18 <script src="../../../resources/testharness.js"></script> | 18 <script src="../../../resources/testharness.js"></script> |
| 19 <script src="../../../resources/testharnessreport.js"></script> | 19 <script src="../../../resources/testharnessreport.js"></script> |
| 20 <script src="../../../resources/vendor-prefix.js" | 20 <script src="../../../resources/vendor-prefix.js" |
| 21 data-prefixed-objects= | 21 data-prefixed-objects= |
| 22 '[{"ancestors":["window"], "name":"RTCPeerConnection"}, | 22 '[{"ancestors":["window"], "name":"RTCPeerConnection"}]' |
| 23 {"ancestors":["window"], "name":"RTCSessionDescription"}, | |
| 24 {"ancestors":["window"], "name":"RTCIceCandidate"}]' | |
| 25 > | 23 > |
| 26 </script> | 24 </script> |
| 27 <script type="text/javascript"> | 25 <script type="text/javascript"> |
| 28 var test = async_test('Can set up a basic WebRTC call with only data using pro
mises.'); | 26 var test = async_test('Can set up a basic WebRTC call with only data using pro
mises.'); |
| 29 | 27 |
| 30 var gFirstConnection = null; | 28 var gFirstConnection = null; |
| 31 var gSecondConnection = null; | 29 var gSecondConnection = null; |
| 32 | 30 |
| 33 var onIceCandidateToFirst = test.step_func(function(event) { | 31 var onIceCandidateToFirst = test.step_func(function(event) { |
| 34 // If event.candidate is null = no more candidates. | 32 // If event.candidate is null = no more candidates. |
| 35 if (event.candidate) { | 33 if (event.candidate) { |
| 36 var candidate = new RTCIceCandidate(event.candidate); | 34 gSecondConnection.addIceCandidate(event.candidate); |
| 37 gSecondConnection.addIceCandidate(candidate); | |
| 38 } | 35 } |
| 39 }); | 36 }); |
| 40 | 37 |
| 41 var onIceCandidateToSecond = test.step_func(function(event) { | 38 var onIceCandidateToSecond = test.step_func(function(event) { |
| 42 if (event.candidate) { | 39 if (event.candidate) { |
| 43 var candidate = new RTCIceCandidate(event.candidate); | 40 gFirstConnection.addIceCandidate(event.candidate); |
| 44 gFirstConnection.addIceCandidate(candidate); | |
| 45 } | 41 } |
| 46 }); | 42 }); |
| 47 | 43 |
| 48 var onRemoteStream = test.step_func(function(event) { | 44 var onRemoteStream = test.step_func(function(event) { |
| 49 assert_unreached('WebRTC received a stream when there was none'); | 45 assert_unreached('WebRTC received a stream when there was none'); |
| 50 }); | 46 }); |
| 51 | 47 |
| 52 var onIceConnectionStateChange = test.step_func(function(event) { | 48 var onIceConnectionStateChange = test.step_func(function(event) { |
| 53 assert_equals(event.type, 'iceconnectionstatechange'); | 49 assert_equals(event.type, 'iceconnectionstatechange'); |
| 54 var stateinfo = document.getElementById('stateinfo'); | 50 var stateinfo = document.getElementById('stateinfo'); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 atStep = 'Set local description at first'; | 94 atStep = 'Set local description at first'; |
| 99 return gFirstConnection.setLocalDescription(offer); | 95 return gFirstConnection.setLocalDescription(offer); |
| 100 }) | 96 }) |
| 101 .then(function() { | 97 .then(function() { |
| 102 atStep = 'Set remote description at second'; | 98 atStep = 'Set remote description at second'; |
| 103 return gSecondConnection.setRemoteDescription( | 99 return gSecondConnection.setRemoteDescription( |
| 104 gFirstConnection.localDescription); | 100 gFirstConnection.localDescription); |
| 105 }) | 101 }) |
| 106 .then(function() { | 102 .then(function() { |
| 107 atStep = 'Create answer'; | 103 atStep = 'Create answer'; |
| 108 return gSecondConnection.createAnswer() | 104 return gSecondConnection.createAnswer(); |
| 109 }) | 105 }) |
| 110 .then(function(answer) { | 106 .then(function(answer) { |
| 111 atStep = 'Set local description at second'; | 107 atStep = 'Set local description at second'; |
| 112 return gSecondConnection.setLocalDescription(answer); | 108 return gSecondConnection.setLocalDescription(answer); |
| 113 }) | 109 }) |
| 114 .then(function() { | 110 .then(function() { |
| 115 atStep = 'Set remote description at first'; | 111 atStep = 'Set remote description at first'; |
| 116 return gFirstConnection.setRemoteDescription( | 112 return gFirstConnection.setRemoteDescription( |
| 117 gSecondConnection.localDescription); | 113 gSecondConnection.localDescription); |
| 118 }) | 114 }) |
| 119 .then(function() { | 115 .then(function() { |
| 120 atStep = 'Negotiation completed'; | 116 atStep = 'Negotiation completed'; |
| 121 }) | 117 }) |
| 122 .catch(test.step_func(function(e) { | 118 .catch(test.step_func(function(e) { |
| 123 assert_unreached('Error ' + e.name + ': ' + e.message + | 119 assert_unreached('Error ' + e.name + ': ' + e.message + |
| 124 ' happened at step ' + atStep); | 120 ' happened at step ' + atStep); |
| 125 })); | 121 })); |
| 126 }); | 122 }); |
| 127 </script> | 123 </script> |
| 128 | 124 |
| 129 </body> | 125 </body> |
| 130 </html> | 126 </html> |
| OLD | NEW |