Bug 1459307 - Switching between menu options should maintain correct main action state when window sharing is requested. r=johannh

Switching between menu options should maintain correct main action state when window sharing is requested.

Differential Revision: https://phabricator.services.mozilla.com/D7742

--HG--
extra : moz-landing-system : lando
This commit is contained in:
prathiksha 2018-10-09 14:38:36 +00:00
Родитель 13a2e264e0
Коммит 967600d2bd
2 изменённых файлов: 41 добавлений и 1 удалений

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

@ -10,6 +10,7 @@
// should use "expectUncaughtRejection" to flag individual failures.
ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm", this);
PromiseTestUtils.whitelistRejectionsGlobally(/aborted by the user agent/);
ChromeUtils.import("resource:///modules/BrowserWindowTracker.jsm", this);
const permissionError = "error: NotAllowedError: The request is not allowed " +
"by the user agent or the platform in the current context.";
@ -584,6 +585,37 @@ var gTests = [
},
},
{
desc: "Switching between menu options maintains correct main action state while window sharing",
run: async function checkDoorhangerState() {
let win = await BrowserTestUtils.openNewBrowserWindow();
await BrowserTestUtils.openNewForegroundTab(win.gBrowser, "about:newtab");
BrowserWindowTracker.orderedWindows[1].focus();
let promise = promisePopupNotificationShown("webRTC-shareDevices");
await promiseRequestDevice(false, true, null, "window");
await promise;
await expectObserverCalled("getUserMedia:request");
let menulist = document.getElementById("webRTC-selectWindow-menulist");
let notification = PopupNotifications.panel.firstElementChild;
let checkbox = notification.checkbox;
menulist.getItemAtIndex(2).doCommand();
checkbox.click();
ok(checkbox.checked, "checkbox now checked");
ok(notification.button.disabled, "Allow button is disabled");
ok(!notification.hasAttribute("warninghidden"), "warning message is shown");
menulist.getItemAtIndex(3).doCommand();
ok(checkbox.checked, "checkbox still checked");
ok(notification.button.disabled, "Allow button remains disabled");
ok(!notification.hasAttribute("warninghidden"), "warning message is still shown");
win.close();
},
},
];
add_task(async function test() {

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

@ -1477,7 +1477,15 @@ PopupNotifications.prototype = {
notificationEl =
notificationEl.ownerDocument.getBindingParent(notificationEl) || notificationEl.parentNode;
}
this._setNotificationUIState(notificationEl);
let notification = notificationEl.notification;
if (notification.options.checkbox) {
if (notificationEl.checkbox.checked) {
this._setNotificationUIState(notificationEl, notification.options.checkbox.checkedState);
} else {
this._setNotificationUIState(notificationEl, notification.options.checkbox.uncheckedState);
}
}
},
_onButtonEvent(event, type, source = "button", notificationEl = null) {