mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1201973 - 'Stop Sharing' should also revoke persistent permissions granted to frames, r=Gijs.
This commit is contained in:
parent
844fad09fb
commit
1924ade856
@ -269,7 +269,7 @@ let gTests = [
|
||||
|
||||
let indicator = promiseIndicatorWindow();
|
||||
yield promiseMessage("ok", () => {
|
||||
PopupNotifications.panel.firstChild.button.click();
|
||||
activateSecondaryAction(kActionAlways);
|
||||
});
|
||||
expectObserverCalled("getUserMedia:response:allow");
|
||||
expectObserverCalled("recording-device-events");
|
||||
@ -279,6 +279,13 @@ let gTests = [
|
||||
yield indicator;
|
||||
yield checkSharingUI({video: true, audio: true});
|
||||
|
||||
let Perms = Services.perms;
|
||||
let uri = Services.io.newURI("https://example.com/", null, null);
|
||||
is(Perms.testExactPermission(uri, "microphone"), Perms.ALLOW_ACTION,
|
||||
"microphone persistently allowed");
|
||||
is(Perms.testExactPermission(uri, "camera"), Perms.ALLOW_ACTION,
|
||||
"camera persistently allowed");
|
||||
|
||||
yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
|
||||
activateSecondaryAction(kActionDeny);
|
||||
|
||||
@ -296,6 +303,12 @@ let gTests = [
|
||||
expectNoObserverCalled();
|
||||
yield checkNotSharing();
|
||||
|
||||
// The persistent permissions for the frame should have been removed.
|
||||
is(Perms.testExactPermission(uri, "microphone"), Perms.UNKNOWN_ACTION,
|
||||
"microphone not persistently allowed");
|
||||
is(Perms.testExactPermission(uri, "camera"), Perms.UNKNOWN_ACTION,
|
||||
"camera not persistently allowed");
|
||||
|
||||
// the stream is already closed, but this will do some cleanup anyway
|
||||
yield closeStream(global, true);
|
||||
}
|
||||
|
@ -393,7 +393,16 @@ function prompt(aBrowser, aRequest) {
|
||||
allowedDevices.push(videoDevices[0].deviceIndex);
|
||||
if (audioDevices.length && micPerm == perms.ALLOW_ACTION)
|
||||
allowedDevices.push(audioDevices[0].deviceIndex);
|
||||
let mm = this.browser.messageManager;
|
||||
|
||||
// Remember on which URIs we found persistent permissions so that we
|
||||
// can remove them if the user clicks 'Stop Sharing'. There's no
|
||||
// other way for the stop sharing code to know the hostnames of frames
|
||||
// using devices until bug 1066082 is fixed.
|
||||
let browser = this.browser;
|
||||
browser._devicePermissionURIs = browser._devicePermissionURIs || [];
|
||||
browser._devicePermissionURIs.push(uri);
|
||||
|
||||
let mm = browser.messageManager;
|
||||
mm.sendAsyncMessage("webrtc:Allow", {callID: aRequest.callID,
|
||||
windowID: aRequest.windowID,
|
||||
devices: allowedDevices});
|
||||
@ -534,6 +543,13 @@ function prompt(aBrowser, aRequest) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRemember) {
|
||||
// Remember on which URIs we set persistent permissions so that we
|
||||
// can remove them if the user clicks 'Stop Sharing'.
|
||||
aBrowser._devicePermissionURIs = aBrowser._devicePermissionURIs || [];
|
||||
aBrowser._devicePermissionURIs.push(uri);
|
||||
}
|
||||
|
||||
let mm = notification.browser.messageManager;
|
||||
mm.sendAsyncMessage("webrtc:Allow", {callID: aRequest.callID,
|
||||
windowID: aRequest.windowID,
|
||||
@ -862,15 +878,17 @@ function updateBrowserSpecificIndicator(aBrowser, aState) {
|
||||
label: stringBundle.getString("getUserMedia.stopSharing.label"),
|
||||
accessKey: stringBundle.getString("getUserMedia.stopSharing.accesskey"),
|
||||
callback: function () {
|
||||
let uri = Services.io.newURI(aState.documentURI, null, null);
|
||||
let uris = aBrowser._devicePermissionURIs || [];
|
||||
uris = uris.concat(Services.io.newURI(aState.documentURI, null, null));
|
||||
let perms = Services.perms;
|
||||
if (aState.camera &&
|
||||
perms.testExactPermission(uri, "camera") == perms.ALLOW_ACTION)
|
||||
perms.remove(uri, "camera");
|
||||
if (aState.microphone &&
|
||||
perms.testExactPermission(uri, "microphone") == perms.ALLOW_ACTION)
|
||||
perms.remove(uri, "microphone");
|
||||
|
||||
for (let uri of uris) {
|
||||
if (aState.camera &&
|
||||
perms.testExactPermission(uri, "camera") == perms.ALLOW_ACTION)
|
||||
perms.remove(uri, "camera");
|
||||
if (aState.microphone &&
|
||||
perms.testExactPermission(uri, "microphone") == perms.ALLOW_ACTION)
|
||||
perms.remove(uri, "microphone");
|
||||
}
|
||||
let mm = notification.browser.messageManager;
|
||||
mm.sendAsyncMessage("webrtc:StopSharing", windowId);
|
||||
}
|
||||
@ -902,12 +920,13 @@ function updateBrowserSpecificIndicator(aBrowser, aState) {
|
||||
anchorId, mainAction, secondaryActions, options);
|
||||
}
|
||||
else {
|
||||
removeBrowserNotification(aBrowser,"webRTC-sharingDevices");
|
||||
removeBrowserNotification(aBrowser, "webRTC-sharingDevices");
|
||||
aBrowser._devicePermissionURIs = null;
|
||||
}
|
||||
|
||||
// Now handle the screen sharing indicator.
|
||||
if (!aState.screen) {
|
||||
removeBrowserNotification(aBrowser,"webRTC-sharingScreen");
|
||||
removeBrowserNotification(aBrowser, "webRTC-sharingScreen");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user