зеркало из https://github.com/mozilla/gecko-dev.git
Bug 993495 - Update WebRTC UI and add test, r=felipe.
This commit is contained in:
Родитель
763657a529
Коммит
59816ca5ee
|
@ -1,3 +1,7 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
const kObservedTopics = [
|
const kObservedTopics = [
|
||||||
"getUserMedia:response:allow",
|
"getUserMedia:response:allow",
|
||||||
"getUserMedia:revoke",
|
"getUserMedia:revoke",
|
||||||
|
@ -736,6 +740,50 @@ let gTests = [
|
||||||
info("request video, stop sharing resets video only");
|
info("request video, stop sharing resets video only");
|
||||||
yield stopAndCheckPerm(false, true);
|
yield stopAndCheckPerm(false, true);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
desc: "'Always Allow' ignored and not shown on http pages",
|
||||||
|
run: function checkNoAlwaysOnHttp() {
|
||||||
|
// Load an http page instead of the https version.
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
let browser = gBrowser.selectedTab.linkedBrowser;
|
||||||
|
browser.addEventListener("load", function onload() {
|
||||||
|
browser.removeEventListener("load", onload, true);
|
||||||
|
deferred.resolve();
|
||||||
|
}, true);
|
||||||
|
content.location = content.location.href.replace("https://", "http://");
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
// Initially set both permissions to 'allow'.
|
||||||
|
let Perms = Services.perms;
|
||||||
|
let uri = content.document.documentURIObject;
|
||||||
|
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 the connection isn't secure.
|
||||||
|
yield promisePopupNotificationShown("webRTC-shareDevices", () => {
|
||||||
|
content.wrappedJSObject.requestDevice(true, true);
|
||||||
|
});
|
||||||
|
expectObserverCalled("getUserMedia:request");
|
||||||
|
|
||||||
|
// Ensure that the 'Always Allow' action isn't shown.
|
||||||
|
let alwaysLabel = gNavigatorBundle.getString("getUserMedia.always.label");
|
||||||
|
ok(!!alwaysLabel, "found the 'Always Allow' localized label");
|
||||||
|
let labels = [];
|
||||||
|
let notification = PopupNotifications.panel.firstChild;
|
||||||
|
for (let node of notification.childNodes) {
|
||||||
|
if (node.localName == "menuitem")
|
||||||
|
labels.push(node.getAttribute("label"));
|
||||||
|
}
|
||||||
|
is(labels.indexOf(alwaysLabel), -1, "The 'Always Allow' item isn't shown");
|
||||||
|
|
||||||
|
// Cleanup.
|
||||||
|
yield closeStream(true);
|
||||||
|
Perms.remove(uri.host, "camera");
|
||||||
|
Perms.remove(uri.host, "microphone");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -140,14 +140,6 @@ function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevi
|
||||||
};
|
};
|
||||||
|
|
||||||
let secondaryActions = [
|
let secondaryActions = [
|
||||||
{
|
|
||||||
label: stringBundle.getString("getUserMedia.always.label"),
|
|
||||||
accessKey: stringBundle.getString("getUserMedia.always.accesskey"),
|
|
||||||
callback: function () {
|
|
||||||
// don't save unless secure load!
|
|
||||||
mainAction.callback(aSecure);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: stringBundle.getString("getUserMedia.denyRequest.label"),
|
label: stringBundle.getString("getUserMedia.denyRequest.label"),
|
||||||
accessKey: stringBundle.getString("getUserMedia.denyRequest.accesskey"),
|
accessKey: stringBundle.getString("getUserMedia.denyRequest.accesskey"),
|
||||||
|
@ -160,8 +152,8 @@ function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevi
|
||||||
accessKey: stringBundle.getString("getUserMedia.never.accesskey"),
|
accessKey: stringBundle.getString("getUserMedia.never.accesskey"),
|
||||||
callback: function () {
|
callback: function () {
|
||||||
denyRequest(aCallID);
|
denyRequest(aCallID);
|
||||||
// Let someone save "Never" for http sites so that they can be stopped from
|
// Let someone save "Never" for http sites so that they can be stopped from
|
||||||
// bothering you with doorhangers
|
// bothering you with doorhangers.
|
||||||
let perms = Services.perms;
|
let perms = Services.perms;
|
||||||
if (audioDevices.length)
|
if (audioDevices.length)
|
||||||
perms.add(uri, "microphone", perms.DENY_ACTION);
|
perms.add(uri, "microphone", perms.DENY_ACTION);
|
||||||
|
@ -171,6 +163,17 @@ function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevi
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (aSecure) {
|
||||||
|
// Don't show the 'Always' action if the connection isn't secure.
|
||||||
|
secondaryActions.unshift({
|
||||||
|
label: stringBundle.getString("getUserMedia.always.label"),
|
||||||
|
accessKey: stringBundle.getString("getUserMedia.always.accesskey"),
|
||||||
|
callback: function () {
|
||||||
|
mainAction.callback(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
eventCallback: function(aTopic, aNewBrowser) {
|
eventCallback: function(aTopic, aNewBrowser) {
|
||||||
if (aTopic == "swapping")
|
if (aTopic == "swapping")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче