mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 672485 - Ensure window watcher is defined. r=dtownsend,jst
This commit is contained in:
parent
ff6772f7bd
commit
34d5fb481f
@ -54,6 +54,8 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const URI_XPINSTALL_DIALOG = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
|
||||
|
||||
// Installation can begin from any of these states
|
||||
const READY_STATES = [
|
||||
AddonManager.STATE_AVAILABLE,
|
||||
@ -204,8 +206,19 @@ Installer.prototype = {
|
||||
args.installs = this.downloads;
|
||||
args.wrappedJSObject = args;
|
||||
|
||||
Services.ww.openWindow(this.window, "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul",
|
||||
try {
|
||||
Services.ww.openWindow(this.window, URI_XPINSTALL_DIALOG,
|
||||
null, "chrome,modal,centerscreen", args);
|
||||
} catch (e) {
|
||||
this.downloads.forEach(function(aInstall) {
|
||||
aInstall.removeListener(this);
|
||||
// Cancel the installs, as currently there is no way to make them fail
|
||||
// from here.
|
||||
aInstall.cancel();
|
||||
}, this);
|
||||
notifyObservers("addon-install-cancelled", this.window, this.url,
|
||||
this.downloads);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,9 @@ relativesrcdir = toolkit/mozapps/extensions/test/xpinstall
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
# browser_bug672485.js is disabled due to a leak. See bug 682410.
|
||||
|
||||
_BROWSER_FILES = head.js \
|
||||
browser_unsigned_url.js \
|
||||
browser_unsigned_trigger.js \
|
||||
|
@ -0,0 +1,52 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
gWindowWatcher = null;
|
||||
|
||||
function test() {
|
||||
Harness.installConfirmCallback = confirm_install;
|
||||
Harness.installCancelledCallback = cancelled_install;
|
||||
Harness.installEndedCallback = complete_install;
|
||||
Harness.installsCompletedCallback = finish_test;
|
||||
Harness.setup();
|
||||
|
||||
gWindowWatcher = Services.ww;
|
||||
delete Services.ww;
|
||||
is(Services.ww, undefined, "Services.ww should now be undefined");
|
||||
|
||||
var pm = Services.perms;
|
||||
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
||||
|
||||
var triggers = encodeURIComponent(JSON.stringify({
|
||||
"Unsigned XPI": TESTROOT + "unsigned.xpi"
|
||||
}));
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
||||
}
|
||||
|
||||
function confirm_install(window) {
|
||||
ok(false, "Should not see the install dialog");
|
||||
return false;
|
||||
}
|
||||
|
||||
function cancelled_install() {
|
||||
ok(true, "Install should b cancelled");
|
||||
}
|
||||
|
||||
function complete_install() {
|
||||
ok(false, "Install should not have completed");
|
||||
return false;
|
||||
}
|
||||
|
||||
function finish_test(count) {
|
||||
is(count, 0, "0 Add-ons should have been successfully installed");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
Services.ww = gWindowWatcher;
|
||||
|
||||
Services.perms.remove("example.com", "install");
|
||||
|
||||
Harness.finish();
|
||||
}
|
@ -36,6 +36,9 @@ var Harness = {
|
||||
// If set then the callback is called when an install is attempted and
|
||||
// software installation is disabled.
|
||||
installDisabledCallback: null,
|
||||
// If set then the callback is called when an install is attempted and
|
||||
// then canceled.
|
||||
installCancelledCallback: null,
|
||||
// If set then the callback will be called when an install is blocked by the
|
||||
// whitelist. The callback should return true to continue with the install
|
||||
// anyway.
|
||||
@ -216,9 +219,21 @@ var Harness = {
|
||||
ok(!!this.installDisabledCallback, "Installation shouldn't have been disabled");
|
||||
if (this.installDisabledCallback)
|
||||
this.installDisabledCallback(installInfo);
|
||||
this.expectingCancelled = true;
|
||||
installInfo.installs.forEach(function(install) {
|
||||
install.cancel();
|
||||
});
|
||||
this.expectingCancelled = false;
|
||||
this.endTest();
|
||||
},
|
||||
|
||||
installCancelled: function(installInfo) {
|
||||
if (this.expectingCancelled)
|
||||
return;
|
||||
|
||||
ok(!!this.installCancelledCallback, "Installation shouldn't have been cancelled");
|
||||
if (this.installCancelledCallback)
|
||||
this.installCancelledCallback(installInfo);
|
||||
this.endTest();
|
||||
},
|
||||
|
||||
@ -229,9 +244,11 @@ var Harness = {
|
||||
installInfo.install();
|
||||
}
|
||||
else {
|
||||
this.expectingCancelled = true;
|
||||
installInfo.installs.forEach(function(install) {
|
||||
install.cancel();
|
||||
});
|
||||
this.expectingCancelled = false;
|
||||
this.endTest();
|
||||
}
|
||||
},
|
||||
@ -326,6 +343,9 @@ var Harness = {
|
||||
case "addon-install-disabled":
|
||||
this.installDisabled(installInfo);
|
||||
break;
|
||||
case "addon-install-cancelled":
|
||||
this.installCancelled(installInfo);
|
||||
break;
|
||||
case "addon-install-blocked":
|
||||
this.installBlocked(installInfo);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user