Bug 1275856- Update tests to reflect new MediaRecorderErrorEvent. r=jib

MediaRecorderErrorEvent is now fired in response to async errors in the
MediaRecorder. This event wraps a DOMException and tests need to be updated to
reflect this new behaviour.

MozReview-Commit-ID: JIjIZlJJ8PE

--HG--
extra : rebase_source : b8adde26f5321b5b8a3c8e193c5744d6f3403cf5
This commit is contained in:
Bryce Van Dyk 2017-07-28 09:04:11 +12:00
Родитель 751da7c177
Коммит 7914380985
4 изменённых файлов: 14 добавлений и 12 удалений

Просмотреть файл

@ -21,7 +21,7 @@ function startTest() {
mediaRecorder.onerror = function (e) {
is(callbackStep, 0, 'should fired onstop callback');
is(e.name, 'GenericError', 'error name should be GenericError');
is(e.error.name, 'UnknownError', 'error name should be UnknownError');
is(mediaRecorder.mimeType, '', 'mimetype should be empty');
is(mediaRecorder.state, 'recording', 'state is recording');
info('onerror callback fired');

Просмотреть файл

@ -30,7 +30,7 @@ SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]},
//fires again, so set it to null to avoid failures
mediaRecorder.ondataavailable = null;
SimpleTest.finish();
}
};
mediaRecorder.ondataavailable = function(evt) {
ondataavailableFired = true;
ok(evt instanceof BlobEvent,
@ -43,16 +43,18 @@ SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]},
'Blob data received should have type = ' + expectedMimeType);
is(evt.target.mimeType, expectedMimeType,
'Mime type in ondataavailable = ' + expectedMimeType);
}
};
mediaRecorder.onerror = function(evt) {
ok(evt instanceof RecordErrorEvent,
'Events fired from onerror should be RecordErrorEvent');
ok(evt instanceof MediaRecorderErrorEvent,
'Events fired from onerror should be MediaRecorderErrorEvent');
is(evt.type, 'error',
'Event type should onerror');
is(evt.name, 'GenericError',
'Event name is GenericError');
'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');
onErrorFired = true;
}
};
mediaRecorder.start(0);
is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
is(mediaRecorder.stream, stream,

Просмотреть файл

@ -89,9 +89,9 @@ function testPrincipals(resource) {
hasStopped = new Promise(resolve => rec.onstop = resolve);
video.play();
})
.then(() => ok(true, msgNoThrow), e => is(e.name, null, msgNoThrow))
.then(() => ok(true, msgNoThrow), e => is(e.error.name, null, msgNoThrow))
.then(() => Promise.race([
new Promise((_, reject) => rec.onerror = e => reject(new DOMException("", e.name))),
new Promise((_, reject) => rec.onerror = e => reject(e.error)),
hasEnded
]))
.then(() => ok(false, msgSecErr), e => is(e.name, "SecurityError", msgSecErr))

Просмотреть файл

@ -42,7 +42,7 @@ function startTest() {
}
}
ok(callbackStep < 3, 'onerror callback fired as expected.');
is(e.name, 'GenericError', 'Error name should be GenericError.');
is(e.error.name, 'UnknownError', 'Error name should be UnknownError.');
is(mediaRecorder.mimeType, '', 'mimetype should be empty');
is(mediaRecorder.state, 'recording', 'state is recording');
info('onerror callback fired');