Bug 1081251 - register error handlers for all media elements in EME mochitests. r=cpearce a=lmandel
authorJW Wang <jwwang@mozilla.com>
Fri, 09 Jan 2015 01:46:00 +0100
changeset 250181 00ac75ab182f
parent 250180 7503ad43a7fd
child 250182 7bc573c193ea
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1081251
milestone37.0
Bug 1081251 - register error handlers for all media elements in EME mochitests. 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
@@ -197,16 +197,19 @@ function SetupEME(test, token, params)
     "loadedmetadata", "loadstart", "pause", "play", "playing", "progress",
     "stalled", "suspend", "waiting",
   ].forEach(function (e) {
     v.addEventListener(e, function(event) {
       Log(token, "" + e);
     }, false);
   });
 
+  // Finish the test when error is encountered.
+  v.onerror = bail(token + " got error event");
+
   var onSetKeysFail = (params && params.onSetKeysFail)
     ? params.onSetKeysFail
     : bail(token + " Failed to set MediaKeys on <video> element");
 
   v.addEventListener("encrypted", function(ev) {
     Log(token, "got encrypted event");
     var options = [
       {
--- a/dom/media/test/test_eme_canvas_blocked.html
+++ b/dom/media/test/test_eme_canvas_blocked.html
@@ -33,18 +33,16 @@ 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);
   });
 
-  v.addEventListener("error", bail(token + " got error event"));
-
   LoadTest(test, v, token);
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
--- a/dom/media/test/test_eme_persistent_sessions.html
+++ b/dom/media/test/test_eme_persistent_sessions.html
@@ -140,18 +140,16 @@ function startTest(test, token)
           manager.finished(token);
         });
 
       },
       sessionType: "persistent",
     }
   );
 
-  v.addEventListener("error", bail(token + " got error event"));
-
   LoadTest(test, v, token);
 }
 
 function beginTest() {
   manager.runTests(gEMETests, startTest);
 }
 
 var prefs = [
--- a/dom/media/test/test_eme_playback.html
+++ b/dom/media/test/test_eme_playback.html
@@ -82,18 +82,16 @@ function startTest(test, token)
       for (var kid in session.keyIdsReceived) {
         ok(session.keyIdsReceived[kid], TimeStamp(token) + " key with id " + kid + " was usable as expected");
       }
     }
 
     manager.finished(token);
    });
 
-  v.addEventListener("error", bail(token + " got error event"));
-
   LoadTest(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
@@ -23,28 +23,26 @@ function startTest(test, token)
   var case1token = token + "_case1";
   var setKeysFailed = function() {
     ok(true, TimeStamp(case1token) + " setMediaKeys failed as expected.");
     manager.finished(case1token);
   };
   var v1 = SetupEME(test, case1token,  { onSetKeysFail: setKeysFailed });
   var context = new AudioContext();
   var node = context.createMediaElementSource(v1);
-  v1.addEventListener("error", bail(case1token + " got error event"));
   v1.addEventListener("loadeddata", function(ev) {
     ok(false, TimeStamp(case1token) + " should never reach loadeddata, as setMediaKeys should fail");
   });
   manager.started(case1token);
   LoadTest(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("error", bail(case2token + " got error event"));
   v2.addEventListener("loadeddata", function(ev) {
     ok(true, case2token + " should reach loadeddata");
     var threw = false;
     try {
       var context = new AudioContext();
       var node = context.createMediaElementSource(v2);
     } catch (e) {
       threw = true;
@@ -54,17 +52,16 @@ function startTest(test, token)
   });
   manager.started(case2token);
   LoadTest(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("error", bail(case3token + " got error event"));
   v3.addEventListener("loadeddata", function(ev) {
     ok(true, TimeStamp(case3token) + " should reach loadeddata");
     var threw = false;
     try {
       var stream = v3.mozCaptureStreamUntilEnded();
     } catch (e) {
       threw = true;
     }