Bug 980622 - Free media element node to release decoder. r=cajbir
authorAlfredo Yang <ayang@mozilla.com>
Tue, 27 Jan 2015 02:27:00 -0500
changeset 239546 d73961a4175273038edf708409198a5b58920f3b
parent 239545 1ca9cc2f0195add075be6a2799d6fbdb279bdf77
child 239547 94a2a4a7c84c3b3d7244d7e795479d0a977683b6
push id500
push userjoshua.m.grant@gmail.com
push dateThu, 29 Jan 2015 01:48:36 +0000
reviewerscajbir
bugs980622
milestone38.0a1
Bug 980622 - Free media element node to release decoder. r=cajbir
dom/media/test/test_bug495300.html
--- a/dom/media/test/test_bug495300.html
+++ b/dom/media/test/test_bug495300.html
@@ -23,31 +23,36 @@ function filename(uri) {
 
 function mediaEnded(event) {
   ok(true, "Got expected 'ended' event: " + filename(event.target.currentSrc));
 
   if (event.target._expectedDuration)
     ok(Math.abs(event.target.currentTime - event.target._expectedDuration) < 0.1,
        "currentTime equals duration: " + filename(event.target.currentSrc));
 
+  event.target.removeEventListener("ended", mediaEnded, false);
   manager.finished(event.target.token);
+  removeNodeAndSource(event.target);
+}
+
+function mediaLoadedmetadata(event) {
+  event.target.currentTime = event.target.duration;
+  event.target.removeEventListener("loadedmetadata", mediaLoadedmetadata, false);
 }
 
 function startTest(test, token) {
   var elemType = /^audio/.test(test.type) ? "audio" : "video";
   var v1 = document.createElement(elemType);
   v1.preload = "auto";
 
   v1.src = test.name;
   if (test.duration) {
     v1._expectedDuration = test.duration;
   }
-  v1.addEventListener("loadedmetadata", function (event) {
-    event.target.currentTime = event.target.duration;
-  }, false);
+  v1.addEventListener("loadedmetadata", mediaLoadedmetadata, false);
   v1.addEventListener("ended", mediaEnded, false);
   v1.load();
 
   v1.token = token;
   manager.started(token);
 }
 
 manager.runTests(gSeekTests, startTest);