Bug 1395022 - Add test to check only one start event is fired by MediaRecorder when erroring. r=pehrsons

MozReview-Commit-ID: 1JJY0eQMSDn

--HG--
extra : rebase_source : f97bc71009022279b7e6b5b497c1dbf6fc5931b5
This commit is contained in:
Bryce Van Dyk 2017-09-04 10:10:32 +12:00
Родитель 885710fcc9
Коммит 2dd8bf74ac
2 изменённых файлов: 48 добавлений и 0 удалений

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

@ -825,6 +825,9 @@ tags=msg capturestream
[test_mediarecorder_creation_fail.html]
skip-if = android_version == '17' # android(bug 1232305)
tags=msg
[test_mediarecorder_fires_start_event_once_when_erroring.html]
skip-if = android_version == '17' # android(bug 1232305)
tags=msg
[test_mediarecorder_getencodeddata.html]
skip-if = android_version == '17' # android(bug 1232305)
tags=msg

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

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1395022 - MediaRecorder fires start event when erroring.</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1395022">Mozilla Bug 1395022</a>
<pre id="test">
<script class="testbody" type="text/javascript">
function startTest() {
let audioContext = new AudioContext();
let destination1 = audioContext.createMediaStreamDestination();
let oscilator = audioContext.createOscillator();
oscilator.connect(destination1);
oscilator.start();
let destination2 = audioContext.createMediaStreamDestination();
let rec = new MediaRecorder(destination1.stream);
let numStartEvents = 0;
rec.onstart = () => {
numStartEvents += 1;
is(numStartEvents, 1, "One start event should be fired by the recorder");
// Trigger an error in the recorder
destination1.stream.addTrack(destination2.stream.getTracks()[0]);
};
rec.onerror = () => {
is(numStartEvents, 1, "One start event should have been fired by the recorder");
SimpleTest.finish();
};
rec.start();
}
SimpleTest.waitForExplicitFinish();
startTest();
</script>
</head>
</html>