Bug 1152151 - [EME] Some tests keep working after they should have finished, part 2: Only load that each test actually needs - r=edwin
authorGerald Squelart <from_mozilla@squelart.com>
Wed, 15 Apr 2015 10:09:25 +1000
changeset 269055 03406fe40cc97158aa270360c684a8b9c720d0ad
parent 269054 c55cbfbc2a24a932f7a666977ad632b6ff24f405
child 269056 b35bfa6c9c0e05f3a30eb5ce398ae09671f11928
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1152151
milestone40.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 1152151 - [EME] Some tests keep working after they should have finished, part 2: Only load that each test actually needs - r=edwin
dom/media/test/eme.js
dom/media/test/test_eme_canvas_blocked.html
dom/media/test/test_eme_obs_notification.html
dom/media/test/test_eme_persistent_sessions.html
dom/media/test/test_eme_stream_capture_blocked.html
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -139,33 +139,38 @@ function MaybeCrossOriginURI(test, uri)
 {
   if (test.crossOrigin) {
     return "http://test2.mochi.test:8888/tests/dom/media/test/allowed.sjs?" + uri;
   } else {
     return uri;
   }
 }
 
-function AppendTrack(test, ms, track, token)
+function AppendTrack(test, ms, track, token, loadParams)
 {
   return new Promise(function(resolve, reject) {
     var sb;
     var curFragment = 0;
     var resolved = false;
+    var fragments = track.fragments;
     var fragmentFile;
 
+    if (loadParams && loadParams.onlyLoadFirstFragments) {
+      fragments = fragments.slice(0, loadParams.onlyLoadFirstFragments);
+    }
+
     function addNextFragment() {
-      if (curFragment >= track.fragments.length) {
+      if (curFragment >= fragments.length) {
         Log(token, track.name + ": end of track");
         resolve();
         resolved = true;
         return;
       }
 
-      fragmentFile = MaybeCrossOriginURI(test, track.fragments[curFragment++]);
+      fragmentFile = MaybeCrossOriginURI(test, fragments[curFragment++]);
 
       var req = new XMLHttpRequest();
       req.open("GET", fragmentFile);
       req.responseType = "arraybuffer";
 
       req.addEventListener("load", function() {
         Log(token, track.name + ": fetch of " + fragmentFile + " complete, appending");
         sb.appendBuffer(new Uint8Array(req.response));
@@ -201,17 +206,17 @@ function AppendTrack(test, ms, track, to
     });
 
     addNextFragment();
   });
 }
 
 //Returns a promise that is resolved when the media element is ready to have
 //its play() function called; when it's loaded MSE fragments.
-function LoadTest(test, elem, token)
+function LoadTest(test, elem, token, loadParams)
 {
   if (!test.tracks) {
     ok(false, token + " test does not have a tracks list");
     return Promise.reject();
   }
 
   var ms = new MediaSource();
   elem.src = URL.createObjectURL(ms);
@@ -222,20 +227,24 @@ function LoadTest(test, elem, token)
       if (!firstOpen) {
         Log(token, "sourceopen again?");
         return;
       }
 
       firstOpen = false;
       Log(token, "sourceopen");
       return Promise.all(test.tracks.map(function(track) {
-        return AppendTrack(test, ms, track, token);
+        return AppendTrack(test, ms, track, token, loadParams);
       })).then(function(){
-        Log(token, "end of stream");
-        ms.endOfStream();
+        if (loadParams && loadParams.noEndOfStream) {
+          Log(token, "Tracks loaded");
+        } else {
+          Log(token, "Tracks loaded, calling MediaSource.endOfStream()");
+          ms.endOfStream();
+        }
         resolve();
       });
     })
   });
 }
 
 // Same as LoadTest, but manage a token+"_load" start&finished.
 // Also finish main token if loading fails.
--- a/dom/media/test/test_eme_canvas_blocked.html
+++ b/dom/media/test/test_eme_canvas_blocked.html
@@ -33,17 +33,18 @@ function startTest(test, token)
       ctx.drawImage(video, 0, 0);
     } catch (ex) {
       threwError = true;
     }
     ok(threwError, TimeStamp(token) + " - Should throw an error when trying to draw EME video to canvas.");
     manager.finished(token);
   });
 
-  LoadTestWithManagedLoadToken(test, v, manager, token);
+  LoadTestWithManagedLoadToken(test, v, manager, token,
+                               { onlyLoadFirstFragments:2, noEndOfStream:true });
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
   [ "media.mediasource.enabled", true ],
--- a/dom/media/test/test_eme_obs_notification.html
+++ b/dom/media/test/test_eme_obs_notification.html
@@ -46,17 +46,18 @@ function startTest(test, token)
   v.preload = "auto"; // Required due to "canplay" not firing for MSE unless we do this.
 
   v.addEventListener("loadeddata", function(ev) {
     ok(observedVideos.has(ev.target), "Should have been told about eme video through observer as well.");
     observedVideos.delete(ev.target);
     manager.finished(token);
   });
 
-  LoadTestWithManagedLoadToken(test, v, manager, token);
+  LoadTestWithManagedLoadToken(test, v, manager, token,
+                               { onlyLoadFirstFragments:2, noEndOfStream:true });
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
   [ "media.mediasource.enabled", true ],
--- a/dom/media/test/test_eme_persistent_sessions.html
+++ b/dom/media/test/test_eme_persistent_sessions.html
@@ -141,17 +141,18 @@ function startTest(test, token)
           manager.finished(token);
         });
 
       },
       sessionType: "persistent",
     }
   );
 
-  LoadTestWithManagedLoadToken(test, v, manager, token);
+  LoadTestWithManagedLoadToken(test, v, manager, token,
+                               { onlyLoadFirstFragments:2, noEndOfStream:true });
 }
 
 function beginTest() {
   manager.runTests(gEMETests.filter(t => t.sessionCount === 1), startTest);
 }
 
 var prefs = [
   [ "media.mediasource.enabled", true ],
--- a/dom/media/test/test_eme_stream_capture_blocked.html
+++ b/dom/media/test/test_eme_stream_capture_blocked.html
@@ -27,17 +27,18 @@ function startTest(test, token)
   };
   var v1 = SetupEME(test, case1token,  { onSetKeysFail: setKeysFailed });
   var context = new AudioContext();
   var node = context.createMediaElementSource(v1);
   v1.addEventListener("loadeddata", function(ev) {
     ok(false, TimeStamp(case1token) + " should never reach loadeddata, as setMediaKeys should fail");
   });
   manager.started(case1token);
-  LoadTestWithManagedLoadToken(test, v1, manager, case1token);
+  LoadTestWithManagedLoadToken(test, v1, manager, case1token,
+                               { onlyLoadFirstFragments:2, noEndOfStream:true });
 
 
   // Case 2. creating a MediaElementSource on a media element with a MediaKeys should fail.
   var case2token = token + "_case2";
   var v2 = SetupEME(test, case2token);
   v2.addEventListener("loadeddata", function(ev) {
     ok(true, case2token + " should reach loadeddata");
     var threw = false;
@@ -46,17 +47,18 @@ function startTest(test, token)
       var node = context.createMediaElementSource(v2);
     } catch (e) {
       threw = true;
     }
     ok(threw, "Should throw an error creating a MediaElementSource on an EME video.");
     manager.finished(case2token);
   });
   manager.started(case2token);
-  LoadTestWithManagedLoadToken(test, v2, manager, case2token);
+  LoadTestWithManagedLoadToken(test, v2, manager, case2token,
+                               { onlyLoadFirstFragments:2, noEndOfStream:true });
 
 
   // Case 3. capturing a media element with mozCaptureStream that has a MediaKeys should fail.
   var case3token = token + "_case3";
   var v3 = SetupEME(test, case3token);
   v3.addEventListener("loadeddata", function(ev) {
     ok(true, TimeStamp(case3token) + " should reach loadeddata");
     var threw = false;
@@ -64,17 +66,18 @@ function startTest(test, token)
       var stream = v3.mozCaptureStreamUntilEnded();
     } catch (e) {
       threw = true;
     }
     ok(threw, TimeStamp(case3token) + " Should throw an error calling mozCaptureStreamUntilEnded an EME video.");
     manager.finished(case3token);
   });
   manager.started(case3token);
-  LoadTestWithManagedLoadToken(test, v3, manager, case3token);
+  LoadTestWithManagedLoadToken(test, v3, manager, case3token,
+                               { onlyLoadFirstFragments:2, noEndOfStream:true });
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
   [ "media.mediasource.enabled", true ],