Bug 1275856 - Expand MediaRecorder tests to check stack traces when MediaRecorderErrorEvent is fired. r=jib
authorBryce Van Dyk <bvandyk@mozilla.com>
Wed, 09 Aug 2017 19:55:54 +1200
changeset 647079 c735325c95be798ade798ee0b0a8804902f42847
parent 647078 2d3c818bf51db0fd21bac31f09affc3272ce8ebf
child 647080 0153cadbabe3049bf575e2d610519d93260cd503
push id74288
push userhikezoe@mozilla.com
push dateWed, 16 Aug 2017 00:19:57 +0000
reviewersjib
bugs1275856
milestone57.0a1
Bug 1275856 - Expand MediaRecorder tests to check stack traces when MediaRecorderErrorEvent is fired. r=jib MozReview-Commit-ID: 6NnaHt24ecz
dom/media/test/test_mediarecorder_creation_fail.html
dom/media/test/test_mediarecorder_getencodeddata.html
dom/media/test/test_mediarecorder_principals.html
dom/media/test/test_mediarecorder_unsupported_src.html
--- a/dom/media/test/test_mediarecorder_creation_fail.html
+++ b/dom/media/test/test_mediarecorder_creation_fail.html
@@ -17,16 +17,19 @@ function startTest() {
   // 3. onstop
   var callbackStep = 0;
   var stream = new AudioContext().createMediaStreamDestination().stream;
   var mediaRecorder = new MediaRecorder(stream);
 
   mediaRecorder.onerror = function (e) {
     is(callbackStep, 0, 'should fired onstop callback');
     is(e.error.name, 'UnknownError', 'error name should be UnknownError');
+    ok(e.error.stack.includes('test_mediarecorder_creation_fail.html'),
+      'Events fired from onerror should include an error with a stack trace indicating ' +
+      'an error in this test');
     is(mediaRecorder.mimeType, '', 'mimetype should be empty');
     is(mediaRecorder.state, 'recording', 'state is recording');
     info('onerror callback fired');
     callbackStep = 1;
   };
 
   mediaRecorder.onwarning = function () {
     ok(false, 'Unexpected onwarning callback fired');
--- a/dom/media/test/test_mediarecorder_getencodeddata.html
+++ b/dom/media/test/test_mediarecorder_getencodeddata.html
@@ -48,16 +48,19 @@ SpecialPowers.pushPrefEnv({"set": [["med
         ok(evt instanceof MediaRecorderErrorEvent,
           'Events fired from onerror should be MediaRecorderErrorEvent');
         is(evt.type, 'error',
            'Event type is error');
         ok(evt.error instanceof DOMException,
           'Events fired from onerror should have a DOMException in their error member');
         is(evt.error.name, 'UnknownError', 'Error name should be UnknownError.');
         is(evt.error.message, 'The operation failed for an unknown transient reason');
+        ok(evt.error.stack.includes('test_mediarecorder_getencodeddata.html'),
+          'Events fired from onerror should include an error with a stack trace indicating ' +
+          'an error in this test');
         onErrorFired = true;
       };
       mediaRecorder.start(0);
       is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
       is(mediaRecorder.stream, stream,
          'Media recorder stream = element stream at the start of recording');
       mediaRecorder.requestData();
     }, 100);
--- a/dom/media/test/test_mediarecorder_principals.html
+++ b/dom/media/test/test_mediarecorder_principals.html
@@ -89,17 +89,22 @@ function testPrincipals(resource) {
       hasStopped = new Promise(resolve => rec.onstop = resolve);
       video.play();
     })
     .then(() => ok(true, msgNoThrow), e => is(e.error.name, null, msgNoThrow))
     .then(() => Promise.race([
       new Promise((_, reject) => rec.onerror = e => reject(e.error)),
       hasEnded
     ]))
-    .then(() => ok(false, msgSecErr), e => is(e.name, "SecurityError", msgSecErr))
+    .then(() => ok(false, msgSecErr), e => {
+      is(e.name, "SecurityError", msgSecErr);
+      ok(e.stack.includes('test_mediarecorder_principals.html'),
+      'Events fired from onerror should include an error with a stack trace indicating ' +
+      'an error in this test');
+    })
     .then(() => Promise.race([hasStopped, hasEnded.then(() => Promise.reject())]))
     .then(() => ok(true, msgOnStop), e => ok(false, msgOnStop))
     .then(() => clearInterval(interval));
   });
 }
 
 testPrincipals(getPlayableVideo(gSeekTests))
 .catch(e => throwOutside(e))
--- a/dom/media/test/test_mediarecorder_unsupported_src.html
+++ b/dom/media/test/test_mediarecorder_unsupported_src.html
@@ -38,16 +38,19 @@ function startTest() {
           try {
             mediaRecorder.pause();
           } catch(e) {
             ok(false, 'Should not get exception in pause call.');
           }
         }
         ok(callbackStep < 3, 'onerror callback fired as expected.');
         is(e.error.name, 'UnknownError', 'Error name should be UnknownError.');
+        ok(e.error.stack.includes('test_mediarecorder_unsupported_src.html'),
+          'Events fired from onerror should include an error with a stack trace indicating ' +
+          'an error in this test');
         is(mediaRecorder.mimeType, '', 'mimetype should be empty');
         is(mediaRecorder.state, 'recording', 'state is recording');
         info('onerror callback fired');
       }
 
       mediaRecorder.onwarning = function () {
         ok(false, 'Unexpected onwarning callback fired.');
       };