Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/webrtc/promises-call.html

Issue 1984133002: Move web-platform-tests to wpt (part 2 of 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <!--
3 This test uses data only, and thus does not require fake media devices.
4 -->
5
6 <html>
7 <head>
8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9 <title>RTCPeerConnection Data-Only Connection Test with Promises</title>
10 </head>
11 <body>
12 <div id="log"></div>
13 <h2>iceConnectionState info</h2>
14 <div id="stateinfo">
15 </div>
16
17 <!-- These files are in place when executing on W3C. -->
18 <script src="../../../resources/testharness.js"></script>
19 <script src="../../../resources/testharnessreport.js"></script>
20 <script type="text/javascript">
21 var test = async_test('Can set up a basic WebRTC call with only data using pro mises.');
22
23 var gFirstConnection = null;
24 var gSecondConnection = null;
25
26 var onIceCandidateToFirst = test.step_func(function(event) {
27 // If event.candidate is null = no more candidates.
28 if (event.candidate) {
29 gSecondConnection.addIceCandidate(event.candidate);
30 }
31 });
32
33 var onIceCandidateToSecond = test.step_func(function(event) {
34 if (event.candidate) {
35 gFirstConnection.addIceCandidate(event.candidate);
36 }
37 });
38
39 var onRemoteStream = test.step_func(function(event) {
40 assert_unreached('WebRTC received a stream when there was none');
41 });
42
43 var onIceConnectionStateChange = test.step_func(function(event) {
44 assert_equals(event.type, 'iceconnectionstatechange');
45 var stateinfo = document.getElementById('stateinfo');
46 stateinfo.innerHTML = 'First: ' + gFirstConnection.iceConnectionState
47 + '<br>Second: ' + gSecondConnection.iceConnectionState;
48 // Note: All these combinations are legal states indicating that the
49 // call has connected. All browsers should end up in completed/completed,
50 // but as of this moment, we've chosen to terminate the test early.
51 // TODO: Revise test to ensure completed/completed is reached.
52 if (gFirstConnection.iceConnectionState == 'connected' &&
53 gSecondConnection.iceConnectionState == 'connected') {
54 test.done()
55 }
56 if (gFirstConnection.iceConnectionState == 'connected' &&
57 gSecondConnection.iceConnectionState == 'completed') {
58 test.done()
59 }
60 if (gFirstConnection.iceConnectionState == 'completed' &&
61 gSecondConnection.iceConnectionState == 'connected') {
62 test.done()
63 }
64 if (gFirstConnection.iceConnectionState == 'completed' &&
65 gSecondConnection.iceConnectionState == 'completed') {
66 test.done()
67 }
68 });
69
70 // This function starts the test.
71 test.step(function() {
72 gFirstConnection = new RTCPeerConnection(null);
73 gFirstConnection.onicecandidate = onIceCandidateToFirst;
74 gFirstConnection.oniceconnectionstatechange = onIceConnectionStateChange;
75
76 gSecondConnection = new RTCPeerConnection(null);
77 gSecondConnection.onicecandidate = onIceCandidateToSecond;
78 gSecondConnection.onaddstream = onRemoteStream;
79 gSecondConnection.oniceconnectionstatechange = onIceConnectionStateChange;
80
81 // The createDataChannel is necessary and sufficient to make
82 // sure the ICE connection be attempted.
83 gFirstConnection.createDataChannel('channel');
84
85 var atStep = 'Create offer';
86
87 gFirstConnection.createOffer()
88 .then(function(offer) {
89 atStep = 'Set local description at first';
90 return gFirstConnection.setLocalDescription(offer);
91 })
92 .then(function() {
93 atStep = 'Set remote description at second';
94 return gSecondConnection.setRemoteDescription(
95 gFirstConnection.localDescription);
96 })
97 .then(function() {
98 atStep = 'Create answer';
99 return gSecondConnection.createAnswer();
100 })
101 .then(function(answer) {
102 atStep = 'Set local description at second';
103 return gSecondConnection.setLocalDescription(answer);
104 })
105 .then(function() {
106 atStep = 'Set remote description at first';
107 return gFirstConnection.setRemoteDescription(
108 gSecondConnection.localDescription);
109 })
110 .then(function() {
111 atStep = 'Negotiation completed';
112 })
113 .catch(test.step_func(function(e) {
114 assert_unreached('Error ' + e.name + ': ' + e.message +
115 ' happened at step ' + atStep);
116 }));
117 });
118 </script>
119
120 </body>
121 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698