Commit 949034f3 authored by Philipp Hancke's avatar Philipp Hancke Committed by Commit Bot

webrtc wpt: remove generateMediaStreamTrack in RTCRtpSender-replaceTrack

and add_cleanup

BUG=836871

Change-Id: I175e53f3466719403e5d61a68dc7125bf547e36e
Reviewed-on: https://chromium-review.googlesource.com/1140789
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577474}
parent 82221184
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Calling replaceTrack on closed connection should reject with InvalidStateError Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack on closed connection should reject with InvalidStateError promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack with track of different kind should reject with TypeError Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack with track of different kind should reject with TypeError promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack on stopped sender should reject with InvalidStateError Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack on stopped sender should reject with InvalidStateError promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack(null) on sender not set to session description should resolve with sender.track set to null Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack(null) on sender not set to session description should resolve with sender.track set to null promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack(null) on sender set to session description should resolve with sender.track set to null Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack(null) on sender set to session description should resolve with sender.track set to null promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack on sender with stopped track and and set to session description should resolve with sender.track set to given track Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack on sender with stopped track and and set to session description should resolve with sender.track set to given track promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
FAIL Calling replaceTrack on sender with similar track and and set to session description should resolve with sender.track set to new track Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument. FAIL Calling replaceTrack on sender with similar track and and set to session description should resolve with sender.track set to new track promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument."
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -3,16 +3,12 @@ ...@@ -3,16 +3,12 @@
<title>RTCRtpSender.prototype.replaceTrack</title> <title>RTCRtpSender.prototype.replaceTrack</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script> <script>
'use strict'; 'use strict';
// Test is based on the following editor draft: // Test is based on the following editor draft:
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
// The following helper functions are called from RTCPeerConnection-helper.js:
// generateMediaStreamTrack
/* /*
5.2. RTCRtpSender Interface 5.2. RTCRtpSender Interface
interface RTCRtpSender { interface RTCRtpSender {
...@@ -31,10 +27,12 @@ ...@@ -31,10 +27,12 @@
4. If connection's [[isClosed]] slot is true, return a promise rejected 4. If connection's [[isClosed]] slot is true, return a promise rejected
with a newly created InvalidStateError and abort these steps. with a newly created InvalidStateError and abort these steps.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver('audio'); const transceiver = pc.addTransceiver('audio');
const { sender } = transceiver; const { sender } = transceiver;
...@@ -50,10 +48,12 @@ ...@@ -50,10 +48,12 @@
transceiver kind of transceiver, return a promise rejected with a transceiver kind of transceiver, return a promise rejected with a
newly created TypeError. newly created TypeError.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('video'); const stream = await navigator.mediaDevices.getUserMedia({video: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver('audio'); const transceiver = pc.addTransceiver('audio');
const { sender } = transceiver; const { sender } = transceiver;
...@@ -67,10 +67,12 @@ ...@@ -67,10 +67,12 @@
5. If transceiver.stopped is true, return a promise rejected with a newly 5. If transceiver.stopped is true, return a promise rejected with a newly
created InvalidStateError. created InvalidStateError.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver('audio'); const transceiver = pc.addTransceiver('audio');
const { sender } = transceiver; const { sender } = transceiver;
...@@ -86,10 +88,12 @@ ...@@ -86,10 +88,12 @@
(section 3.4.1.), then set sender's track attribute to withTrack, and (section 3.4.1.), then set sender's track attribute to withTrack, and
return a promise resolved with undefined. return a promise resolved with undefined.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver('audio'); const transceiver = pc.addTransceiver('audio');
const { sender } = transceiver; const { sender } = transceiver;
...@@ -101,11 +105,15 @@ ...@@ -101,11 +105,15 @@
}); });
}, 'Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track'); }, 'Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track');
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track1 = generateMediaStreamTrack('audio'); const stream1 = await navigator.mediaDevices.getUserMedia({audio: true});
const track2 = generateMediaStreamTrack('audio'); t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
const [track1] = stream1.getTracks();
const stream2 = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
const [track2] = stream2.getTracks();
const transceiver = pc.addTransceiver(track1); const transceiver = pc.addTransceiver(track1);
const { sender } = transceiver; const { sender } = transceiver;
...@@ -118,10 +126,12 @@ ...@@ -118,10 +126,12 @@
}); });
}, 'Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track'); }, 'Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track');
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track); const transceiver = pc.addTransceiver(track);
const { sender } = transceiver; const { sender } = transceiver;
...@@ -145,10 +155,12 @@ ...@@ -145,10 +155,12 @@
3. Queue a task that runs the following steps: 3. Queue a task that runs the following steps:
2. Set sender's track attribute to withTrack. 2. Set sender's track attribute to withTrack.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track = generateMediaStreamTrack('audio'); const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const transceiver = pc.addTransceiver(track); const transceiver = pc.addTransceiver(track);
const { sender } = transceiver; const { sender } = transceiver;
...@@ -175,11 +187,15 @@ ...@@ -175,11 +187,15 @@
3. Queue a task that runs the following steps: 3. Queue a task that runs the following steps:
2. Set sender's track attribute to withTrack. 2. Set sender's track attribute to withTrack.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track1 = generateMediaStreamTrack('audio'); const stream1 = await navigator.mediaDevices.getUserMedia({audio: true});
const track2 = generateMediaStreamTrack('audio'); t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
const [track1] = stream1.getTracks();
const stream2 = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
const [track2] = stream1.getTracks();
const transceiver = pc.addTransceiver(track1); const transceiver = pc.addTransceiver(track1);
const { sender } = transceiver; const { sender } = transceiver;
...@@ -207,11 +223,15 @@ ...@@ -207,11 +223,15 @@
3. Queue a task that runs the following steps: 3. Queue a task that runs the following steps:
2. Set sender's track attribute to withTrack. 2. Set sender's track attribute to withTrack.
*/ */
promise_test(t => { promise_test(async t => {
const pc = new RTCPeerConnection(); const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close()); t.add_cleanup(() => pc.close());
const track1 = generateMediaStreamTrack('audio'); const stream1 = await navigator.mediaDevices.getUserMedia({audio: true});
const track2 = generateMediaStreamTrack('audio'); t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
const [track1] = stream1.getTracks();
const stream2 = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
const [track2] = stream1.getTracks();
const transceiver = pc.addTransceiver(track1); const transceiver = pc.addTransceiver(track1);
const { sender } = transceiver; const { sender } = transceiver;
......
This is a testharness.js-based test. This is a testharness.js-based test.
PASS Calling replaceTrack on closed connection should reject with InvalidStateError PASS Calling replaceTrack on closed connection should reject with InvalidStateError
FAIL Calling replaceTrack with track of different kind should reject with TypeError assert_throws: function "function() { throw e }" threw object "InvalidModificationError" ("InvalidModificationError") expected object "TypeError" ("TypeError") FAIL Calling replaceTrack with track of different kind should reject with TypeError assert_throws: function "function() { throw e }" threw object "InvalidModificationError" ("InvalidModificationError") expected object "TypeError" ("TypeError")
FAIL Calling replaceTrack on stopped sender should reject with InvalidStateError transceiver.stop is not a function FAIL Calling replaceTrack on stopped sender should reject with InvalidStateError promise_test: Unhandled rejection with value: object "TypeError: transceiver.stop is not a function"
PASS Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track PASS Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track
PASS Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track PASS Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track
PASS Calling replaceTrack(null) on sender not set to session description should resolve with sender.track set to null PASS Calling replaceTrack(null) on sender not set to session description should resolve with sender.track set to null
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment