Bug 997365 - End support for hold-out mandatory/optional: facingMode constraint on mobile. r=smaug, r=mt

This commit is contained in:
Jan-Ivar Bruaroey 2015-02-02 10:11:00 -05:00
Родитель fc3472190e
Коммит 4993ea6729
6 изменённых файлов: 75 добавлений и 160 удалений

Просмотреть файл

@ -1629,29 +1629,6 @@ MediaManager::GetUserMedia(
c.mVideo.SetAsBoolean() = false;
}
#if defined(ANDROID) || defined(MOZ_WIDGET_GONK)
// Be backwards compatible only on mobile and only for facingMode.
if (c.mVideo.IsMediaTrackConstraints()) {
auto& tc = c.mVideo.GetAsMediaTrackConstraints();
if (!tc.mRequire.WasPassed() &&
tc.mMandatory.mFacingMode.WasPassed() && !tc.mFacingMode.WasPassed()) {
tc.mFacingMode.Construct().SetAsString() = tc.mMandatory.mFacingMode.Value();
tc.mRequire.Construct().AppendElement(NS_LITERAL_STRING("facingMode"));
}
if (tc.mOptional.WasPassed() && !tc.mAdvanced.WasPassed()) {
tc.mAdvanced.Construct();
for (size_t i = 0; i < tc.mOptional.Value().Length(); i++) {
if (tc.mOptional.Value()[i].mFacingMode.WasPassed()) {
MediaTrackConstraintSet n;
n.mFacingMode.Construct().SetAsString() =
tc.mOptional.Value()[i].mFacingMode.Value();
tc.mAdvanced.Value().AppendElement(n);
}
}
}
}
#endif
if (c.mVideo.IsMediaTrackConstraints() && !privileged) {
auto& tc = c.mVideo.GetAsMediaTrackConstraints();
// only allow privileged content to set the window id

Просмотреть файл

@ -1,87 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
Tests covering gUM constraints API for audio, video and fake video. Exercise
successful parsing code and ensure that unknown required constraints and
overconstraining cases produce appropriate errors.
TODO(jib): Merge desktop and mobile version of these tests again.
*/
var common_tests = [
// Each test here tests a different constraint or codepath.
{ message: "unknown required constraint on video fails",
constraints: { video: { somethingUnknown:0, require:["somethingUnknown"] },
fake: true },
error: "NotFoundError" },
{ message: "unknown required constraint on audio fails",
constraints: { audio: { somethingUnknown:0, require:["somethingUnknown"] },
fake: true },
error: "NotFoundError" },
{ message: "video overconstrained by facingMode fails",
constraints: { video: { facingMode:'left', require:["facingMode"] },
fake: true },
error: "NotFoundError" },
{ message: "video overconstrained by facingMode array fails",
constraints: { video: { facingMode:['left', 'right'], require:["facingMode"] },
fake: true },
error: "NotFoundError" },
{ message: "audio overconstrained by facingMode fails",
constraints: { audio: { facingMode:'left', require:["facingMode"] },
fake: true },
error: "NotFoundError" },
{ message: "full screensharing requires permission",
constraints: { video: { mediaSource:'screen' } },
error: "PermissionDeniedError" },
{ message: "application screensharing requires permission",
constraints: { video: { mediaSource:'application' } },
error: "PermissionDeniedError" },
{ message: "window screensharing requires permission",
constraints: { video: { mediaSource:'window' } },
error: "PermissionDeniedError" },
{ message: "browser screensharing requires permission",
constraints: { video: { mediaSource:'browser' } },
error: "PermissionDeniedError" },
{ message: "unknown mediaSource fails",
constraints: { video: { mediaSource:'uncle' } },
error: "NotFoundError" },
{ message: "Success-path: optional video facingMode + audio ignoring facingMode",
constraints: { fake: true,
audio: { mediaSource:'microphone',
facingMode:'left',
foo:0,
advanced: [{ facingMode:'environment' },
{ facingMode:'user' },
{ bar:0 }] },
video: { mediaSource:'camera',
facingMode:['left', 'right', 'user', 'environment'],
foo:0,
advanced: [{ facingMode:'environment' },
{ facingMode:['user'] },
{ bar:0 }] } },
error: null }
];
/**
* Starts the test run by running through each constraint
* test by verifying that the right resolution and rejection is fired.
*/
function testConstraints(tests) {
function testgum(prev, test) {
return prev.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
.then(() => is(null, test.error, test.message),
reason => is(reason.name, test.error, test.message + ": " + reason.message));
}
var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
set : [ ['media.getusermedia.browser.enabled', false],
['media.getusermedia.screensharing.enabled', false] ]
}, resolve));
tests.reduce(testgum, p)
.catch(reason => ok(false, "Unexpected failure: " + reason.message))
.then(SimpleTest.finish);
}

Просмотреть файл

@ -3,7 +3,6 @@
skip-if = (os == 'win' && strictContentSandbox) || android_version == '10'
support-files =
head.js
constraints.js
dataChannel.js
mediaStreamPlayback.js
network.js
@ -41,9 +40,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' # no windowshare on b2g/andr
[test_getUserMedia_basicVideoAudio.html]
skip-if = (toolkit == 'gonk' && debug) # debug-only failure, turned an intermittent (bug 962579) into a permanant orange
[test_getUserMedia_constraints.html]
skip-if = toolkit == 'gonk' || toolkit == 'android' # Bug 907352, backwards-compatible behavior on mobile only
[test_getUserMedia_constraints_mobile.html]
skip-if = toolkit != 'android' # Bug 1063290, intermittent timeout # Bug 907352, backwards-compatible behavior on mobile only
skip-if = toolkit == 'gonk' # Bug 1063290, intermittent timeout
[test_getUserMedia_callbacks.html]
skip-if = toolkit == 'gonk' # Bug 1063290, intermittent timeout
[test_getUserMedia_gumWithinGum.html]

Просмотреть файл

@ -7,21 +7,87 @@
<body>
<pre id="test">
<script type="application/javascript">
createHTML({ title: "Test getUserMedia constraints (desktop)", bug: "882145" });
createHTML({ title: "Test getUserMedia constraints", bug: "882145" });
/**
See constraints.js for testConstraints() and common_tests.
TODO(jib): Merge desktop and mobile version of these tests again (Bug 997365)
Tests covering gUM constraints API for audio, video and fake video. Exercise
successful parsing code and ensure that unknown required constraints and
overconstraining cases produce appropriate errors.
*/
var desktop_tests = [
{ message: "legacy facingMode ignored (desktop)",
var tests = [
// Each test here tests a different constraint or codepath.
{ message: "unknown required constraint on video fails",
constraints: { video: { somethingUnknown:0, require:["somethingUnknown"] },
fake: true },
error: "NotFoundError" },
{ message: "unknown required constraint on audio fails",
constraints: { audio: { somethingUnknown:0, require:["somethingUnknown"] },
fake: true },
error: "NotFoundError" },
{ message: "video overconstrained by facingMode fails",
constraints: { video: { facingMode:'left', require:["facingMode"] },
fake: true },
error: "NotFoundError" },
{ message: "video overconstrained by facingMode array fails",
constraints: { video: { facingMode:['left', 'right'], require:["facingMode"] },
fake: true },
error: "NotFoundError" },
{ message: "audio overconstrained by facingMode fails",
constraints: { audio: { facingMode:'left', require:["facingMode"] },
fake: true },
error: "NotFoundError" },
{ message: "full screensharing requires permission",
constraints: { video: { mediaSource:'screen' } },
error: "PermissionDeniedError" },
{ message: "application screensharing requires permission",
constraints: { video: { mediaSource:'application' } },
error: "PermissionDeniedError" },
{ message: "window screensharing requires permission",
constraints: { video: { mediaSource:'window' } },
error: "PermissionDeniedError" },
{ message: "browser screensharing requires permission",
constraints: { video: { mediaSource:'browser' } },
error: "PermissionDeniedError" },
{ message: "unknown mediaSource fails",
constraints: { video: { mediaSource:'uncle' } },
error: "NotFoundError" },
{ message: "Success-path: optional video facingMode + audio ignoring facingMode",
constraints: { fake: true,
audio: { mediaSource:'microphone',
facingMode:'left',
foo:0,
advanced: [{ facingMode:'environment' },
{ facingMode:'user' },
{ bar:0 }] },
video: { mediaSource:'camera',
facingMode:['left', 'right', 'user', 'environment'],
foo:0,
advanced: [{ facingMode:'environment' },
{ facingMode:['user'] },
{ bar:0 }] } },
error: null },
{ message: "legacy facingMode ignored",
constraints: { video: { mandatory: { facingMode:'left' } }, fake: true },
error: null },
];
runTest(function () {
testConstraints(common_tests.concat(desktop_tests));
});
/**
* Starts the test run by running through each constraint
* test by verifying that the right resolution and rejection is fired.
*/
runTest(function() {
var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
set : [ ['media.getusermedia.browser.enabled', false],
['media.getusermedia.screensharing.enabled', false] ]
}, resolve));
tests.reduce((p, test) =>
p.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
.then(() => is(null, test.error, test.message),
e => is(e.name, test.error, test.message + ": " + e.message)), p)
.catch(e => ok(false, "Unexpected failure: " + e.name + ", " + e.message))
.then(SimpleTest.finish);
});
</script>
</pre>

Просмотреть файл

@ -1,29 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<script src="mediaStreamPlayback.js"></script>
<script src="constraints.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({ title: "Test getUserMedia constraints (mobile)", bug: "882145" });
/**
See constraints.js for testConstraints() and common_tests.
TODO(jib): Merge desktop and mobile version of these tests again (Bug 997365)
*/
var mobile_tests = [
{ message: "legacy facingMode overconstrains video (mobile)",
constraints: { video: { mandatory: { facingMode:'left' } }, fake: true },
error: "NotFoundError" },
];
runTest(function () {
testConstraints(common_tests.concat(mobile_tests));
});
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -13,15 +13,6 @@
dictionary MediaTrackConstraints : MediaTrackConstraintSet {
sequence<DOMString> require;
sequence<MediaTrackConstraintSet> advanced;
// mobile-only backwards-compatibility for facingMode
MobileLegacyMediaTrackConstraintSet mandatory;
sequence<MobileLegacyMediaTrackConstraintSet> _optional;
};
// TODO(jib): Remove in 6+ weeks (Bug 997365)
dictionary MobileLegacyMediaTrackConstraintSet {
DOMString facingMode;
};
interface MediaStreamTrack {