summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_streams_srcObject.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/test/test_streams_srcObject.html')
-rw-r--r--dom/media/test/test_streams_srcObject.html62
1 files changed, 62 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 000000000..a5a4205cd
--- /dev/null
+++ b/dom/media/test/test_streams_srcObject.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test interactions of src and srcObject</title>
+ <script type="text/javascript" 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();
+});
+
+// TODO: remove prefixed version soon (1183495).
+
+var doTests = () => doTest("srcObject").then(() => doTest("mozSrcObject"))
+ .catch(e => ok(false, "Unexpected error: " + e))
+ .then(() => SimpleTest.finish())
+ .catch(e => ok(false, "Coding error: " + e));
+
+</script>
+</pre>
+</body>
+</html>