summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_streams_srcObject.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/test/test_streams_srcObject.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--dom/media/test/test_streams_srcObject.html60
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/media/test/test_streams_srcObject.html b/dom/media/test/test_streams_srcObject.html
new file mode 100644
index 0000000000..8ea5797d14
--- /dev/null
+++ b/dom/media/test/test_streams_srcObject.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test interactions of src and srcObject</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body onload="doTests()">
+<audio id="a1"></audio>
+<audio id="a2"></audio>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+var doTest = srcObject => new Promise(resolve => {
+ var a = document.getElementById('a1');
+ a.src = getPlayableAudio(gSmallTests).name;
+ var b = new Audio();
+
+ var newSrc = a.src + "?2";
+ b.src = newSrc;
+ is(b[srcObject], null, "Initial srcObject is null");
+ var stream = a.mozCaptureStream();
+ b[srcObject] = stream;
+ is(b[srcObject], stream, "Stream set correctly");
+ try {
+ b[srcObject] = "invalid";
+ ok(false, "Setting srcObject to an invalid value should throw.");
+ } catch (e) {
+ ok(e instanceof TypeError, "Exception should be a TypeError");
+ }
+ is(b[srcObject], stream, "Stream not set to invalid value");
+ is(b.src, newSrc, "src attribute not affected by setting srcObject");
+ var step = 0;
+ b.addEventListener("loadedmetadata", function() {
+ if (step == 0) {
+ is(b.currentSrc, "", "currentSrc set to empty string while playing srcObject");
+ b[srcObject] = null;
+ is(b[srcObject], null, "Stream set to null");
+ // The resource selection algorithm will run again and choose b.src
+ } else if (step == 1) {
+ is(b.currentSrc, b.src, "currentSrc set to src now that srcObject is null");
+ resolve();
+ }
+ ++step;
+ });
+ a.play();
+ b.play();
+});
+
+var doTests = () => doTest("srcObject")
+ .catch(e => ok(false, "Unexpected error: " + e))
+ .then(() => SimpleTest.finish())
+ .catch(e => ok(false, "Coding error: " + e));
+
+</script>
+</pre>
+</body>
+</html>