Bug 1131392 - Remove unused test code after disabling non-MSE EME - r=cpearce a=lmandel
authorEdwin Flores <eflores@mozilla.com>
Tue, 03 Mar 2015 11:02:36 +1300
changeset 250279 dd9bfd410f7e
parent 250278 a8aa24cf19a5
child 250280 1a9d0193519a
push id4535
push usercpearce@mozilla.com
push date2015-03-06 20:57 +0000
treeherdermozilla-beta@68707623b5a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1131392
milestone37.0
Bug 1131392 - Remove unused test code after disabling non-MSE EME - r=cpearce a=lmandel
dom/media/test/eme.js
dom/media/test/test_eme_canvas_blocked.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_persistent_sessions.html
+++ b/dom/media/test/test_eme_persistent_sessions.html
@@ -143,17 +143,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 ],