зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1503518 [wpt PR 13805] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=190778, a=testonly
Automatic update from web-platform-testswpt-export-for-webkit-190778 -- Merge pull request #13805 from woaiwyhty/wpt-export-for-webkit-190778 WebKit export of https://bugs.webkit.org/show_bug.cgi?id=190778 -- wpt-commits: ff3e6e2db88acc409216225c80aef51594696215, 457d416adbbfff6916357a347d2a98fef2d8fcd2 wpt-pr: 13805
This commit is contained in:
Родитель
1fdfb8d313
Коммит
7a4e8ffe51
|
@ -0,0 +1,47 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<title>MediaRecorder destroy script execution context</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<iframe src="support/MediaRecorder-iframe.html" id="subFrame-stop" name="subFrameStop"></iframe>
|
||||
<iframe src="support/MediaRecorder-iframe.html" id="subFrame-allTrackEnded" name="subFrameAllTrackEnded"></iframe>
|
||||
<script>
|
||||
var iframeForCallingStop = document.getElementById('subFrame-stop');
|
||||
var iframeForAllTrackEnded = document.getElementById('subFrame-allTrackEnded');
|
||||
|
||||
var testForCallingStop = async_test('MediaRecorder will not fire the stop event when stop() is called and the script execution context is going away');
|
||||
var testForAllTrackEnded = async_test('MediaRecorder will not fire the stop event when all tracks are ended and the script execution context is going away');
|
||||
|
||||
iframeForCallingStop.onload = function(e) {
|
||||
subFrameStop.window.prepareForTest();
|
||||
const recorder = subFrameStop.window.recorder;
|
||||
recorder.ondataavailable = testForCallingStop.step_func(blobEvent => {
|
||||
iframeForCallingStop.remove();
|
||||
testForCallingStop.step_timeout(testForCallingStop.step_func_done(), 0);
|
||||
});
|
||||
recorder.onstop = testForCallingStop.unreached_func('Unexpected stop event');
|
||||
recorder.start();
|
||||
assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
|
||||
subFrameStop.window.drawSomethingOnCanvas();
|
||||
recorder.stop();
|
||||
};
|
||||
|
||||
iframeForAllTrackEnded.onload = function(e) {
|
||||
subFrameAllTrackEnded.window.prepareForTest();
|
||||
const recorder = subFrameAllTrackEnded.window.recorder;
|
||||
recorder.ondataavailable = testForAllTrackEnded.step_func(blobEvent => {
|
||||
iframeForAllTrackEnded.remove();
|
||||
testForAllTrackEnded.step_timeout(testForAllTrackEnded.step_func_done(), 0);
|
||||
});
|
||||
recorder.onstop = testForAllTrackEnded.unreached_func('Unexpected stop event');
|
||||
recorder.start();
|
||||
assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
|
||||
subFrameAllTrackEnded.window.drawSomethingOnCanvas();
|
||||
subFrameAllTrackEnded.window.video.getVideoTracks()[0].stop();
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,50 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>MediaRecorder Stop</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();
|
||||
}
|
||||
|
||||
async_test(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();
|
||||
});
|
||||
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();
|
||||
}, "MediaRecorder will stop recording and fire a stop event when all tracks are ended");
|
||||
|
||||
async_test(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();
|
||||
});
|
||||
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");
|
||||
}, "MediaRecorder will stop recording and fire a stop event when stop() is called");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Start a MediaRecorder</title>
|
||||
<html>
|
||||
<body>
|
||||
<canvas id="canvas" width="200px" height="200px"></canvas>
|
||||
<script>
|
||||
var context;
|
||||
var recorder;
|
||||
var video;
|
||||
|
||||
function createVideoStream() {
|
||||
const canvas = document.getElementById("canvas");
|
||||
context = canvas.getContext('2d');
|
||||
return canvas.captureStream();
|
||||
}
|
||||
|
||||
function drawSomethingOnCanvas() {
|
||||
context.fillStyle = "red";
|
||||
context.fillRect(0, 0, 10, 10);
|
||||
}
|
||||
|
||||
function prepareForTest() {
|
||||
video = createVideoStream();
|
||||
recorder = new MediaRecorder(video);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче