mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1644519 - Wait for permission change to settle in browser_doorhanger_installs.js. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D79382
This commit is contained in:
parent
e97469625b
commit
a2f65accfd
@ -63,12 +63,10 @@ async function setPrivateBrowsingValue(value, id) {
|
||||
// Let's make sure we received the right message
|
||||
let { permissions } = value == "0" ? removed : added;
|
||||
ok(permissions.includes("internal:privateBrowsingAllowed"));
|
||||
|
||||
Management.off("change-permissions", listener);
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
Management.on("change-permissions", listener);
|
||||
Management.once("change-permissions", listener);
|
||||
});
|
||||
let radio = getHtmlElem(
|
||||
`input[type="radio"][name="private-browsing"][value="${value}"]`
|
||||
|
@ -8,6 +8,9 @@ const { AddonTestUtils } = ChromeUtils.import(
|
||||
const { ExtensionPermissions } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionPermissions.jsm"
|
||||
);
|
||||
const { Management } = ChromeUtils.import(
|
||||
"resource://gre/modules/Extension.jsm"
|
||||
);
|
||||
|
||||
const SECUREROOT =
|
||||
"https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
||||
@ -123,6 +126,7 @@ async function waitForProgressNotification(
|
||||
|
||||
function acceptAppMenuNotificationWhenShown(
|
||||
id,
|
||||
extensionId,
|
||||
{
|
||||
dismiss = false,
|
||||
checkIncognito = false,
|
||||
@ -132,6 +136,7 @@ function acceptAppMenuNotificationWhenShown(
|
||||
) {
|
||||
const { AppMenuNotifications, PanelUI, document } = global;
|
||||
return new Promise(resolve => {
|
||||
let permissionChangePromise = null;
|
||||
function appMenuPopupHidden() {
|
||||
PanelUI.panel.removeEventListener("popuphidden", appMenuPopupHidden);
|
||||
is(
|
||||
@ -139,7 +144,7 @@ function acceptAppMenuNotificationWhenShown(
|
||||
false,
|
||||
"badge is not set after addon-installed"
|
||||
);
|
||||
resolve();
|
||||
resolve(permissionChangePromise);
|
||||
}
|
||||
function appMenuPopupShown() {
|
||||
PanelUI.panel.removeEventListener("popupshown", appMenuPopupShown);
|
||||
@ -167,6 +172,26 @@ function acceptAppMenuNotificationWhenShown(
|
||||
"checkbox visibility is correct"
|
||||
);
|
||||
is(checkbox.checked, incognitoChecked, "checkbox is marked as expected");
|
||||
|
||||
// If we're unchecking or checking the incognito property, this will
|
||||
// trigger an update in ExtensionPermission, let's wait for it before
|
||||
// returning from this promise.
|
||||
if (incognitoChecked != checkIncognito) {
|
||||
permissionChangePromise = new Promise(resolve => {
|
||||
const listener = (type, change) => {
|
||||
if (extensionId == change.extensionId) {
|
||||
// Let's make sure we received the right message
|
||||
let { permissions } = checkIncognito
|
||||
? change.added
|
||||
: change.removed;
|
||||
ok(permissions.includes("internal:privateBrowsingAllowed"));
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
Management.once("change-permissions", listener);
|
||||
});
|
||||
}
|
||||
|
||||
checkbox.checked = checkIncognito;
|
||||
|
||||
if (dismiss) {
|
||||
@ -182,7 +207,7 @@ function acceptAppMenuNotificationWhenShown(
|
||||
let popupnotification = document.getElementById(popupnotificationID);
|
||||
|
||||
popupnotification.button.click();
|
||||
resolve();
|
||||
resolve(permissionChangePromise);
|
||||
}
|
||||
PanelUI.notificationPanel.addEventListener("popupshown", popupshown);
|
||||
});
|
||||
@ -390,7 +415,11 @@ var TESTS = [
|
||||
|
||||
let installDialog = await dialogPromise;
|
||||
|
||||
notificationPromise = acceptAppMenuNotificationWhenShown("addon-installed");
|
||||
notificationPromise = acceptAppMenuNotificationWhenShown(
|
||||
"addon-installed",
|
||||
"amosigned-xpi@tests.mozilla.org"
|
||||
);
|
||||
|
||||
installDialog.button.click();
|
||||
await notificationPromise;
|
||||
|
||||
@ -514,6 +543,7 @@ var TESTS = [
|
||||
|
||||
let notificationPromise = acceptAppMenuNotificationWhenShown(
|
||||
"addon-installed",
|
||||
"amosigned-xpi@tests.mozilla.org",
|
||||
{ dismiss: true }
|
||||
);
|
||||
acceptInstallDialog(installDialog);
|
||||
@ -703,6 +733,7 @@ var TESTS = [
|
||||
|
||||
let notificationPromise = acceptAppMenuNotificationWhenShown(
|
||||
"addon-installed",
|
||||
"amosigned-xpi@tests.mozilla.org",
|
||||
{ checkIncognito: true }
|
||||
);
|
||||
installDialog.button.click();
|
||||
@ -975,6 +1006,7 @@ var TESTS = [
|
||||
|
||||
let notificationPromise = acceptAppMenuNotificationWhenShown(
|
||||
"addon-installed",
|
||||
"amosigned-xpi@tests.mozilla.org",
|
||||
{ incognitoChecked: true }
|
||||
);
|
||||
installDialog.button.click();
|
||||
@ -1072,6 +1104,7 @@ var TESTS = [
|
||||
|
||||
let notificationPromise = acceptAppMenuNotificationWhenShown(
|
||||
"addon-installed",
|
||||
"amosigned-xpi@tests.mozilla.org",
|
||||
{ incognitoChecked: true, global: win }
|
||||
);
|
||||
acceptInstallDialog(installDialog);
|
||||
|
Loading…
Reference in New Issue
Block a user