Bug 980622 - Free media element node to release decoder. r=cajbir, a=test-only
authorAlfredo Yang <ayang@mozilla.com>
Tue, 27 Jan 2015 02:27:00 -0500
changeset 243078 5af391c10cbe
parent 243077 f421202b153f
child 243079 4b9480a0f719
push id4383
push userryanvm@gmail.com
push date2015-01-28 15:06 +0000
treeherdermozilla-beta@897f73d9e4f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir, test-only
bugs980622
milestone36.0
Bug 980622 - Free media element node to release decoder. r=cajbir, a=test-only
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);