mirror of
https://github.com/servo/servo.git
synced 2025-08-17 03:15:34 +01:00
Update web-platform-tests to revision 2b7dace05fc1869398ee24f84fda4c0e4c0455ae
This commit is contained in:
parent
b23125d590
commit
6c901de216
844 changed files with 19802 additions and 3093 deletions
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
// This test verifies that ImageCapture can be created (or not) with different
|
||||
// Media Stream Track types (audio, video).
|
||||
|
||||
function makeAsyncTest(modifyTrack, message) {
|
||||
async_test(function(test) {
|
||||
|
||||
const gotStream = test.step_func(function(stream) {
|
||||
assert_equals(stream.getAudioTracks().length, 0);
|
||||
assert_equals(stream.getVideoTracks().length, 1);
|
||||
|
||||
var videoTrack = stream.getVideoTracks()[0];
|
||||
assert_equals(videoTrack.readyState, 'live');
|
||||
assert_true(videoTrack.enabled);
|
||||
assert_false(videoTrack.muted);
|
||||
|
||||
var capturer = new ImageCapture(videoTrack);
|
||||
assert_equals(capturer.track, videoTrack);
|
||||
|
||||
modifyTrack(videoTrack);
|
||||
|
||||
promise_rejects(test,
|
||||
'InvalidStateError',
|
||||
capturer.grabFrame(),
|
||||
'Should throw InvalidStateError.')
|
||||
.then(() => test.done());
|
||||
});
|
||||
|
||||
const onError = test.unreached_func('Error creating MediaStream.');
|
||||
navigator.mediaDevices.getUserMedia({video: true})
|
||||
.then(gotStream)
|
||||
.catch(onError);
|
||||
|
||||
}, message);
|
||||
}
|
||||
|
||||
var disableTrack = function(videoTrack) {
|
||||
// grabFrame() is rejected if the associated video track is disabled.
|
||||
videoTrack.enabled = false;
|
||||
};
|
||||
|
||||
var stopTrack = function(videoTrack) {
|
||||
// grabFrame() is rejected if the associated video track is ended.
|
||||
videoTrack.stop();
|
||||
assert_equals(videoTrack.readyState, 'ended');
|
||||
};
|
||||
|
||||
// Create the rejection tests. Note that grabFrame() would also be rejected if
|
||||
// the video Track was muted but that's a read-only property of the Track.
|
||||
makeAsyncTest(disableTrack, 'grabFrame() of a disabled Track');
|
||||
makeAsyncTest(stopTrack, 'grabFrame() of an ended Track');
|
||||
|
||||
|
||||
var testAudio = async_test(function() {
|
||||
navigator.mediaDevices.getUserMedia({audio:true})
|
||||
.then(
|
||||
this.step_func(function(stream) {
|
||||
assert_equals(stream.getAudioTracks().length, 1);
|
||||
assert_equals(stream.getVideoTracks().length, 0);
|
||||
assert_throws("NotSupportedError",
|
||||
function() {
|
||||
var capturer = new ImageCapture(stream.getAudioTracks()[0]);
|
||||
},
|
||||
'an ImageCapturer can only be created from a video track');
|
||||
|
||||
this.done();
|
||||
}))
|
||||
.catch(
|
||||
this.unreached_func('Error creating MediaStream.'));
|
||||
}, 'verifies that an ImageCapture cannot be created out of an Audio Track');
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue