зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to autoland. on a CLOSED TREE
This commit is contained in:
Коммит
c2af41dd40
|
@ -6,6 +6,7 @@
|
|||
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const {EventDispatcher} = ChromeUtils.import("resource://gre/modules/Messaging.jsm");
|
||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
// The chrome window and friends.
|
||||
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
|
@ -25,7 +26,25 @@ function cleanupTabs() {
|
|||
}
|
||||
}
|
||||
|
||||
// A user prompt is displayed during theme installation and responding to
|
||||
// the prompt from test code is tricky. Instead, just override the prompt
|
||||
// implementation and let installation proceed.
|
||||
const PROMPT_CLASSID = Components.ID("{85325f87-03f8-d142-b3a0-d2a0b8f2d4e0}");
|
||||
const PROMPT_CONTRACTID = "@mozilla.org/addons/web-install-prompt;1";
|
||||
function NullPrompt() {}
|
||||
NullPrompt.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.amIWebInstallPrompt]),
|
||||
confirm(browser, url, installs) {
|
||||
installs[0].install();
|
||||
},
|
||||
};
|
||||
|
||||
add_task(async function testThemeInstall() {
|
||||
let factory = XPCOMUtils.generateSingletonFactory(NullPrompt);
|
||||
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
let originalCID = registrar.contractIDToCID(PROMPT_CONTRACTID);
|
||||
registrar.registerFactory(PROMPT_CLASSID, "", PROMPT_CONTRACTID, factory);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.webapi.testing", true],
|
||||
["extensions.install.requireBuiltInCerts", false]],
|
||||
|
@ -61,6 +80,9 @@ add_task(async function testThemeInstall() {
|
|||
|
||||
Services.obs.removeObserver(observer, "lightweight-theme-styling-update");
|
||||
cleanupTabs();
|
||||
|
||||
registrar.unregisterFactory(PROMPT_CLASSID, factory);
|
||||
registrar.registerFactory(originalCID, "", PROMPT_CONTRACTID, null);
|
||||
});
|
||||
|
||||
run_next_test();
|
||||
|
|
|
@ -2540,7 +2540,7 @@ var AddonManagerInternal = {
|
|||
// precedence.
|
||||
// If this add-on is not a webextension or if the application does not
|
||||
// implement permission prompts, no confirmation is displayed for
|
||||
// installs created with mozAddonManager (in which case requireConfirm
|
||||
// installs created from about:addons (in which case requireConfirm
|
||||
// is false).
|
||||
// In the remaining cases, a confirmation prompt is displayed but the
|
||||
// application may override it either by implementing the
|
||||
|
@ -2705,7 +2705,12 @@ var AddonManagerInternal = {
|
|||
method: "amWebAPI",
|
||||
},
|
||||
}).then(install => {
|
||||
AddonManagerInternal.setupPromptHandler(target, null, install, false, "AMO");
|
||||
let requireConfirm = true;
|
||||
if (target.contentDocument &&
|
||||
target.contentDocument.nodePrincipal.isSystemPrincipal) {
|
||||
requireConfirm = false;
|
||||
}
|
||||
AddonManagerInternal.setupPromptHandler(target, null, install, requireConfirm, "AMO");
|
||||
|
||||
let id = this.nextInstall++;
|
||||
let {listener, installPromise} = makeListener(id, target.messageManager);
|
||||
|
|
|
@ -21,6 +21,11 @@ add_task(async function test_theme_install() {
|
|||
Services.obs.removeObserver(observer, "lightweight-theme-styling-update");
|
||||
});
|
||||
|
||||
let sawConfirm = false;
|
||||
promisePopupNotificationShown("addon-install-confirmation").then(panel => {
|
||||
sawConfirm = true;
|
||||
panel.button.click();
|
||||
});
|
||||
|
||||
let prompt1 = waitAppMenuNotificationShown("addon-installed", "theme@tests.mozilla.org", false);
|
||||
let installPromise = ContentTask.spawn(browser, URL, async (url) => {
|
||||
|
@ -29,6 +34,8 @@ add_task(async function test_theme_install() {
|
|||
});
|
||||
await prompt1;
|
||||
|
||||
ok(sawConfirm, "Confirm notification was displayed before installation");
|
||||
|
||||
// Open a new window and test the app menu panel from there. This verifies the
|
||||
// incognito checkbox as well as finishing install in this case.
|
||||
let newWin = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
|
Загрузка…
Ссылка в новой задаче