mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 993495 - Update WebRTC UI and add test, r=felipe.
This commit is contained in:
parent
763657a529
commit
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 = [
|
||||
"getUserMedia:response:allow",
|
||||
"getUserMedia:revoke",
|
||||
@ -736,6 +740,50 @@ let gTests = [
|
||||
info("request video, stop sharing resets video only");
|
||||
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 = [
|
||||
{
|
||||
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"),
|
||||
accessKey: stringBundle.getString("getUserMedia.denyRequest.accesskey"),
|
||||
@ -160,8 +152,8 @@ function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevi
|
||||
accessKey: stringBundle.getString("getUserMedia.never.accesskey"),
|
||||
callback: function () {
|
||||
denyRequest(aCallID);
|
||||
// Let someone save "Never" for http sites so that they can be stopped from
|
||||
// bothering you with doorhangers
|
||||
// Let someone save "Never" for http sites so that they can be stopped from
|
||||
// bothering you with doorhangers.
|
||||
let perms = Services.perms;
|
||||
if (audioDevices.length)
|
||||
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 = {
|
||||
eventCallback: function(aTopic, aNewBrowser) {
|
||||
if (aTopic == "swapping")
|
||||
|
Loading…
x
Reference in New Issue
Block a user