Backed out 2 changesets (bug 1371166) for Windows 8 permafails in test_mediarecorder_principals.html a=backout
authorWes Kocher <wkocher@mozilla.com>
Mon, 24 Jul 2017 14:50:47 -0700
changeset 419227 bf4634a50775537b4e791b6d294a275b83737472
parent 419226 462d7561089c98e33382384896434861ad7bc491
child 419228 899590a34d56e099d4e064a9e4d41a54993790e9
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)
reviewersbackout
bugs1371166
milestone56.0a1
backs out955998eefbe8462e3fa9964962eb8ee6b05200dd
736042ec645d1c4c64af0528365768e40ee24e56
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
Backed out 2 changesets (bug 1371166) for Windows 8 permafails in test_mediarecorder_principals.html a=backout Backed out changeset 955998eefbe8 (bug 1371166) Backed out changeset 736042ec645d (bug 1371166) MozReview-Commit-ID: 11duLALJ9PW
dom/media/test/test_mediarecorder_principals.html
--- a/dom/media/test/test_mediarecorder_principals.html
+++ b/dom/media/test/test_mediarecorder_principals.html
@@ -10,80 +10,84 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="text/javascript" src="manifest.js"></script>
 </head>
 <body>
 <div>
   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1018299">Test for MediaRecorder Principal Handling</a>
 </div>
 
-<video id="v1" preload="metadata"></video>
-<video id="v2" preload="metadata"></video>
+<video id="v1" preload="auto"></video>
+<video id="v2" preload="auto"></video>
 
 <pre id="test">
 <script type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
-let throwOutside = e => setTimeout(() => { throw e; });
+var pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
+var throwOutside = e => setTimeout(() => { throw e; });
 
 // Generate a random key. The first load with that key will return
 // data, the second and subsequent loads with that key will return a redirect
 // to a different origin ('localhost:8888' will be redirected to 'example.org',
-// and 'example.org' will be redirected to 'localhost:8888').
+// and 'example.org' will be redirected to 'localhost:8888'). We rely on the
+// fact that Ogg will do a seek to the end of the resource, triggering a new
+// load with the same key which will return a same-origin resource.
 // Loading data from two different origins should be detected by the media
 // cache and result in a null principal so that the MediaRecorder usages below
 // fail.
