Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated getUserMedia tests to use common vendor prefix infrastructure #800

Merged
merged 2 commits into from
Apr 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
120 changes: 0 additions & 120 deletions mediacapture-streams/featuredetection.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../featuredetection.js></script>
<script src=../prefix.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) {
// TODO remove when prefixes are gone
var srcObjName = FeatureNameInBrowser(vid, "srcObject");
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");
Expand All @@ -35,13 +32,13 @@ <h1>Description</h1>
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
// TODO add test that duration must be set to currentTime
// when mediastream is destroyed
vid.removeEventListener("timeupdate", testOncePlaying, false);
t.done();
t.done();
}
vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false);
vid[srcObjName] = stream;
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script>
<script>
test(function () {
assert_true(undefined !== BrowserHasFeature(navigator, "getUserMedia"), "navigator.getUserMedia exists");
assert_true(undefined !== navigator.getUserMedia, "navigator.getUserMedia exists");
}, "getUserMedia() is present on navigator");
</script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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() {
Expand All @@ -26,7 +25,7 @@ <h1>Description</h1>
}),
t.step_func(function (error) {
assert_equals(error.name, "PermissionDenied", "Permission denied error returned"); // see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22216
assert_equals(error.constraintName, null, "constraintName attribute not set for permission denied");
assert_equals(error.constraintName, null, "constraintName attribute not set for permission denied");
t.done();
}));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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 () {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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 () {
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");});
}
)
Expand Down
4 changes: 0 additions & 4 deletions mediacapture-streams/prefix.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,19 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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) {
// TODO remove when prefixes are gone
var api = BrowserHasFeature(window, "AudioContext");
if (!window.AudioContext && undefined !== api) {
window.AudioContext = api;
}
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);
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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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) {
// TODO remove when prefixes are gone
var srcObjName = FeatureNameInBrowser(vid, "srcObject");
var testOncePlaying = function() {
vid.removeEventListener("timeupdate", testOncePlaying, false);
stream.getVideoTracks()[0].enabled = false;
Expand All @@ -42,7 +39,7 @@ <h1>Description</h1>
}
t.done();
}
vid[srcObjName] = stream;
vid.srcObject = stream;
vid.play();
vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false);

Expand Down
3 changes: 1 addition & 2 deletions mediacapture-streams/stream-api/mediastream/audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.js></script>
<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script>
<script>
var astream;
var t = async_test("Tests that a MediaStream with exactly one audio track is returned", {timeout: 10000});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.js></script>
<script src="/common/vendor-prefix.js" data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]'></script>
<script>
var t = async_test("Tests that an addition to a finished MediaStream raises an exception", {timeout:20000});
t.step(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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 () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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) {
if (window.navigator.getUserMedia) {
navigator.getUserMedia({video:true}, function (stream) {
t.step(function () {
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");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ <h1>Description</h1>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../../featuredetection.js></script>
<script src=prefix.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 constructor follows the algorithm set in the spec", {timeout: 10000});
t.step(function() {
Expand All @@ -37,7 +36,7 @@ <h1>Description</h1>
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 () {
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");
Expand Down