|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test MediaRecorder Record with media.ogg.enabled = false</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
7 <script type="text/javascript" src="manifest.js"></script> |
|
8 </head> |
|
9 <body> |
|
10 <pre id="test"> |
|
11 <script class="testbody" type="text/javascript"> |
|
12 |
|
13 function startTest() { |
|
14 // the expect sequence should be |
|
15 // 1. onerror |
|
16 // 2. ondataavailable |
|
17 // 3. onstop |
|
18 var callbackStep = 0; |
|
19 var stream = new AudioContext().createMediaStreamDestination().stream; |
|
20 var mediaRecorder = new MediaRecorder(stream); |
|
21 |
|
22 mediaRecorder.onerror = function (e) { |
|
23 is(callbackStep, 0, 'should fired onstop callback'); |
|
24 is(e.name, 'GenericError', 'error name should be GenericError'); |
|
25 is(mediaRecorder.mimeType, '', 'mimetype should be empty'); |
|
26 is(mediaRecorder.state, 'recording', 'state is recording'); |
|
27 info('onerror callback fired'); |
|
28 callbackStep = 1; |
|
29 }; |
|
30 |
|
31 mediaRecorder.onwarning = function () { |
|
32 ok(false, 'Unexpected onwarning callback fired'); |
|
33 }; |
|
34 |
|
35 mediaRecorder.onstop = function () { |
|
36 info('onstop callback fired'); |
|
37 is(mediaRecorder.state, 'inactive', 'state should be inactive'); |
|
38 is(callbackStep, 2, 'should fired onstop callback'); |
|
39 SimpleTest.finish(); |
|
40 }; |
|
41 |
|
42 // This handler fires every 250ms to generate a blob. |
|
43 mediaRecorder.ondataavailable = function (evt) { |
|
44 info('ondataavailable callback fired'); |
|
45 is(callbackStep, 1, 'should fired ondataavailable callback'); |
|
46 is(evt.data.size, 0, 'data size should be zero'); |
|
47 ok(evt instanceof BlobEvent, |
|
48 'Events fired from ondataavailable should be BlobEvent'); |
|
49 is(evt.data.type, '', 'encoder start fail, blob miemType should be empty'); |
|
50 callbackStep = 2; |
|
51 }; |
|
52 |
|
53 // Start recording |
|
54 mediaRecorder.start(250); |
|
55 is(mediaRecorder.state, 'recording', 'Media recorder should be recording'); |
|
56 is(mediaRecorder.stream, stream, |
|
57 'Media recorder stream = element stream at the start of recording'); |
|
58 } |
|
59 |
|
60 SimpleTest.waitForExplicitFinish(); |
|
61 SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]}, startTest); |
|
62 |
|
63 </script> |
|
64 </pre> |
|
65 </body> |
|
66 </html> |