summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mst-content-hint
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/mst-content-hint
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mst-content-hint')
-rw-r--r--testing/web-platform/tests/mst-content-hint/META.yml3
-rw-r--r--testing/web-platform/tests/mst-content-hint/MediaStreamTrack-contentHint.html111
-rw-r--r--testing/web-platform/tests/mst-content-hint/RTCRtpSendParameters-degradationPreference.html129
-rw-r--r--testing/web-platform/tests/mst-content-hint/idlharness.window.js19
4 files changed, 262 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mst-content-hint/META.yml b/testing/web-platform/tests/mst-content-hint/META.yml
new file mode 100644
index 0000000000..7f79eccbaa
--- /dev/null
+++ b/testing/web-platform/tests/mst-content-hint/META.yml
@@ -0,0 +1,3 @@
+spec: https://w3c.github.io/mst-content-hint/
+suggested_reviewers:
+ - alvestrand
diff --git a/testing/web-platform/tests/mst-content-hint/MediaStreamTrack-contentHint.html b/testing/web-platform/tests/mst-content-hint/MediaStreamTrack-contentHint.html
new file mode 100644
index 0000000000..98c88e66ea
--- /dev/null
+++ b/testing/web-platform/tests/mst-content-hint/MediaStreamTrack-contentHint.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<canvas id="canvas">
+</canvas>
+<script>
+
+function createAudioTrack() {
+ ac = new AudioContext();
+ var osc = ac.createOscillator();
+ var dest = ac.createMediaStreamDestination();
+ osc.connect(dest);
+ audio_track = dest.stream.getAudioTracks()[0];
+
+ assert_equals(audio_track.kind, "audio");
+ return audio_track;
+}
+
+function createVideoTrack() {
+ canvas = document.getElementById("canvas");
+ video_track = canvas.captureStream().getVideoTracks()[0];
+
+ assert_equals(video_track.kind, "video");
+ return video_track;
+}
+
+test(t => {
+ audio_track = createAudioTrack();
+ assert_equals("", audio_track.contentHint);
+
+ video_track = createVideoTrack();
+ assert_equals("", video_track.contentHint);
+}, "Tracks have empty default content hint");
+
+test(t => {
+ audio_track = createAudioTrack();
+ audio_track.contentHint = "speech";
+ assert_equals(audio_track.contentHint, "speech");
+ audio_track.contentHint = "music";
+ assert_equals(audio_track.contentHint, "music");
+ audio_track.contentHint = "";
+ assert_equals(audio_track.contentHint, "");
+}, "Accepts valid audio contentHints");
+
+test(t => {
+ audio_track = createAudioTrack();
+ audio_track.contentHint = "speech";
+ assert_equals(audio_track.contentHint, "speech");
+ audio_track.contentHint = "motion";
+ assert_equals(audio_track.contentHint, "speech",
+ "Audio tracks should ignore video-only contentHints.");
+ audio_track.contentHint = "bogus";
+ assert_equals(audio_track.contentHint, "speech",
+ "Audio tracks should ignore garbage contentHints");
+}, "Audio tracks ignore invalid/video contentHints");
+
+test(t => {
+ video_track = createVideoTrack();
+ video_track.contentHint = "motion";
+ assert_equals(video_track.contentHint, "motion");
+ video_track.contentHint = "detail";
+ assert_equals(video_track.contentHint, "detail");
+ video_track.contentHint = "text";
+ assert_equals(video_track.contentHint, "text");
+ video_track.contentHint = "";
+ assert_equals(video_track.contentHint, "");
+}, "Accepts valid video contentHints");
+
+test(t => {
+ video_track = createVideoTrack();
+ video_track.contentHint = "motion";
+ assert_equals(video_track.contentHint, "motion");
+ video_track.contentHint = "speech";
+ assert_equals(video_track.contentHint, "motion",
+ "Video tracks should ignore audio-only contentHints.");
+ video_track.contentHint = "bogus";
+ assert_equals(video_track.contentHint, "motion",
+ "Video tracks should ignore garbage contentHints");
+}, "Video tracks ignore invalid/audio contentHints");
+
+test(t => {
+ video_track = createVideoTrack();
+ video_track.contentHint = "motion";
+ assert_equals(video_track.contentHint, "motion");
+
+ // Cloning a track should preserve contentHint.
+ video_track_clone = video_track.clone();
+ assert_equals(video_track_clone.contentHint, "motion");
+
+ // Changing a cloned track's contentHint should not change the original.
+ video_track_clone.contentHint = "detail";
+ assert_equals(video_track_clone.contentHint, "detail");
+ assert_equals(video_track.contentHint, "motion");
+}, "Cloned video tracks have separate contentHints");
+
+test(t => {
+ audio_track = createAudioTrack();
+ audio_track.contentHint = "speech";
+ assert_equals(audio_track.contentHint, "speech");
+
+ // Cloning a track should preserve contentHint.
+ audio_track_clone = audio_track.clone();
+ assert_equals(audio_track_clone.contentHint, "speech");
+
+ // Changing a cloned track's contentHint should not change the original.
+ audio_track_clone.contentHint = "music";
+ assert_equals(audio_track_clone.contentHint, "music");
+ assert_equals(audio_track.contentHint, "speech");
+}, "Cloned audio tracks have separate contentHints");
+
+</script>
diff --git a/testing/web-platform/tests/mst-content-hint/RTCRtpSendParameters-degradationPreference.html b/testing/web-platform/tests/mst-content-hint/RTCRtpSendParameters-degradationPreference.html
new file mode 100644
index 0000000000..3573bb5876
--- /dev/null
+++ b/testing/web-platform/tests/mst-content-hint/RTCRtpSendParameters-degradationPreference.html
@@ -0,0 +1,129 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>RTCRtpSendParameters degradationPreference</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ 'use strict';
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const { sender } = pc.addTransceiver('video');
+
+ let param = sender.getParameters();
+
+ assert_equals(param.degradationPreference, undefined,
+ 'Expect initial param.degradationPreference to be undefined');
+
+ param.degradationPreference = 'maintain-framerate';
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, 'maintain-framerate');
+
+ param.degradationPreference = 'maintain-resolution';
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, 'maintain-resolution');
+
+ param.degradationPreference = 'balanced';
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, 'balanced');
+
+ param.degradationPreference = undefined;
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, undefined);
+}, 'setParameters with degradationPreference set should succeed on video transceiver');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const { sender } = pc.addTransceiver('video');
+
+ let param = sender.getParameters();
+
+ assert_equals(param.degradationPreference, undefined,
+ 'Expect initial param.degradationPreference to be undefined');
+
+ param.degradationPreference = undefined;
+
+ await sender.setParameters(param);
+
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, undefined);
+}, 'setParameters with degradationPreference unset should succeed on video transceiver');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const { sender } = pc.addTransceiver('video');
+
+ let param = sender.getParameters();
+ param.degradationPreference = 'invalid';
+
+ return promise_rejects_js(t, TypeError, sender.setParameters(param));
+}, 'setParameters with invalid degradationPreference should throw TypeError on video transceiver');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const { sender } = pc.addTransceiver('audio');
+
+ let param = sender.getParameters();
+
+ assert_equals(param.degradationPreference, undefined,
+ 'Expect initial param.degradationPreference to be undefined');
+
+ param.degradationPreference = 'maintain-framerate';
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, 'maintain-framerate');
+
+ param.degradationPreference = 'maintain-resolution';
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, 'maintain-resolution');
+
+ param.degradationPreference = 'balanced';
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, 'balanced');
+
+ param.degradationPreference = undefined;
+ await sender.setParameters(param);
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, undefined);
+}, 'setParameters with degradationPreference set should succeed on audio transceiver');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const { sender } = pc.addTransceiver('audio');
+
+ let param = sender.getParameters();
+
+ assert_equals(param.degradationPreference, undefined,
+ 'Expect initial param.degradationPreference to be undefined');
+
+ param.degradationPreference = undefined;
+
+ await sender.setParameters(param);
+
+ param = sender.getParameters();
+ assert_equals(param.degradationPreference, undefined);
+}, 'setParameters with degradationPreference unset should succeed on audio transceiver');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ const { sender } = pc.addTransceiver('audio');
+
+ let param = sender.getParameters();
+ param.degradationPreference = 'invalid';
+
+ return promise_rejects_js(t, TypeError, sender.setParameters(param));
+}, 'setParameters with invalid degradationPreference should throw TypeError on audio transceiver');
+
+</script>
diff --git a/testing/web-platform/tests/mst-content-hint/idlharness.window.js b/testing/web-platform/tests/mst-content-hint/idlharness.window.js
new file mode 100644
index 0000000000..ef0e5e9812
--- /dev/null
+++ b/testing/web-platform/tests/mst-content-hint/idlharness.window.js
@@ -0,0 +1,19 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+// META: script=/webrtc/RTCPeerConnection-helper.js
+
+'use strict';
+
+idl_test(
+ ['mst-content-hint'],
+ ['mediacapture-streams', 'webrtc', 'dom'],
+ async idl_array => {
+ idl_array.add_objects({
+ MediaStreamTrack: ['audioTrack', 'videoTrack'],
+ });
+
+ const stream = await getNoiseStream({ audio: true, video: true });
+ self.audioTrack = stream.getAudioTracks()[0];
+ self.videoTrack = stream.getVideoTracks()[0];
+ }
+);