summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_source.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/test/test_source.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/test/test_source.html')
-rw-r--r--dom/media/test/test_source.html92
1 files changed, 92 insertions, 0 deletions
diff --git a/dom/media/test/test_source.html b/dom/media/test/test_source.html
new file mode 100644
index 000000000..f64c0a3f7
--- /dev/null
+++ b/dom/media/test/test_source.html
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Media test: append source child</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>
+<video id="v1"></video>
+<audio id="a1"></audio>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var v1 = document.getElementById("v1");
+var a1 = document.getElementById("a1");
+v1.preload = "auto";
+a1.preload = "auto";
+
+is(v1.src, "", "src should be null");
+is(a1.src, "", "src should be null");
+is(v1.currentSrc, "", "currentSrc should be null");
+is(a1.currentSrc, "", "currentSrc should be null");
+is(v1.childNodes.length, 0, "should have no children");
+is(a1.childNodes.length, 0, "should have no children");
+
+function newSource(filter) {
+ var test = null;
+ var candidates = gSmallTests.filter(function(x){return filter.test(x.type);});
+ if (candidates.length > 0) {
+ var e = document.createElement("source");
+ e.type = candidates[0].type;
+ e.src = candidates[0].name;
+ return e;
+ } else {
+ return null
+ }
+}
+
+var audioLoaded = false;
+var videoLoaded = false;
+
+function loaded(e) {
+ var media = e.target;
+ ok(media.networkState > 0, "networkState should be > 0");
+ is(media.childNodes.length, 1, "should have 1 child");
+ var sourceFile = media.currentSrc.substring(media.currentSrc.lastIndexOf('/')+1);
+ var resource = media.firstChild.src.substring(media.firstChild.src.lastIndexOf('/')+1);
+ is(sourceFile, resource, "loaded wrong resource!");
+ if (media == a1)
+ audioLoaded = true;
+ else if (media == v1)
+ videoLoaded = true;
+ if (audioLoaded && videoLoaded) {
+ SimpleTest.finish();
+ }
+}
+
+v1.addEventListener('loadeddata', loaded, false);
+a1.addEventListener('loadeddata', loaded, false);
+
+var videoSource = newSource(/^video/);
+if (videoSource) {
+ v1.appendChild(videoSource);
+ v1.load();
+} else {
+ // No video backends? Don't test anything.
+ videoLoaded = true;
+}
+
+var audioSource = newSource(/^audio/);
+if (audioSource) {
+ a1.appendChild(audioSource);
+ a1.load();
+} else {
+ audioLoaded = true;
+}
+
+if (!audioLoaded && !videoLoaded) {
+ SimpleTest.waitForExplicitFinish();
+} else {
+ if (audioLoaded) {
+ todo(false, "No audio types supported");
+ }
+ if (videoLoaded) {
+ todo(false, "No video types supported");
+ }
+}
+
+</script>
+</pre>
+</body>
+</html>