summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc/protocol/msid-generate.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webrtc/protocol/msid-generate.html')
-rw-r--r--testing/web-platform/tests/webrtc/protocol/msid-generate.html153
1 files changed, 153 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc/protocol/msid-generate.html b/testing/web-platform/tests/webrtc/protocol/msid-generate.html
new file mode 100644
index 0000000000..0fcf28ee6b
--- /dev/null
+++ b/testing/web-platform/tests/webrtc/protocol/msid-generate.html
@@ -0,0 +1,153 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>RTCPeerconnection MSID generation</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../RTCPeerConnection-helper.js"></script>
+<script src="../third_party/sdp/sdp.js"></script>
+<script>
+
+function msidLines(desc) {
+ const sections = SDPUtils.splitSections(desc.sdp);
+ return SDPUtils.matchPrefix(sections[1], 'a=msid:');
+}
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const dc = pc.createDataChannel('foo');
+ const desc = await pc.createOffer();
+ assert_equals(msidLines(desc).length, 0);
+}, 'No media track produces no MSID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ pc.addTrack(stream1.getTracks()[0]);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:-/);
+}, 'AddTrack without a stream produces MSID with no stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ pc.addTrack(stream1.getTracks()[0], stream1);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'AddTrack with a stream produces MSID with a stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ const stream2 = new MediaStream(stream1.getTracks());
+ pc.addTrack(stream1.getTracks()[0], stream1, stream2);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 2);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+ assert_regexp_match(msid_lines[1], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'AddTrack with two streams produces two MSID lines');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ pc.addTrack(stream1.getTracks()[0], stream1, stream1);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'AddTrack with the stream twice produces single MSID with a stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ pc.addTransceiver(stream1.getTracks()[0]);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:-/);
+}, 'AddTransceiver without a stream produces MSID with no stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ pc.addTransceiver(stream1.getTracks()[0], {streams: [stream1]});
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'AddTransceiver with a stream produces MSID with a stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ const stream2 = new MediaStream(stream1.getTracks());
+ pc.addTransceiver(stream1.getTracks()[0], {streams: [stream1, stream2]});
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 2);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+ assert_regexp_match(msid_lines[1], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'AddTransceiver with two streams produces two MSID lines');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ pc.addTransceiver(stream1.getTracks()[0], {streams: [stream1, stream1]});
+const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'AddTransceiver with the stream twice produces single MSID with a stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ const {sender} = pc.addTransceiver(stream1.getTracks()[0]);
+ sender.setStreams(stream1);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'SetStreams with a stream produces MSID with a stream ID');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ const stream2 = new MediaStream(stream1.getTracks());
+ const {sender} = pc.addTransceiver(stream1.getTracks()[0]);
+ sender.setStreams(stream1, stream2);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 2);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+ assert_regexp_match(msid_lines[1], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'SetStreams with two streams produces two MSID lines');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const stream1 = await getNoiseStream({audio: true});
+ const {sender} = pc.addTransceiver(stream1.getTracks()[0]);
+ sender.setStreams(stream1, stream1);
+ const desc = await pc.createOffer();
+ const msid_lines = msidLines(desc);
+ assert_equals(msid_lines.length, 1);
+ assert_regexp_match(msid_lines[0], /^a=msid:[\!#$%&'*+-.0-9a-zA-Z]/);
+}, 'SetStreams with the stream twice produces single MSID with a stream ID');
+
+</script>