Bug 995090 - test if cloned media element should be able to play till the end even after the src attribute of the original is changed. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Tue, 29 Apr 2014 18:59:00 +0200
changeset 181352 c8b374bf936b485e7b1404ca36285f1e47734d06
parent 181351 8ada6d76215baa84b8a2e65e10fbc3aff382a27a
child 181353 9eb4f13a78d83b07063d1f0d789a7bd7ac4541d2
child 181386 727238c137566e3b5197fc4492b6076fa2e764af
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerscpearce
bugs995090
milestone32.0a1
Bug 995090 - test if cloned media element should be able to play till the end even after the src attribute of the original is changed. r=cpearce
content/media/test/mochitest.ini
content/media/test/test_clone_media_element.html
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -314,16 +314,17 @@ skip-if = (buildapp == 'b2g' && (toolkit
 [test_bug874897.html]
 [test_bug883173.html]
 [test_bug895305.html]
 [test_bug895091.html]
 [test_bug919265.html]
 [test_bug957847.html]
 [test_chaining.html]
 skip-if = buildapp == 'b2g' # b2g(timed out) b2g-debug(timed out) b2g-desktop(timed out)
+[test_clone_media_element.html]
 [test_contentDuration1.html]
 [test_contentDuration2.html]
 [test_contentDuration3.html]
 [test_contentDuration4.html]
 [test_contentDuration5.html]
 [test_contentDuration6.html]
 [test_contentDuration7.html]
 [test_can_play_type.html]
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_clone_media_element.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test: cloned media element should continue to play to the end even after the source of the original element is cleared</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>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.requestLongerTimeout(2);
+// tests must run in sequence otherwise concurrent running test will also
+// update media cache which will hide the fact media cache not updated
+// after changes in media cache streams.
+PARALLEL_TESTS = 1;
+
+function startTest(test, token) {
+  manager.started(token);
+  info("Trying to load " + token);
+  var v = document.createElement('video');
+  v.preload = "metadata";
+  v.token = token;
+  v.src = test.name;
+
+  v.onloadedmetadata = function(evt) {
+    info(evt.target.token + " metadata loaded.");
+    evt.target.onloadedmetadata = null;
+    var clone = evt.target.cloneNode(false);
+    clone.token = evt.target.token;
+    clone.play();
+
+    clone.onloadstart = function(evt) {
+      info("cloned " + evt.target.token + " start loading.");
+      evt.target.onloadstart = null;
+      removeNodeAndSource(v);
+    }
+
+    clone.onended = function(evt) {
+      ok(true, "cloned " + evt.target.token + " ended.");
+      evt.target.onended = null;
+      removeNodeAndSource(evt.target);
+      manager.finished(evt.target.token);
+    }
+  }
+}
+
+var manager = new MediaTestManager;
+manager.runTests(gSmallTests.concat(gPlayedTests), startTest);
+
+</script>
+</pre>
+</body>
+</html>