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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-AddRemoveTrack.html

Issue 2951713002: RTCPeerConnection.addTrack and removeTrack added (behind flag) (Closed)
Patch Set: Created 3 years, 5 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 <html>
3 <head>
4 <title>RTCPeerConnection.getSenders</title>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <script>
10 promise_test(function() {
11 let pc = new RTCPeerConnection();
12 return createStreams({audio:true, video:false}, 1)
13 .then(function(streams) {
14 let stream = streams[0];
15 let track = stream.getAudioTracks()[0];
16 let sender = pc.addTrack(track);
17 assert_equals(sender.track, track);
18 assert_array_equals(pc.getLocalStreams(), []);
19 });
20 }, 'addTrack() for a single track.');
21
22 promise_test(function() {
23 let pc = new RTCPeerConnection();
24 return createStreams({audio:true, video:false}, 1)
25 .then(function(streams) {
26 let stream = streams[0];
27 let track = stream.getAudioTracks()[0];
28 let sender = pc.addTrack(track, stream);
Guido Urdaneta 2017/07/06 09:49:57 why does this test produce the same result as the
hbos_chromium 2017/07/06 12:31:37 The difference can be observed in the SDP, but thi
29 assert_equals(sender.track, track);
30 assert_array_equals(pc.getLocalStreams(), []);
31 });
32 }, 'addTrack() for a single track and its stream.');
33
34 promise_test(function() {
35 let pc = new RTCPeerConnection();
36 return createStreams({audio:true, video:false}, 2)
37 .then(function(streams) {
38 let streamA = streams[0];
39 let trackA = streamA.getAudioTracks()[0];
40 let streamB = streams[1];
41 let sender = pc.addTrack(trackA, streamB);
Guido Urdaneta 2017/07/06 09:49:57 Same here, should passing |streamB| have an observ
hbos_chromium 2017/07/06 12:31:37 Ditto.
42 assert_equals(sender.track, trackA);
43 assert_array_equals(pc.getLocalStreams(), []);
44 });
45 }, 'addTrack() for a single track and a different stream.');
46
47 promise_test(function() {
48 let pc = new RTCPeerConnection();
49 return createStreams({audio:true, video:false}, 2)
50 .then(function(streams) {
51 let streamA = streams[0];
52 let streamB = streams[1];
53 let track = streamA.getAudioTracks()[0];
54 let exception = null;
55 try {
56 pc.addTrack(track, streamA, streamB);
57 } catch (e) {
58 exception = e;
59 }
60 // The spec supports multiple streams per track but our implementation
Guido Urdaneta 2017/07/06 09:49:57 Add a TODO to fix this test with reference to the
hbos_chromium 2017/07/06 12:31:37 Done.
61 // doesn't.
62 assert_true(exception != null);
63 assert_equals('NotSupportedError', exception.name);
64 });
65 }, 'addTrack() for a single track and two streams throws NotSupportedError.');
66
67 promise_test(function() {
68 let pc = new RTCPeerConnection();
69 return createStreams({audio:true, video:false}, 1)
70 .then(function(streams) {
71 let stream = streams[0];
72 let track = stream.getAudioTracks()[0];
73 let sender = pc.addTrack(track);
74 assert_equals(sender.track, track);
75 let exception = null;
76 try {
77 pc.addTrack(track);
78 } catch (e) {
79 exception = e;
80 }
81 assert_equals('InvalidAccessError', exception.name);
82 });
83 }, 'addTrack() when already added throws InvalidAccessError.');
84
85 promise_test(function() {
86 let pc = new RTCPeerConnection();
87 return createStreams({audio:true, video:false}, 1)
88 .then(function(streams) {
89 let stream = streams[0];
90 let track = stream.getAudioTracks()[0];
91 pc.addStream(stream);
92 let exception = null;
93 try {
94 pc.addTrack(track);
95 } catch (e) {
96 exception = e;
97 }
98 assert_true(exception != null);
99 assert_equals('InvalidAccessError', exception.name);
100 });
101 }, 'addTrack() after addStream() throws InvalidAccessError.');
102
103 promise_test(function() {
104 let pc = new RTCPeerConnection();
105 return createStreams({audio:true, video:false}, 1)
106 .then(function(streams) {
107 let stream = streams[0];
108 let track = stream.getAudioTracks()[0];
109 let sender = pc.addTrack(track);
110 assert_equals(sender.track, track);
111 assert_array_equals(pc.getSenders(), [ sender ]);
112 assert_array_equals(pc.getLocalStreams(), []);
113 pc.addStream(stream);
114 assert_array_equals(pc.getLocalStreams(), [ stream ]);
115 // The existing sender is reused by |addStream|.
116 assert_array_equals(pc.getSenders(), [ sender ]);
117 });
118 }, 'addTrack() before addStream() works.');
119
120 /**
121 * Helper functions to tests.
Guido Urdaneta 2017/07/06 09:49:57 remove " to tests"
hbos_chromium 2017/07/06 12:31:37 Done.
122 */
123
124 function createStreams(constraints, numStreams, streamsSoFar = []) {
125 if (numStreams == 0) {
126 return Promise.resolve(streamsSoFar);;
127 }
128 return navigator.mediaDevices.getUserMedia(constraints)
129 .then(function(stream) {
130 return createStreams(constraints,
131 numStreams - 1,
132 streamsSoFar.concat([stream]));
133 });
134 }
135 </script>
136 </body>
137 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698