mirror of
https://github.com/servo/servo.git
synced 2025-09-12 07:58:20 +01:00
Update web-platform-tests to revision e1942ace5be3a3962f204e630e9969acd70e3952
This commit is contained in:
parent
e6cf68704e
commit
69d6c85949
108 changed files with 3217 additions and 530 deletions
|
@ -0,0 +1,99 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Assigning a MediaStream to a media element and not playing it results in rendering a first frame</title>
|
||||
</head>
|
||||
<body>
|
||||
<p class="instructions">When prompted, accept to share your video stream.</p>
|
||||
<h1 class="instructions">Description</h1>
|
||||
<p class="instructions">This test checks that a HTMLMediaElement with an
|
||||
assigned MediaStream with a video track fires the appropriate events to reach
|
||||
the "canplay" event and readyState HAVE_ENOUGH_DATA even when not playing or
|
||||
autoplaying.</p>
|
||||
<video id="vid"></video>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
'use strict';
|
||||
const vid = document.getElementById("vid");
|
||||
|
||||
promise_test(async t => {
|
||||
const wait = ms => new Promise(r => t.step_timeout(r, ms));
|
||||
const timeout = (promise, time, msg) => Promise.race([
|
||||
promise,
|
||||
wait(time).then(() => Promise.reject(new Error(msg)))
|
||||
]);
|
||||
const stream = await navigator.mediaDevices.getUserMedia({video: true});
|
||||
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
|
||||
vid.srcObject = stream;
|
||||
|
||||
await timeout(new Promise(r => vid.oncanplay = r), 8000, "canplay timeout");
|
||||
assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA,
|
||||
"readyState is HAVE_ENOUGH_DATA after \"canplay\"");
|
||||
}, "Tests that loading a MediaStream in a media element eventually results in \"canplay\" even when not playing or autoplaying");
|
||||
|
||||
promise_test(async t => {
|
||||
const wait = ms => new Promise(r => t.step_timeout(r, ms));
|
||||
const timeout = (promise, time, msg) => Promise.race([
|
||||
promise,
|
||||
wait(time).then(() => Promise.reject(new Error(msg)))
|
||||
]);
|
||||
const unexpected = e => { throw new Error(`Got unexpected event ${e.name}`); };
|
||||
const stream = await navigator.mediaDevices.getUserMedia({video: true});
|
||||
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
|
||||
vid.srcObject = stream;
|
||||
|
||||
vid.onloadstart = unexpected;
|
||||
vid.ondurationchange = unexpected;
|
||||
vid.onresize = unexpected;
|
||||
vid.onloadedmetadata = unexpected;
|
||||
vid.onloadeddata = unexpected;
|
||||
vid.oncanplay = unexpected;
|
||||
vid.oncanplaythrough = unexpected;
|
||||
|
||||
await timeout(new Promise(r => vid.onloadstart = r), 8000,
|
||||
"loadstart timeout");
|
||||
vid.onloadstart = unexpected;
|
||||
|
||||
await timeout(new Promise(r => vid.ondurationchange = r), 8000,
|
||||
"durationchange timeout");
|
||||
vid.ondurationchange = unexpected;
|
||||
assert_equals(vid.duration, Infinity, "duration changes to Infinity");
|
||||
|
||||
await timeout(new Promise(r => vid.onresize = r), 8000,
|
||||
"resize timeout");
|
||||
vid.onresize = unexpected;
|
||||
assert_not_equals(vid.videoWidth, 0,
|
||||
"videoWidth is something after \"resize\"");
|
||||
assert_not_equals(vid.videoHeight, 0,
|
||||
"videoHeight is something after \"resize\"");
|
||||
|
||||
await timeout(new Promise(r => vid.onloadedmetadata = r), 8000,
|
||||
"loadedmetadata timeout");
|
||||
vid.onloadedmetadata = unexpected;
|
||||
assert_greater_than_equal(vid.readyState, vid.HAVE_METADATA,
|
||||
"readyState is at least HAVE_METADATA after \"loadedmetadata\"");
|
||||
|
||||
await timeout(new Promise(r => vid.onloadeddata = r), 8000,
|
||||
"loadeddata timeout");
|
||||
vid.onloadeddata = unexpected;
|
||||
assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA,
|
||||
"readyState is HAVE_ENOUGH_DATA after \"loadeddata\" since there's no buffering");
|
||||
|
||||
await timeout(new Promise(r => vid.oncanplay = r), 8000, "canplay timeout");
|
||||
vid.oncanplay = unexpected;
|
||||
assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA,
|
||||
"readyState is HAVE_ENOUGH_DATA after \"canplay\" since there's no buffering");
|
||||
|
||||
await timeout(new Promise(r => vid.oncanplaythrough = r), 8000,
|
||||
"canplaythrough timeout");
|
||||
vid.oncanplaythrough = unexpected;
|
||||
assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA,
|
||||
"readyState is HAVE_ENOUGH_DATA after \"canplaythrough\"");
|
||||
|
||||
// Crank the event loop to see whether any more events are fired.
|
||||
await wait(100);
|
||||
}, "Tests that loading a MediaStream in a media element sees all the expected (deterministic) events even when not playing or autoplaying");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue