зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1564588 - Add test for third-party permission prompt wo/remember this decision. r=johannh
Depends on D40897 Differential Revision: https://phabricator.services.mozilla.com/D41435 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fafbd3a6b5
Коммит
8b23465e9a
|
@ -2,6 +2,7 @@
|
|||
support-files =
|
||||
get_user_media.html
|
||||
get_user_media_in_frame.html
|
||||
get_user_media_in_xorigin_frame.html
|
||||
get_user_media_content_script.js
|
||||
head.js
|
||||
skip-if = os == 'mac' # most tests permafail on macosx1014, see individual bugs
|
||||
|
@ -13,6 +14,8 @@ skip-if = os == 'mac' # macosx1014 permafail, see 1565738
|
|||
skip-if = os == 'mac' # macosx1014 fails due to 1567656
|
||||
[browser_devices_get_user_media_in_frame.js]
|
||||
skip-if = debug || os == 'mac' # bug 1369731, macosx1014 due to 1567746
|
||||
[browser_devices_get_user_media_in_xorigin_frame.js]
|
||||
skip-if = debug || os == 'mac' # bug 1369731, macosx1014 due to 1567746
|
||||
[browser_devices_get_user_media_multi_process.js]
|
||||
skip-if =
|
||||
(debug && os == "win") || os == "mac" || # bug 1393761, macosx1014 due to 1568142
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* 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/. */
|
||||
|
||||
var gTests = [
|
||||
{
|
||||
desc: "'Always Allow' disabled on third party pages",
|
||||
run: async function checkNoAlwaysOnThirdParty() {
|
||||
// Initially set both permissions to 'allow'.
|
||||
let Perms = Services.perms;
|
||||
let uri = Services.io.newURI("https://test1.example.com/");
|
||||
Perms.add(uri, "microphone", Perms.ALLOW_ACTION);
|
||||
Perms.add(uri, "camera", Perms.ALLOW_ACTION);
|
||||
|
||||
// Request devices and expect a prompt despite the saved 'Allow' permission,
|
||||
// because we're a third party.
|
||||
let promise = promisePopupNotificationShown("webRTC-shareDevices");
|
||||
await promiseRequestDevice(true, true, "frame1");
|
||||
await promise;
|
||||
await expectObserverCalled("getUserMedia:request");
|
||||
checkDeviceSelectors(true, true);
|
||||
|
||||
// Ensure that the 'Remember this decision' checkbox is absent.
|
||||
let notification = PopupNotifications.panel.firstElementChild;
|
||||
let checkbox = notification.checkbox;
|
||||
ok(!!checkbox, "checkbox is present");
|
||||
ok(checkbox.hidden, "checkbox is not visible");
|
||||
ok(!checkbox.checked, "checkbox not checked");
|
||||
|
||||
let indicator = promiseIndicatorWindow();
|
||||
await promiseMessage("ok", () => notification.button.click());
|
||||
await expectObserverCalled("getUserMedia:response:allow");
|
||||
await expectObserverCalled("recording-device-events");
|
||||
Assert.deepEqual(
|
||||
await getMediaCaptureState(),
|
||||
{ audio: true, video: true },
|
||||
"expected camera and microphone to be shared"
|
||||
);
|
||||
await indicator;
|
||||
await checkSharingUI({ audio: true, video: true });
|
||||
|
||||
// Cleanup.
|
||||
await closeStream(false, "frame1");
|
||||
Perms.remove(uri, "camera");
|
||||
Perms.remove(uri, "microphone");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
add_task(async function test() {
|
||||
await runTests(gTests, {
|
||||
relativeURI: "get_user_media_in_xorigin_frame.html",
|
||||
});
|
||||
});
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><meta charset="UTF-8"></head>
|
||||
<body>
|
||||
<div id="message"></div>
|
||||
<script>
|
||||
// Specifies whether we are using fake streams to run this automation
|
||||
var useFakeStreams = true;
|
||||
try {
|
||||
var audioDevice = SpecialPowers.getCharPref("media.audio_loopback_dev");
|
||||
var videoDevice = SpecialPowers.getCharPref("media.video_loopback_dev");
|
||||
dump("TEST DEVICES: Using media devices:\n");
|
||||
dump("audio: " + audioDevice + "\nvideo: " + videoDevice + "\n");
|
||||
useFakeStreams = false;
|
||||
} catch (e) {
|
||||
dump("TEST DEVICES: No test devices found (in media.{audio,video}_loopback_dev, using fake streams.\n");
|
||||
useFakeStreams = true;
|
||||
}
|
||||
|
||||
function message(m) {
|
||||
// eslint-disable-next-line no-unsanitized/property
|
||||
document.getElementById("message").innerHTML = m;
|
||||
window.parent.postMessage(m, "*");
|
||||
}
|
||||
|
||||
var gStreams = [];
|
||||
|
||||
function requestDevice(aAudio, aVideo, aShare) {
|
||||
var opts = {video: aVideo, audio: aAudio};
|
||||
if (aShare) {
|
||||
opts.video = {
|
||||
mozMediaSource: aShare,
|
||||
mediaSource: aShare,
|
||||
};
|
||||
} else if (useFakeStreams) {
|
||||
opts.fake = true;
|
||||
}
|
||||
|
||||
window.navigator.mediaDevices.getUserMedia(opts)
|
||||
.then(stream => {
|
||||
gStreams.push(stream);
|
||||
message("ok");
|
||||
}, err => message("error: " + err));
|
||||
}
|
||||
message("pending");
|
||||
|
||||
function closeStream() {
|
||||
for (let stream of gStreams) {
|
||||
if (stream) {
|
||||
stream.getTracks().forEach(t => t.stop());
|
||||
stream = null;
|
||||
}
|
||||
}
|
||||
gStreams = [];
|
||||
message("closed");
|
||||
}
|
||||
</script>
|
||||
<iframe id="frame1" allow="camera;microphone" src="https://test1.example.com/browser/browser/base/content/test/webrtc/get_user_media.html"></iframe>
|
||||
<iframe id="frame2" allow="camera;microphone" src="https://test1.example.com/browser/browser/base/content/test/webrtc/get_user_media.html"></iframe>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче