Bug 1131392 - Remove unused test code after disabling non-MSE EME - r=cpearce
authorEdwin Flores <eflores@mozilla.com>
Tue, 03 Mar 2015 11:02:36 +1300
changeset 231523 c7f1c4d0e60529ef9987f196ecac3236cff2b6c3
parent 231522 c3732d9a9abe57a1e544a309fecf7162d6640743
child 231524 ae1bfc4588519172cc151c07b23a3eee09cb7cb9
push id28353
push usercbook@mozilla.com
push dateTue, 03 Mar 2015 12:54:59 +0000
treeherdermozilla-central@985070813323 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1131392
milestone39.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 1131392 - Remove unused test code after disabling non-MSE EME - r=cpearce
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_playback.html
dom/media/test/test_eme_stream_capture_blocked.html
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -124,16 +124,21 @@ function MaybeCrossOriginURI(test, uri)
     return "http://test2.mochi.test:8888/tests/dom/media/test/allowed.sjs?" + uri;
   } else {
     return uri;
   }
 }
 
 function PlayFragmented(test, elem, token)
 {
+  if (!test.fragments) {
+    ok(false, token + " test does not have a fragments list");
+    return Promise.reject();
+  }
+
   return new Promise(function(resolve, reject) {
     var ms = new MediaSource();
     elem.src = URL.createObjectURL(ms);
 
     var sb;
     var curFragment = 0;
 
     function addNextFragment() {
@@ -176,32 +181,16 @@ function PlayFragmented(test, elem, toke
       sb = ms.addSourceBuffer(test.type);
       sb.addEventListener("updateend", addNextFragment);
 
       addNextFragment();
     })
   });
 }
 
-// Returns a promise that is resovled when the media element is ready to have
-// its play() function called; when it's loaded MSE fragments, or once the load
-// has started for non-MSE video.
-function LoadTest(test, elem, token)
-{
-  if (test.fragments) {
-    return PlayFragmented(test, elem, token);
-  }
-
-  // This file isn't fragmented; set the media source normally.
-  return new Promise(function(resolve, reject) {
-    elem.src = MaybeCrossOriginURI(test, test.name);
-    resolve();
-  });
-}
-
 function SetupEME(test, token, params)
 {
   var v = document.createElement("video");
   v.crossOrigin = test.crossOrigin || false;
 
   // Log events dispatched to make debugging easier...
   [ "canplay", "canplaythrough", "ended", "error", "loadeddata",
     "loadedmetadata", "loadstart", "pause", "play", "playing", "progress",
--- a/dom/media/test/test_eme_canvas_blocked.html
+++ b/dom/media/test/test_eme_canvas_blocked.html
@@ -33,17 +33,17 @@ 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);
   });
 
-  LoadTest(test, v, token);
+  PlayFragmented(test, v, token);
 }
 
 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
@@ -47,17 +47,17 @@ 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);
   });
 
-  LoadTest(test, v, token);
+  PlayFragmented(test, v, token);
 }
 
 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
@@ -142,17 +142,17 @@ function startTest(test, token)
           manager.finished(token);
         });
 
       },
       sessionType: "persistent",
     }
   );
 
-  LoadTest(test, v, token);
+  PlayFragmented(test, v, token);
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
   [ "media.mediasource.enabled", true ],
--- a/dom/media/test/test_eme_playback.html
+++ b/dom/media/test/test_eme_playback.html
@@ -81,19 +81,19 @@ function startTest(test, token)
       var session = sessions[i];
       ok(session.gotKeysChanged, TimeStamp(token) + " should have received at least one keychange event");
       for (var kid in session.keyIdsReceived) {
         ok(session.keyIdsReceived[kid], TimeStamp(token) + " key with id " + kid + " was usable as expected");
       }
     }
 
     manager.finished(token);
-   });
+  });
 
-  LoadTest(test, v, token)
+  PlayFragmented(test, v, token)
   .then(function() {
     v.play();
   }).catch(function() {
     ok(false, token + " failed to load");
     manager.finished(token);
   });
 }
 
--- a/dom/media/test/test_eme_stream_capture_blocked.html
+++ b/dom/media/test/test_eme_stream_capture_blocked.html
@@ -27,17 +27,17 @@ 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);
-  LoadTest(test, v1, case1token);
+  PlayFragmented(test, v1, case1token);
 
 
   // 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 +46,17 @@ 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);
-  LoadTest(test, v2, case2token);
+  PlayFragmented(test, v2, case2token);
 
 
   // 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 +64,17 @@ 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);
-  LoadTest(test, v3, case3token);
+  PlayFragmented(test, v3, case3token);
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
   [ "media.mediasource.enabled", true ],