-// This test relies on that preloading the metadata then loading a sufficiently
-// long video will result in two separate requests to load the resource. This
-// ends up relying on the impl of MediaCache and friends and we should probably
-// replace this test with a more robust gtest or the like.
 let key = Math.floor(Math.random()*100000000);
 let interval;
 
 function testPrincipals(resource) {
   if (!resource) {
     todo(false, "No types supported");
     return;
   }
-  // First test: Load file from same-origin first, then get redirected to
-  // another origin before attempting to record stream.
-  let video = document.getElementById("v1");
-  video.src =
-      "http://mochi.test:8888/tests/dom/media/test/dynamic_redirect.sjs?key=v1_" +
-      key + "&res=" + resource.name;
-  video.load();
-  // To limit readahead, avoid racing with playback and "catching up" mode.
-  return new Promise(resolve => video.onloadeddata = resolve).then(() => {
-    video.play();
-    interval = setInterval(() => info("video.currentTime = "+ video.currentTime), 1000);
+  // Reduce cache size and cache-ahead to make HTMLMediaElement do partial requests.
+  return pushPrefs(['media.cache_readahead_limit', 2],
+                   ['media.cache_size', 192])
+  .then(() => {
+    // First test: Load file from same-origin first, then get redirected to
+    // another origin before attempting to record stream.
+    let video = document.getElementById("v1");
+    video.src =
+        "http://mochi.test:8888/tests/dom/media/test/dynamic_redirect.sjs?key=v1_" +
+        key + "&res=" + resource.name;
+    video.load();
+    // To limit readahead, avoid racing with playback and "catching up" mode.
+    return new Promise(resolve => video.oncanplaythrough = resolve).then(() => {
+      video.play();
+      interval = setInterval(() => info("video.currentTime = "+ video.currentTime), 1000);
 
-    let msg = "mediaRecorder.start() must throw SecurityError";
-    return new Promise(resolve => video.onplaying = resolve)
-    .then(() => waitUntil(() => video.currentTime > resource.duration / 5))
-    // Test failure of the next step only, so "catch-bypass" any errors above.
-    .then(() => Promise.resolve()
-      .then(() => new MediaRecorder(video.mozCaptureStreamUntilEnded()).start())
-      .then(() => ok(false, msg), e => is(e.name, "SecurityError", msg)), 0)
-    .then(() => clearInterval(interval));
+      let msg = "mediaRecorder.start() must throw SecurityError";
+      return new Promise(resolve => video.onplaying = resolve)
+      .then(() => waitUntil(() => video.currentTime > resource.duration / 2))
+      // Test failure of the next step only, so "catch-bypass" any errors above.
+      .then(() => Promise.resolve()
+        .then(() => new MediaRecorder(video.mozCaptureStreamUntilEnded()).start())
+        .then(() => ok(false, msg), e => is(e.name, "SecurityError", msg)), 0)
+      .then(() => clearInterval(interval));
+    });
   })
   .then(() => {
     // Second test: Load file from same-origin first, but record ASAP, before
     // getting redirected to another origin.
     let video = document.getElementById("v2");
     video.src =
         "http://mochi.test:8888/tests/dom/media/test/dynamic_redirect.sjs?key=v2_" +
         key + "&res=" + resource.name;
     video.load();
     let rec, hasStopped, hasEnded = new Promise(r => video.onended = r);
     let data = [];
 
     let msgNoThrow = "mediaRecorder.start() should not throw here";
     let msgSecErr = "mediaRecorder.onerror must fire SecurityError";
     let msgOnStop = "mediaRecorder.onstop must also have fired";
-    return new Promise(resolve => video.onloadeddata = resolve).then(() => {
+    return new Promise(resolve => video.onloadedmetadata = resolve).then(() => {
       rec = new MediaRecorder(video.mozCaptureStreamUntilEnded());
       rec.ondataavailable = e => data.push(e.data);
       rec.start();
       hasStopped = new Promise(resolve => rec.onstop = resolve);
       video.play();
     })
     .then(() => ok(true, msgNoThrow), e => is(e.name, null, msgNoThrow))
     .then(() => Promise.race([
@@ -92,24 +96,24 @@ function testPrincipals(resource) {
     ]))
     .then(() => ok(false, msgSecErr), e => is(e.name, "SecurityError", msgSecErr))
     .then(() => Promise.race([hasStopped, hasEnded.then(() => Promise.reject())]))
     .then(() => ok(true, msgOnStop), e => ok(false, msgOnStop))
     .then(() => clearInterval(interval));
   });
 }
 
-testPrincipals({ name:"pixel_aspect_ratio.mp4", type:"video/mp4", duration:28 })
+testPrincipals(getPlayableVideo(gSeekTests))
 .catch(e => throwOutside(e))
 .then(() => SimpleTest.finish())
 .catch(e => throwOutside(e));
 
-let stop = stream => stream.getTracks().forEach(track => track.stop());
-let wait = ms => new Promise(resolve => setTimeout(resolve, ms));
-let waitUntil = f => new Promise(resolve => {
-  let ival = setInterval(() => f() && resolve(clearInterval(ival)), 100);
+var stop = stream => stream.getTracks().forEach(track => track.stop());
+var wait = ms => new Promise(resolve => setTimeout(resolve, ms));
+var waitUntil = f => new Promise(resolve => {
+  var ival = setInterval(() => f() && resolve(clearInterval(ival)), 100);
 });
 
 </script>
 </pre>
 
 </body>
 </html>