Bug 1383122 - P3. Don't set src attribute to null. r=jwwang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 21 Jul 2017 19:05:54 +0200
changeset 419423 43c119144a326381483a414b15c924c4cf632fa2
parent 419422 5a812783ca551343738bdfaddfa3d9f4a57c1450
child 419424 54a7da0c5524ecb7a2b3864833c0273eceae24a5
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1383122
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1383122 - P3. Don't set src attribute to null. r=jwwang Setting the src attribute to null was incorrect, per spec https://www.w3.org/TR/WebIDL-1/#es-DOMString, if null is passed, this is to be treated as ToString(null), which is "null" (https://tc39.github.io/ecma262/#sec-tostring). Hence setting src to null will cause a 404 error as it attempts to load "null". To unload the element, recommended practice is: Per spec: https://html.spec.whatwg.org/multipage/media.html#best-practices-for-authors-using-media-elements "by removing the element's src attribute and any source element descendants, and invoking the element's load() method." MozReview-Commit-ID: 5Lq13CeDCSZ
dom/media/mediasource/test/mediasource.js
dom/media/test/eme.js
dom/media/test/file_access_controls.html
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -17,19 +17,18 @@ function runWithMSE(testFunction) {
 
     var el = document.createElement("video");
     el.src = URL.createObjectURL(ms);
     el.preload = "auto";
 
     document.body.appendChild(el);
     SimpleTest.registerCleanupFunction(function () {
       el.remove();
-      // Don't trigger load algorithm to prevent 'error' events.
-      el.preload = "none";
-      el.src = null;
+      el.removeAttribute("src");
+      el.load();
     });
 
     testFunction(ms, el);
   }
 
   addLoadEvent(function () {
     SpecialPowers.pushPrefEnv({"set": gMSETestPrefs}, bootstrapTest);
   });
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -375,18 +375,18 @@ function ProcessInitData(v, test, token,
 }
 
 /*
  * Clean up the |v| element.
  */
 function CleanUpMedia(v) {
   v.setMediaKeys(null);
   v.remove();
-  v.onerror = null;
-  v.src = null;
+  v.removeAttribute("src");
+  v.load();
 }
 
 /*
  * Close all sessions and clean up the |v| element.
  */
 function CloseSessions(v, sessions) {
   return Promise.all(sessions.map(s => s.close()))
   .then(CleanUpMedia(v));
--- a/dom/media/test/file_access_controls.html
+++ b/dom/media/test/file_access_controls.html
@@ -117,36 +117,36 @@ function nextTest() {
       // We're done, exit the test.
       window.close();
       return;
     }
   }
 
   if (gVideo) {
     gVideo.remove();
-    gVideo.preload = "none"; // Don't trigger load algorithm.
-    gVideo.src = null;
+    gVideo.removeAttribute("src");
+    gVideo.load();
   }
 
   gVideo = null;
-  SpecialPowers.forceGC();  
-  
+  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
   // don't overlap with the resources we load here, which are loaded with non-default preferences set.
   // We also want to make sure that an HTTP fetch actually happens for each testcase.
   var url = gTests[gTestNum].url;
   var random = Math.floor(Math.random()*1000000000);
   url += (url.search(/\?/) < 0 ? "?" : "&") + "rand=" + random;
   gVideo.src = url;
   //dump("Starting test " + gTestNum + " at " + gVideo.src + " expecting:" + gVideo.expectedResult + "\n");
   if (!gTestedRemoved) {
-    document.body.appendChild(gVideo); 
+    document.body.appendChild(gVideo);
     // Will cause load() to be invoked.
   } else {
     gVideo.load();
   }
   gTestNum++;
 }
 
 function done() {