mirror of
https://github.com/servo/servo.git
synced 2025-08-20 12:55:33 +01:00
Update web-platform-tests to revision 0f31ab1b094596062154092307bb9ff8e6122533
This commit is contained in:
parent
96ad6710b1
commit
372e03fe64
32 changed files with 992 additions and 222 deletions
|
@ -0,0 +1,66 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>MediaRecorder Pause and Resume</title>
|
||||
<link rel="help" href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#mediarecorder">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
</canvas>
|
||||
<script>
|
||||
function createVideoStream() {
|
||||
let canvas = document.getElementById("canvas");
|
||||
canvas.getContext('2d');
|
||||
return canvas.captureStream();
|
||||
}
|
||||
|
||||
function recordEvents(target, events) {
|
||||
let arr = [];
|
||||
for (let ev of events) {
|
||||
target.addEventListener(ev, _ => arr.push(ev));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
promise_test(async () => {
|
||||
let video = createVideoStream();
|
||||
let recorder = new MediaRecorder(video);
|
||||
let events = recordEvents(recorder,
|
||||
["start", "stop", "dataavailable", "pause", "resume", "error"]);
|
||||
|
||||
recorder.start();
|
||||
assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
|
||||
|
||||
recorder.pause();
|
||||
assert_equals(recorder.state, "paused", "MediaRecorder should be paused immediately following pause()");
|
||||
|
||||
// A second call to pause should be idempotent
|
||||
recorder.pause();
|
||||
assert_equals(recorder.state, "paused", "MediaRecorder should be paused immediately following pause()");
|
||||
|
||||
let event = await new Promise(r => recorder.onpause = r);
|
||||
assert_equals(event.type, "pause", "the event type should be pause");
|
||||
assert_true(event.isTrusted, "isTrusted should be true when the event is created by C++");
|
||||
|
||||
recorder.resume();
|
||||
assert_equals(recorder.state, "recording", "MediaRecorder state should be recording immediately following resume() call");
|
||||
|
||||
// A second call to resume should be idempotent
|
||||
recorder.resume();
|
||||
assert_equals(recorder.state, "recording", "MediaRecorder state should be recording immediately following resume() call");
|
||||
|
||||
event = await new Promise(r => recorder.onresume = r);
|
||||
assert_equals(event.type, "resume", "the event type should be resume");
|
||||
assert_true(event.isTrusted, "isTrusted should be true when the event is created by C++");
|
||||
|
||||
recorder.stop();
|
||||
await new Promise(r => recorder.onstop = r);
|
||||
|
||||
assert_array_equals(events, ["start", "pause", "resume", "dataavailable", "stop"],
|
||||
"Should have gotten expected events");
|
||||
}, "MediaRecorder handles pause() and resume() calls appropriately in state and events");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -16,35 +16,68 @@
|
|||
return canvas.captureStream();
|
||||
}
|
||||
|
||||
async_test(t => {
|
||||
function recordEvents(target, events) {
|
||||
let arr = [];
|
||||
for (let ev of events) {
|
||||
target.addEventListener(ev, _ => arr.push(ev));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
promise_test(async t => {
|
||||
let video = createVideoStream();
|
||||
let recorder = new MediaRecorder(video);
|
||||
recorder.onstop = t.step_func(errorEvent => {
|
||||
assert_equals(errorEvent.type, 'stop', 'the error type should be stop');
|
||||
assert_true(errorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
|
||||
assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped when all tracks are ended");
|
||||
t.done();
|
||||
});
|
||||
let events = recordEvents(recorder,
|
||||
["start", "stop", "dataavailable", "pause", "resume", "error"]);
|
||||
assert_equals(video.getVideoTracks().length, 1, "video mediastream starts with one track");
|
||||
recorder.start();
|
||||
assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
|
||||
|
||||
video.getVideoTracks()[0].stop();
|
||||
assert_equals(recorder.state, "recording", "MediaRecorder state should be recording immediately following last track ending");
|
||||
let event = await new Promise(r => recorder.onstop = r);
|
||||
|
||||
assert_equals(event.type, "stop", "the event type should be stop");
|
||||
assert_true(event.isTrusted, "isTrusted should be true when the event is created by C++");
|
||||
assert_equals(recorder.state, "inactive", "MediaRecorder is inactive after stop event");
|
||||
|
||||
assert_array_equals(events, ["start", "dataavailable", "stop"],
|
||||
"Should have gotten expected events");
|
||||
|
||||
recorder.stop();
|
||||
await Promise.race([
|
||||
new Promise((_, reject) => recorder.onstop =
|
||||
_ => reject(new Error("stop() is idempotent"))),
|
||||
new Promise(r => t.step_timeout(r, 0))
|
||||
]);
|
||||
}, "MediaRecorder will stop recording and fire a stop event when all tracks are ended");
|
||||
|
||||
async_test(t => {
|
||||
promise_test(async t => {
|
||||
let video = createVideoStream();
|
||||
let recorder = new MediaRecorder(video);
|
||||
recorder.onstop = t.step_func(errorEvent => {
|
||||
assert_equals(errorEvent.type, 'stop', 'the error type should be stop');
|
||||
assert_true(errorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
|
||||
assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped when stop() is called");
|
||||
t.done();
|
||||
});
|
||||
let events = recordEvents(recorder,
|
||||
["start", "stop", "dataavailable", "pause", "resume", "error"]);
|
||||
recorder.start();
|
||||
assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
|
||||
|
||||
recorder.stop();
|
||||
assert_equals(recorder.state, "recording", "State should remain the same until stop event is fired");
|
||||
assert_equals(recorder.state, "inactive", "MediaRecorder state should be inactive immediately following stop() call");
|
||||
|
||||
let event = await new Promise (r => recorder.onstop = r);
|
||||
assert_equals(event.type, "stop", "the event type should be stop");
|
||||
assert_true(event.isTrusted, "isTrusted should be true when the event is created by C++");
|
||||
assert_equals(recorder.state, "inactive", "MediaRecorder is inactive after stop event");
|
||||
|
||||
assert_array_equals(events, ["start", "dataavailable", "stop"],
|
||||
"Should have gotten expected events");
|
||||
|
||||
recorder.stop();
|
||||
await Promise.race([
|
||||
new Promise((_, reject) => recorder.onstop =
|
||||
_ => reject(new Error("stop() is idempotent"))),
|
||||
new Promise(r => t.step_timeout(r, 0))
|
||||
]);
|
||||
}, "MediaRecorder will stop recording and fire a stop event when stop() is called");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue