diff options
Diffstat (limited to 'testing/web-platform/tests/mediacapture-streams')
26 files changed, 1059 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-api.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-api.https.html new file mode 100644 index 000000000..6e662dded --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-api.https.html @@ -0,0 +1,23 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia: test that getUserMedia is present (with or without vendor prefix)</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia"> +<meta name='assert' content='Check that the getUserMedia() method is present.'/> +</head> +<body> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks for the presence of the +<code>navigator.getUserMedia</code> method, taking vendor prefixes into account.</p> +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +test(function () { + assert_true(undefined !== navigator.getUserMedia, "navigator.getUserMedia exists"); + }, "getUserMedia() is present on navigator"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-deny.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-deny.https.html new file mode 100644 index 000000000..cce0e1c18 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-deny.https.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> +<head> + <title>getUserMedia() triggers error callback when auth is denied</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#error-names"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaStreamError"> +</head> +<body> +<p class="instructions">When prompted, <strong>please deny</strong> access to +the video stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that the error callback is triggered +when user denies access to the video stream.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that the error callback is triggered when permission is denied", {timeout:10000}); +t.step(function() { + navigator.getUserMedia( + {video: true}, + t.step_func(function (stream) { + assert_unreached("The success callback should not be triggered since access is to be denied"); + t.done(); + }), + t.step_func(function (error) { + assert_equals(error.name, "securityError", "securityError returned"); + assert_equals(error.constraintName, undefined, "constraintName attribute not set for permission denied"); + t.done(); + }) + ); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-empty-option-param.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-empty-option-param.https.html new file mode 100644 index 000000000..a543129bb --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-empty-option-param.https.html @@ -0,0 +1,35 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia({}) aborts with NOT_SUPPORTED_ERR</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +</head> +<body> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that getUserMedia with no value in the +options parameter raises a NOT_SUPPORTED_ERR exception.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that getUserMedia raises a NOT_SUPPORTED_ERR exception when used with an empty options parameter"); +t.step( function () { + // TODO This is no longer what's in the spec, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22211 + assert_throws("NOT_SUPPORTED_ERR", + function () { + navigator.getUserMedia({}, t.step_func(function (stream) { + assert_unreached("This should never be triggered since the constraints parameter is empty"); + t.done(); + }), t.step_func(function (error) { + assert_unreached("This should never be triggered since the constraints parameter is empty"); + })); + }); + t.done(); +}); + +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-impossible-constraint.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-impossible-constraint.https.html new file mode 100644 index 000000000..b63856275 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-impossible-constraint.https.html @@ -0,0 +1,35 @@ +<!doctype html> +<html> +<head> +<title>Trivial mandatory constraint in getUserMedia</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#idl-def-NavigatorUserMediaError"> +</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 setting an impossible mandatory +constraint (width >=1G) in getUserMedia works</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that setting an impossible constraint in getUserMedia fails", {timeout:10000}); +t.step(function() { + // Note - integer conversion is weird for +inf and numbers > 2^32, so we + // use a number less than 2^32 for testing. + navigator.getUserMedia({video: {width: {min:100000000}}}, t.step_func(function (stream) { + assert_unreached("a Video stream of width 100M cannot be created"); + t.done(); + }), t.step_func(function(error) { + assert_equals(error.name, "ConstraintNotSatisfiedError", "An impossible constraint triggers a ConstraintNotSatisfiedError"); + assert_equals(error.constraintName, "width", "The name of the not satisfied error is given in error.constraintName"); + t.done(); + })); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-optional-constraint.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-optional-constraint.https.html new file mode 100644 index 000000000..7e69ca03f --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-optional-constraint.https.html @@ -0,0 +1,32 @@ +<!doctype html> +<html> +<head> +<title>Optional constraint recognized as optional in getUserMedia</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +</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 setting an optional constraint in +getUserMedia is handled as optional</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that setting an optional constraint in getUserMedia is handled as optional", {timeout:10000}); +t.step(function() { + navigator.getUserMedia({video: {advanced: [{width: {min:1024, max: 800}}]}}, + t.step_func(function (stream) { + assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track"); + t.done(); + }), + t.step_func(function(error) { + assert_unreached("an optional constraint can't stop us from obtaining a video stream"); + })); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-trivial-constraint.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-trivial-constraint.https.html new file mode 100644 index 000000000..c24d02b84 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-trivial-constraint.https.html @@ -0,0 +1,31 @@ +<!doctype html> +<html> +<head> +<title>Trivial mandatory constraint in getUserMedia</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +</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 setting a trivial mandatory +constraint (width >=0) in getUserMedia works</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that setting a trivial mandatory constraint in getUserMedia works", {timeout:10000}); +t.step(function() { + navigator.getUserMedia({video: {width: {min:0}}}, t.step_func(function (stream) { + assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track"); + t.done(); + }), t.step_func(function(error) { + assert_unreached("a Video stream of minimally zero width can always be created"); + t.done(); + })); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/GUM-unknownkey-option-param.https.html b/testing/web-platform/tests/mediacapture-streams/GUM-unknownkey-option-param.https.html new file mode 100644 index 000000000..c288c7439 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/GUM-unknownkey-option-param.https.html @@ -0,0 +1,37 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia({doesnotexist:true}) aborts with NOT_SUPPORTED_ERR</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +</head> +<body> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that getUserMedia with an unknown value +in the options parameter raises a NOT_SUPPORTED_ERR exception.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +test(function () { + // TODO This is no longer what's in the spec, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22211 + assert_throws( + "NOT_SUPPORTED_ERR", + function () { + navigator.getUserMedia( + {doesnotexist:true}, + t.step_func(function (stream) { + assert_unreached("This should never be triggered since the constraints parameter is unrecognized"); + }), t.step_func(function (error) { + assert_unreached("This should never be triggered since the constraints parameter is unrecognized"); + })); + } + ) + } +); + +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html b/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html new file mode 100644 index 000000000..806416e2c --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaDevices-enumerateDevices.https.html @@ -0,0 +1,47 @@ +<!doctype html> +<html> +<head> +<title>enumerateDevices: test that enumerateDevices is present</title> +<link rel="author" title="Dr Alex Gouaillard" href="mailto:agouaillard@gmail.com"/> +<link rel="help" href="https://w3c.github.io/mediacapture-main/#enumerating-devices"> +<meta name='assert' content='Check that the enumerateDevices() method is present.'/> +</head> +<body> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks for the presence of the +<code>navigator.mediaDevices.enumerateDevices()</code> method.</p> +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +"use strict"; +//NOTE ALEX: for completion, a test for ondevicechange event is missing. +test(function () { + assert_true(undefined !== navigator.mediaDevices.enumerateDevices, "navigator.mediaDevices.enumerateDevices exists"); + var p = navigator.mediaDevices.enumerateDevices() + p.then(function(list){ + for(let mediainfo of list){ + // TODO check the type of mediainfo + assert_true(undefined !== mediainfo.deviceId, "mediaInfo's deviceId should exist."); + assert_true(undefined !== mediainfo.kind, "mediaInfo's kind should exist."); + assert_true(undefined !== mediainfo.label, "mediaInfo's label should exist."); + assert_true(undefined !== mediainfo.groupId, "mediaInfo's groupId should exist."); + // TODO the values of some of those fields should be empty string by default if no permission has been requested. + if( mediainfo.kind == "audioinput" || + mediainfo.kind == "videoinput") { + // NOTE ALEX: looks like nobody has implemented that. How can I make it a separate test, + // ... to have better granularity? + // assert_true(undefined !== mediainfo.getCapabilities(), "MediaDeviceInfo.getCapabilities() exists."); + // var cap = mediainfo.getcapabilities(); + } else if ( mediainfo.kind !== "audiooutput" ) { + assert_unreached("mediainfo.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.") + } + } + }) + p.catch(function(err){ + assert_unreached("A call to enumerateDevices() should never fail."); + }); +}, "mediaDevices.enumerateDevices() is present and working on navigator"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaDevices-getUserMedia.https.html b/testing/web-platform/tests/mediacapture-streams/MediaDevices-getUserMedia.https.html new file mode 100644 index 000000000..0573ab0a5 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaDevices-getUserMedia.https.html @@ -0,0 +1,41 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia: test that mediaDevices.getUserMedia is present</title> +<link rel="author" title="Dr Alex Gouaillard" href="mailto:agouaillard@gmail.com"/> +<link rel="help" href="https://w3c.github.io/mediacapture-main/#mediadevices-interface-extensions"> +<meta name='assert' content='Check that the mediaDevices.getUserMedia() method is present.'/> +</head> +<body> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks for the presence of the +<code>navigator.mediaDevices.getUserMedia</code> method.</p> +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +test(function () { + assert_true(undefined !== navigator.mediaDevices.getUserMedia, "navigator.mediaDevices.getUserMedia exists."); + // TODO: do some stuff with it + assert_true(undefined !== navigator.mediaDevices.getSupportedConstraints, "navigator.mediaDevices.getSupportedConstraints exists."); + var list = navigator.mediaDevices.getSupportedConstraints(); + // TODO: we are supposed to check that all values returned can be used in a constraint .... + // NOTE: the current list of attributes that may or may not be here + // ... FF for example has many no tin that list, should we fail if an attribute is present but not listed in the specs? + // list.width + // list.height + // list.aspectRatio + // list.frameRate + // list.facingMode + // list.volume + // list.sampleRate + // list.sampleSize + // list.echoCancellation + // list.latency + // list.channelCount + // list.deviceId + // list.groupId + }, "mediaDevices.getUserMedia() is present on navigator"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html new file mode 100644 index 000000000..ce97806a8 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test that the HTMLMediaElement preload 'none' attribute value is ignored for MediaStream used as srcObject and MediaStream object URLs used as src.</title>> + <link rel="author" title="Matthew Wolenetz" href="mailto:wolenetz@chromium.org"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}, {"ancestors":["window"], "name":"MediaStream"}]'></script> + </head> + <body> + <p class="instructions">When prompted, accept to share your audio and video streams.</p> + <h1 class="instructions">Description</h1> + <p class="instructions">This test checks that the HTMLMediaElement preload 'none' attribute value is ignored for MediaStream used as srcObject and MediaStream object URLs used as src.</p> + + <audio preload="none"></audio> + <video preload="none"></video> + + <script> + function testPreloadNone(t, mediaElement, setSourceStreamFunc) + { + // The optional deferred load steps (for preload none) for MediaStream resources should be skipped. + mediaElement.addEventListener("suspend", t.unreached_func("'suspend' should not be fired.")); + + mediaElement.addEventListener("loadeddata", t.step_func(function() + { + assert_equals(mediaElement.networkState, mediaElement.NETWORK_LOADING); + t.done(); + })); + + setSourceStreamFunc(); + assert_equals(mediaElement.networkState, mediaElement.NETWORK_NO_SOURCE); // Resource selection is active. + } + + async_test(function(t) + { + var aud = document.querySelector("audio"); + navigator.getUserMedia({audio:true}, t.step_func(function(stream) + { + testPreloadNone(t, aud, t.step_func(function() + { + aud.src = URL.createObjectURL(stream); + t.add_cleanup(function() { URL.revokeObjectURL(aud.src); }); + })); + }), t.unreached_func("getUserMedia error callback was invoked.")); + }, "Test that preload 'none' is ignored for MediaStream object URL used as src"); + + async_test(function(t) + { + var vid = document.querySelector("video"); + navigator.getUserMedia({video:true}, t.step_func(function(stream) + { + testPreloadNone(t, vid, t.step_func(function() { vid.srcObject = stream; })); + }), t.unreached_func("getUserMedia error callback was invoked.")); + }, "Test that preload 'none' is ignored for MediaStream used as srcObject"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html new file mode 100644 index 000000000..1bdbe3eee --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html @@ -0,0 +1,55 @@ +<!doctype html> +<html> +<head> +<title>Assigning mediastream to a video element</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia"> +</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 the MediaStream object returned by +the success callback in getUserMedia can be properly assigned to a video element +via the <code>srcObject</code> attribute.</p> + +<video id="vid"></video> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]' data-prefixed-prototypes='[{"ancestors":["HTMLMediaElement"],"name":"srcObject"}]'></script> +<script> +var vid = document.getElementById("vid"); +var t = async_test("Tests that a MediaStream can be assigned to a video element with srcObject", {timeout: 10000}); +t.step(function() { + navigator.getUserMedia({video: true}, t.step_func(function (stream) { + var testOncePlaying = function() { + assert_equals(vid.played.length, 1, "A MediaStream's timeline always consists of a single range"); + assert_equals(vid.played.start(0), 0, "A MediaStream's timeline always consists of a single range"); + assert_equals(vid.played.end(0), vid.currentTime, "A MediaStream's timeline always consists of a single range"); + assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA, "Upon selecting a media stream, the UA sets readyState to HAVE_ENOUGH_DATA"); + var time = vid.currentTime; + assert_throws("INVALID_STATE_ERR", function() { + vid.currentTime = 0; + }); + assert_equals(vid.currentTime, time, "The UA MUST ignore attempts to set the currentTime attribute"); + // TODO add test that duration must be set to currentTime + // when mediastream is destroyed + vid.removeEventListener("timeupdate", testOncePlaying, false); + t.done(); + } + vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false); + vid.srcObject = stream; + vid.play(); + assert_true(!vid.seeking, "A MediaStream is not seekable"); + assert_equals(vid.seekable.length, 0, "A MediaStream is not seekable"); + assert_equals(vid.defaultPlaybackRate, 1, "playback rate is always 1"); + assert_equals(vid.playbackRate, 1, "playback rate is always 1"); + assert_equals(vid.buffered.length, 0, "A MediaStream cannot be preloaded. Therefore, there is no buffered timeranges"); + assert_equals(vid.duration, Infinity, " A MediaStream does not have a pre-defined duration. "); + assert_equals(vid.startDate, NaN, " A MediaStream does not specify a timeline offset"); + }), function(error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-add-audio-track.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-add-audio-track.https.html new file mode 100644 index 000000000..e3650aae0 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-add-audio-track.https.html @@ -0,0 +1,54 @@ +<!doctype html> +<html> +<head> +<title>Adding a track to a MediaStream</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrackList-add-void-MediaStreamTrack-track"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#event-mediastream-addtrack"> +</head> +<body> +<p class="instructions">When prompted, accept to share your audio stream, then your video stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that adding a track to a MediaStream works as expected.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that adding a track to a MediaStream works as expected", {timeout: 20000}); // longer timeout since requires double user interaction +t.step(function () { + var audio, video; + + navigator.getUserMedia({audio: true}, gotAudio, function(error) {}); + function gotAudio(stream) { + audio = stream; + navigator.getUserMedia({video: true}, gotVideo, function(error) {}); + } + + function gotVideo(stream) { + video = stream; + t.step(function () { + assert_equals(video.getAudioTracks().length, 0, "video mediastream starts with no audio track"); + video.addTrack(audio.getAudioTracks()[0]); + assert_equals(video.getAudioTracks().length, 1, "video mediastream has now one audio track"); + video.addTrack(audio.getAudioTracks()[0]); + assert_equals(video.getAudioTracks().length, 1, "video mediastream still has one audio track"); // If track is already in stream's track set, then abort these steps. + + }); + audio.onaddtrack = t.step_func(function () { + assert_unreached("onaddtrack is not fired when the script directly modified the track of a mediastream"); + }); + t.step(function () { + assert_equals(audio.getVideoTracks().length, 0, "audio mediastream starts with no video track"); + audio.addTrack(video.getVideoTracks()[0]); + assert_equals(audio.getVideoTracks().length, 1, "audio mediastream now has one video track"); + }); + t.step(function () { + t.done(); + }); + } +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-audio-only.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-audio-only.https.html new file mode 100644 index 000000000..77d6d0c19 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-audio-only.https.html @@ -0,0 +1,35 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia({audio:true}) creates a stream with at least an audio track</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-kind"> +</head> +<body> +<p class="instructions">When prompted, accept to share your audio stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that the MediaStream object returned by +the success callback in getUserMedia has exactly one audio track.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}, {"ancestors":["window"], "name":"MediaStream"}]'></script> +<script> +var astream; +var t = async_test("Tests that a MediaStream with exactly one audio track is returned", {timeout: 10000}); +t.step(function() { + navigator.getUserMedia({audio:true}, t.step_func(function (stream) { + astream = stream; + assert_true(stream instanceof MediaStream, "getUserMedia success callback comes with a MediaStream object"); + assert_equals(stream.getAudioTracks().length, 1, "the media stream has exactly one audio track"); + assert_equals(stream.getAudioTracks()[0].kind, "audio", "getAudioTracks() returns a sequence of tracks whose kind is 'audio'"); + assert_equals(stream.getVideoTracks().length, 0, "the media stream has zero video track"); + t.done(); + }), + function(error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-finished-add.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-finished-add.https.html new file mode 100644 index 000000000..a0c4b28b1 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-finished-add.https.html @@ -0,0 +1,45 @@ +<!doctype html> +<html> +<head> +<title>Adding a track to an inactive MediaStream</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-addTrack-void-MediaStreamTrack-track"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStreamTrack-stop-void"> +</head> +<body> +<p class="instructions">When prompted, accept to share your audio stream, then +your video stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that adding a track to an inactive +MediaStream is allowed.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that adding a track to an inactive MediaStream is allowed", {timeout:20000}); +t.step(function () { + var audio, video; + + navigator.getUserMedia({audio:true}, gotAudio, function() {}); + function gotAudio(stream) { + audio = stream; + navigator.getUserMedia({video:true}, gotVideo, function() {}); + } + + function gotVideo(stream) { + video = stream; + t.step(function () { + audio.getAudioTracks()[0].stop(); + assert_false(audio.active, "audio stream is inactive after stopping its only audio track"); + assert_true(video.active, "video stream is active"); + audio.addTrack(video.getVideoTracks()[0]); + audio.removeTrack(audio.getAudioTracks()[0]); + }); + t.done(); + } +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-gettrackid.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-gettrackid.https.html new file mode 100644 index 000000000..a7fabdaac --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-gettrackid.https.html @@ -0,0 +1,35 @@ +<!doctype html> +<html> +<head> +<title>Retrieving a track from a MediaStream</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStream-getTrackById-MediaStreamTrack-DOMString-trackId"> +</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 MediaStream.getTrackById behaves as expected</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that MediaStream.getTrackById works as expected", {timeout: 10000}); +t.step(function () { + navigator.getUserMedia( + {video: true}, + t.step_func(gotVideo), + t.step_func(function (error) { + assert_unreached('Unexpected getUserMedia error: ' + error); + })); + function gotVideo(stream) { + var track = stream.getVideoTracks()[0]; + assert_equals(track, stream.getTrackById(track.id), "getTrackById returns track of given id"); + assert_equals(stream.getTrackById(track.id + "foo"), null, "getTrackById of inexistant id returns null"); + t.done(); + } +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-id-manual.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-id-manual.https.html new file mode 100644 index 000000000..88f095458 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-id-manual.https.html @@ -0,0 +1,32 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia() creates a stream with a proper id</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStream-id"> +</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 the MediaStream object returned by +the success callback in getUserMedia has a correct id.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that a MediaStream with a correct id is returned"); +var allowedCharacters = /^[\u0021\u0023-\u0027\u002A-\u002B\u002D-\u002E\u0030-\u0039\u0041-\u005A\u005E-\u007E]*$/; +if (window.navigator.getUserMedia) { + navigator.getUserMedia({video:true}, function (stream) { + t.step(function () { + assert_true(stream.id.length === 36, "the media stream id has 36 characters"); + assert_regexp_match(stream.id, allowedCharacters, "the media stream id uses the set of allowed characters"); + }); + t.done(); +}, function(error) {}); +} +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-idl.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-idl.https.html new file mode 100644 index 000000000..81cce51c1 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-idl.https.html @@ -0,0 +1,52 @@ +<!doctype html> +<html> +<head> +<title>MediaStream constructor algorithm</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaStream"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-id"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#mediastream"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#event-mediastreamtrack-ended"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStreamTrack-stop-void"> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStreamTrack-clone-MediaStreamTrack"> +</head> +<body> +<p class="instructions">When prompted, accept to share your video and audio stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that the MediaStream constructor +follows the algorithm set in the spec.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"},{"ancestors":["window"], "name":"MediaStream"}]'></script> +<script> +var t = async_test("Tests that a MediaStream constructor follows the algorithm set in the spec", {timeout: 10000}); +t.step(function() { + navigator.getUserMedia({video: true, audio:true}, t.step_func(function (stream) { + var stream1 = new MediaStream(); + assert_not_equals(stream.id, stream1.id, "Two different MediaStreams have different ids"); + var stream2 = new MediaStream(stream); + assert_not_equals(stream.id, stream2.id, "A MediaStream constructed from another have different ids"); + var audioTrack1 = stream.getAudioTracks()[0]; + var videoTrack = stream.getVideoTracks()[0]; + assert_equals(audioTrack1, stream2.getAudioTracks()[0], "A MediaStream constructed from another share the same audio track"); + assert_equals(videoTrack, stream2.getVideoTracks()[0], "A MediaStream constructed from another share the same video track"); + var stream4 = new MediaStream([audioTrack1]); + assert_equals(stream4.getTrackById(audioTrack1.id), audioTrack1, "a non-ended track gets added via the MediaStream constructor"); + + var audioTrack2 = audioTrack1.clone(); + audioTrack2.addEventListener("ended", t.step_func(function () { + var stream3 = new MediaStream([audioTrack2, videoTrack]); + assert_equals(stream3.getTrackById(audioTrack2.id), null, "an ended track doesn't get added via the MediaStream constructor"); + assert_equals(stream3.getTrackById(videoTrack.id), videoTrack, "a non-ended track gets added via the MediaStream constructor even if the previous track was ended"); + var stream5 = new MediaStream([audioTrack2]); + assert_false(stream5.active, "a MediaStream created using the MediaStream() constructor whose arguments are lists of MediaStreamTrack objects that are all ended, the MediaStream object MUST be created with its active attribute set to false"); + t.done(); + }), false); + audioTrack2.stop(); + }), function(error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-removetrack.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-removetrack.https.html new file mode 100644 index 000000000..1a62bedd7 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-removetrack.https.html @@ -0,0 +1,46 @@ +<!doctype html> +<html> +<head> +<title>Removing a track from a MediaStream</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrackList-remove-void-MediaStreamTrack-track"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#event-mediastream-removetrack"> +</head> +<body> +<p class="instructions">When prompted, accept to share your audio stream, then your video stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that removinging a track from a MediaStream works as expected.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that a removal from a MediaStream works as expected", {timeout:10000}); +t.step(function () { + var audio; + navigator.getUserMedia({audio:true}, gotAudio, function(error) {}); + function gotAudio(stream) { + audio = stream; + navigator.getUserMedia({video:true}, gotVideo, function(error) {}); + } + + function gotVideo(stream) { + var video = stream; + video.onremovetrack = function () { + assert_unreached("onremovetrack is not triggered when removal of track is triggered by the script itself"); + }; + t.step(function () { + assert_equals(video.getVideoTracks().length, 1, "video mediastream starts with one video track"); + video.removeTrack(video.getVideoTracks()[0]); + assert_equals(video.getVideoTracks().length, 0, "video mediastream has no video track left"); + video.removeTrack(audio.getAudioTracks()[0]); // should not throw + }); + t.step(function() { + t.done(); + }); + } +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-video-only.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-video-only.https.html new file mode 100644 index 000000000..aaf880ff5 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-video-only.https.html @@ -0,0 +1,32 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia({video:true}) creates a stream with one video track</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-NavigatorUserMedia-getUserMedia-void-MediaStreamConstraints-constraints-NavigatorUserMediaSuccessCallback-successCallback-NavigatorUserMediaErrorCallback-errorCallback"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-kind"> +</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 the MediaStream object returned by +the success callback in getUserMedia has exactly one video track and no audio.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}, {"ancestors":["window"], "name":"MediaStream"}]'></script> +<script> +var t = async_test("Tests that a MediaStream with at least one video track is returned"); +t.step(function() { + navigator.getUserMedia({video: true}, t.step_func(function (stream) { + assert_true(stream instanceof MediaStream, "getUserMedia success callback comes with a MediaStream object"); + assert_equals(stream.getAudioTracks().length, 0, "the media stream has zero audio track"); + assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track"); + assert_equals(stream.getVideoTracks()[0].kind, "video", "getAudioTracks() returns a sequence of tracks whose kind is 'video'"); + t.done(); + }), function(error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-audio-is-silence.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-audio-is-silence.https.html new file mode 100644 index 000000000..189bb849e --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-audio-is-silence.https.html @@ -0,0 +1,55 @@ +<!doctype html> +<html> +<head> +<title>A disabled audio track is rendered as silence</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#introduction"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreams-as-media-elements"> +</head> +<body> +<p class="instructions">When prompted, accept to share your audio stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that a disabled audio track in a +MediaStream is rendered as silence. It relies on the +<a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html"> +Web Audio API</a>.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}, {"ancestors":["window"], "name":"AudioContext"}]'></script> +<script> +var t = async_test("Tests that a disabled audio track in a MediaStream is rendered as silence", {timeout: 200000}); +var aud = document.getElementById("aud"); +t.step(function() { + navigator.getUserMedia({audio: true}, t.step_func(function (stream) { + var ctx = new AudioContext(); + var streamSource = ctx.createMediaStreamSource(stream); + var silenceDetector = ctx.createScriptProcessor(1024); + var count = 10; + silenceDetector.onaudioprocess = t.step_func(function (e) { + var buffer1 = e.inputBuffer.getChannelData(0); + var buffer2 = e.inputBuffer.getChannelData(1); + var out = e.outputBuffer.getChannelData(0); + out = new Float32Array(buffer1); + for (var i = 0; i < buffer1.length; i++) { + assert_equals(buffer1[i], 0, "Audio buffer entry #" + i + " in channel 0 is silent"); + } + for (var i = 0; i < buffer2.length; i++) { + assert_equals(buffer2[i], 0, "Audio buffer entry #" + i + " in channel 1 is silent"); + } + count--; + if (count === 0) { + silenceDetector.onaudioprocess = null; + t.done(); + } + }); + stream.getAudioTracks()[0].enabled = false; + + streamSource.connect(silenceDetector); + silenceDetector.connect(ctx.destination); + }), function(error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html new file mode 100644 index 000000000..fef3f4f3b --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html @@ -0,0 +1,56 @@ +<!doctype html> +<html> +<head> +<title>A disabled video track is rendered as blackness</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#introduction"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreams-as-media-elements"> +</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 disabled video track in a +MediaStream is rendered as blackness.</p> +<video id="vid"></video> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]' data-prefixed-prototypes='[{"ancestors":["HTMLMediaElement"],"name":"srcObject"}]'></script> +<script> +var vid = document.getElementById("vid"); +var cv = document.createElement("canvas"); +var t = async_test("Tests that a disabled video track in a MediaStream is rendered as blackness", {timeout: 10000}); +t.step(function() { + navigator.getUserMedia( + {video: true}, + t.step_func(function (stream) { + var testOncePlaying = function() { + if (stream.getVideoTracks()[0].enabled) { + stream.getVideoTracks()[0].enabled = false; + return; + } + + vid.removeEventListener("timeupdate", testOncePlaying, false); + cv.width = vid.offsetWidth; + cv.height = vid.offsetHeight; + var ctx = cv.getContext("2d"); + ctx.drawImage(vid,0,0); + var imageData = ctx.getImageData(0, 0, cv.width, cv.height); + for (var i = 0; i < imageData.data.length; i+=4) { + assert_equals(imageData.data[i], 0, "No red component in pixel #" + i); + assert_equals(imageData.data[i + 1], 0, "No green component in pixel #" + i); + assert_equals(imageData.data[i + 2], 0, "No blue component in pixel #" + i); + assert_equals(imageData.data[i + 3], 255, "No transparency in pixel #" + i); + } + t.done(); + } + vid.srcObject = stream; + vid.play(); + vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false); + }), + function(error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end.https.html new file mode 100644 index 000000000..6b6b72fc0 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end.https.html @@ -0,0 +1,39 @@ +<!doctype html> +<html> +<head> +<title>Test that mediastreamtrack are properly ended</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamtrack"> +</head> +<body> +<p class="instructions">When prompted, accept to share your video and audio +stream, and then revoke that permission.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that the video and audio tracks of +MediaStream object returned by the success callback in getUserMedia are +correctly set into inactive state when permission is revoked.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that the video MediaStreamTrack objects are properly ended on permission revocation", {timeout: 20000}); // longer timeout since requires user interaction +t.step(function () { + navigator.getUserMedia({audio: true,video: true}, t.step_func(function (stream) { + var vidTrack = stream.getVideoTracks()[0]; + assert_equals(vidTrack.readyState, "live", "The video track object is in live state"); + var audTrack = stream.getAudioTracks()[0]; + assert_equals(audTrack.readyState, "live", "The audio track object is in live state"); + vidTrack.onended = t.step_func(function () { + assert_equals(vidTrack.readyState, "ended", "Video track has been ended as expected"); + assert_equals(audTrack.readyState, "ended", "Audio track has been ended as expected"); + assert_false(stream.active, "MediaStream has been inactive as expected"); + t.done(); + }); + }), function (error) {} + ); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-id.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-id.https.html new file mode 100644 index 000000000..866b48f94 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-id.https.html @@ -0,0 +1,28 @@ +<!doctype html> +<html> +<head> +<title>Distinct id for distinct mediastream tracks</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-id"> +</head> +<body> +<p class="instructions">When prompted, accept to share your audio and video stream.</p> +<h1 class="instructions">Description</h1> +<p class="instructions">This test checks that distinct mediastream tracks have distinct ids.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that distinct mediastream tracks have distinct ids ", {timeout: 10000}); +t.step(function () { + navigator.getUserMedia({video: true, audio: true}, t.step_func(gotStream), t.step_func(function(error) {t.assert_unreached("Access to audio and video stream is granted");})); + function gotStream(stream) { + assert_not_equals(stream.getVideoTracks()[0], stream.getAudioTracks()[0].id, "audio and video tracks have distinct ids"); + t.done(); + } +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-init.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-init.https.html new file mode 100644 index 000000000..3aa12052d --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-init.https.html @@ -0,0 +1,73 @@ +<!doctype html> +<html> +<head> +<title>getUserMedia({video:true}) creates a stream with a properly initialized video track</title> +<link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#idl-def-MediaStreamTrack"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#life-cycle-and-media-flow"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-kind"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-enabled"> +<link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStreamTrack-readyState"> +</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 the video track of MediaStream +object returned by the success callback in getUserMedia is correctly initialized.</p> + +<div id='log'></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/resources/WebIDLParser.js></script> +<script src=/resources/idlharness.js></script> +<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script> +<script> +var t = async_test("Tests that the video MediaStreamTrack objects are properly initialized", {timeout:10000}); +var track = null +var idl_array = new IdlArray(); + +idl_array.add_idls("interface EventTarget {\ + void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);\ + void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);\ + boolean dispatchEvent(Event event);\ +};"); + +idl_array.add_idls("interface MediaStreamTrack : EventTarget {\ + readonly attribute DOMString kind;\ + readonly attribute DOMString id;\ + readonly attribute DOMString label;\ + attribute boolean enabled;\ + readonly attribute boolean muted;\ + attribute EventHandler onmute;\ + attribute EventHandler onunmute;\ + readonly attribute boolean _readonly;\ + readonly attribute boolean remote;\ + readonly attribute MediaStreamTrackState readyState;\ + attribute EventHandler onended;\ + attribute EventHandler onoverconstrained;\ + MediaStreamTrack clone ();\ + void stop ();\ + MediaTrackCapabilities getCapabilities ();\ + MediaTrackConstraints getConstraints ();\ + MediaTrackSettings getSettings ();\ + Promise<void> applyConstraints (optional MediaTrackConstraints constraints);\ +};"); + +t.step(function () { + navigator.getUserMedia({video: true}, t.step_func(function (stream) { + var videoTracks = stream.getVideoTracks(); + assert_equals(videoTracks.length, 1, "There is exactly one video track in the media stream"); + track = videoTracks[0]; + idl_array.add_objects({MediaStreamTrack: ["track"]}); + idl_array.test(); + assert_equals(track.readyState, "live", "The track object is in live state"); + assert_equals(track.kind, "video", "The track object is of video kind"); + // Not clear that this is required by the spec, + // see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22212 + assert_true(track.enabled, "The track object is enabed"); + t.done(); + }), function (error) {}); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrackEvent-constructor.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrackEvent-constructor.https.html new file mode 100644 index 000000000..8f5a543d8 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrackEvent-constructor.https.html @@ -0,0 +1,42 @@ +<!doctype html> +<title>MediaStreamTrackEvent constructor</title> +<link rel="help" href="https://w3c.github.io/mediacapture-main/#mediastreamtrackevent"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_equals(MediaStreamTrackEvent.length, 2); + assert_throws(new TypeError, function() { + new MediaStreamTrackEvent("type"); + }); + assert_throws(new TypeError, function() { + new MediaStreamTrackEvent("type", null); + }); + assert_throws(new TypeError, function() { + new MediaStreamTrackEvent("type", undefined); + }); +}, "The eventInitDict argument is required"); + +test(function() { + assert_throws(new TypeError, function() { + new MediaStreamTrackEvent("type", {}); + }); + assert_throws(new TypeError, function() { + new MediaStreamTrackEvent("type", { track: null }); + }); + assert_throws(new TypeError, function() { + new MediaStreamTrackEvent("type", { track: undefined }); + }); +}, "The eventInitDict's track member is required."); + +test(function() { + // a MediaStreamTrack instance is needed to test, any instance will do. + var context = new AudioContext(); + var dest = context.createMediaStreamDestination(); + var track = dest.stream.getTracks()[0]; + assert_true(track instanceof MediaStreamTrack); + var event = new MediaStreamTrackEvent("type", { track: track }); + assert_equals(event.type, "type"); + assert_equals(event.track, track); +}, "The MediaStreamTrackEvent instance's track attribute is set."); +</script> diff --git a/testing/web-platform/tests/mediacapture-streams/OWNERS b/testing/web-platform/tests/mediacapture-streams/OWNERS new file mode 100644 index 000000000..2fec44486 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/OWNERS @@ -0,0 +1,3 @@ +@agouaillard +@alvestrand +@dontcallmedom |