Bug 1319357 - clean up media elements when media tests are done. r?jya draft
authorJW Wang <jwwang@mozilla.com>
Tue, 22 Nov 2016 17:02:08 +0800
changeset 442303 e4c5e1009c2a3ebdb25ab43d594504ca7517f0b7
parent 442298 5b5f846f00879e1b13ccce436bf7507baad665ee
child 537771 74da3d1e2683e0fe712061aea8d2fc2ec1876702
push id36672
push userjwwang@mozilla.com
push dateTue, 22 Nov 2016 09:27:15 +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>