Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-error.html

Issue 2697703003: MediaRecorder: make sure ondataavailable+onstop events are fired before onerror (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script>
4 <body>
5 <!-- canvas cannot be arbitrarily small -->
6 <canvas id='canvas'/>
7 </body>
8 <script>
9
10 var test = async_test('forces an error in the MediaRecorder API by changing ' +
11 'the amount of tracks in the MediaStream, and checks that the correct ' +
12 'sequence ondataavailable-stop-error is enforced');
13 var recorder;
14 var stream;
15
16 function drawSomethingOnCanvas(canvas) {
17 // Drawing something on the canvas generates a frame in its captured stream.
18 var context = canvas.getContext("2d");
19 context.fillStyle = "red";
20 context.fillRect(0, 0, 10, 10);
21 }
22
23 recorderOnDataAvailable = test.step_func(function(event) {
24 recorder.onstop = recorderOnStop;
25
26 // Add another track to the MediaStream to force an error.
27 stream.addTrack(stream.getVideoTracks()[0].clone());
28 drawSomethingOnCanvas(document.getElementById('canvas'));
29 });
30
31 recorderOnStop = test.step_func(function() {
32 recorder.onstop = test.unreached_func('Unexpected stop event');
33 recorder.ondataavailable = test.unreached_func('Unexpected data event');
34 recorder.onerror = recorderOnError;
35 });
36
37 recorderOnError = test.step_func(function() {
38 test.done();
39 });
40
41 var step = test.step_func(function() {
42 var canvas = document.getElementById('canvas');
43 stream = canvas.captureStream();
44 assert_equals(stream.getVideoTracks()[0].readyState, 'live');
45
46 drawSomethingOnCanvas(canvas);
emircan 2017/02/17 00:19:07 Move this after l.56. Also, AFAIU first frame is
mcasas 2017/02/17 01:46:14 Done.
47
48 recorder = new MediaRecorder(stream);
49
50 recorder.onstop = test.unreached_func('Unexpected stop event');
51 recorder.onpause = test.unreached_func('Unexpected pause event');
52 recorder.onresume = test.unreached_func('Unexpected resume event');
53 recorder.onerror = test.unreached_func('Unexpected error event');
54 recorder.ondataavailable = recorderOnDataAvailable;
55
56 recorder.start(0);
57 });
58
59 step();
60
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698