Bug 1319357 - clean up media elements when media tests are done. r=jya
authorJW Wang <jwwang@mozilla.com>
Tue, 22 Nov 2016 17:02:08 +0800
changeset 324051 5d0c5c2ee7625c745269a8f9cccf00e562afcfba
parent 324050 e00b256c87a539e9f9ede45904b9043a9cc6b8f3
child 324052 65643222e76c6dfa3560d3d4165d603495ea25e7
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjya
bugs1319357
milestone53.0a1
Bug 1319357 - clean up media elements when media tests are done. r=jya MozReview-Commit-ID: GHJAwxR50AG
dom/media/mediasource/test/mediasource.js
dom/media/test/file_access_controls.html
dom/media/test/test_fragment_noplay.html
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -14,17 +14,20 @@ function runWithMSE(testFunction) {
     var ms = new MediaSource();
 
     var el = document.createElement("video");
     el.src = URL.createObjectURL(ms);
     el.preload = "auto";
 
     document.body.appendChild(el);
     SimpleTest.registerCleanupFunction(function () {
-      el.parentNode.removeChild(el);
+      el.remove();
+      // Don't trigger load algorithm to prevent 'error' events.
+      el.preload = "none";
+      el.src = null;
     });
 
     testFunction(ms, el);
   }
 
   addLoadEvent(function () {
     SpecialPowers.pushPrefEnv({"set": gMSETestPrefs}, bootstrapTest);
   });
--- a/dom/media/test/file_access_controls.html
+++ b/dom/media/test/file_access_controls.html
@@ -115,18 +115,21 @@ function nextTest() {
     } else {
       //dump("Exiting...\n");
       // We're done, exit the test.
       window.close();
       return;
     }
   }
 
-  if (gVideo && gVideo.parentNode)
-    gVideo.parentNode.removeChild(gVideo);
+  if (gVideo) {
+    gVideo.remove();
+    gVideo.preload = "none"; // Don't trigger load algorithm.
+    gVideo.src = null;
+  }
 
   gVideo = null;
   SpecialPowers.forceGC();  
   
   gVideo = createVideo();
   gVideo.expectedResult = gTests[gTestNum].result;
   gVideo.testDescription = gTests[gTestNum].description;
   // Uniquify the resource URL to ensure that the resources loaded by earlier or subsequent tests
--- a/dom/media/test/test_fragment_noplay.html
+++ b/dom/media/test/test_fragment_noplay.html
@@ -114,19 +114,17 @@ function startTest(test, token) {
   var name = test.name + " fragment test";
   var localIs = function(name) { return function(a, b, msg) {
     is(a, b, name + ": " + msg);
   }}(name);
   var localOk = function(name) { return function(a, msg) {
     ok(a, name + ": " + msg);
   }}(name);
   var localFinish = function(v, manager) { return function() {
-    if (v.parentNode) {
-      v.parentNode.removeChild(v);
-    }
+    removeNodeAndSource(v);
     manager.finished(v.token);
   }}(v, manager);
   window['test_fragment_noplay'](v, test.start, test.end, localIs, localOk, localFinish);
 }
 
 manager.runTests(createTestArray(), startTest);
 
 </script>