mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 672485 - Ensure window watcher is defined. r=dtownsend,jst
This commit is contained in:
parent
50fab69e73
commit
89a381ae19
@ -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,13 @@ Installer.prototype = {
|
||||
args.installs = this.downloads;
|
||||
args.wrappedJSObject = args;
|
||||
|
||||
Services.ww.openWindow(this.window, "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul",
|
||||
null, "chrome,modal,centerscreen", args);
|
||||
try {
|
||||
Services.ww.openWindow(this.window, URI_XPINSTALL_DIALOG,
|
||||
null, "chrome,modal,centerscreen", args);
|
||||
} catch (e) {
|
||||
this.downloads.forEach(function(aInstall) aInstall.cancel());
|
||||
notifyObservers("addon-install-failed", this.window, this.url, failed);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -98,6 +98,7 @@ _BROWSER_FILES = head.js \
|
||||
browser_bug611242.js \
|
||||
browser_bug638292.js \
|
||||
browser_bug645699.js \
|
||||
browser_bug672485.js \
|
||||
unsigned.xpi \
|
||||
signed.xpi \
|
||||
signed2.xpi \
|
||||
|
@ -0,0 +1,48 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
Harness.installConfirmCallback = confirm_install;
|
||||
Harness.installFailedCallback = failed_install;
|
||||
Harness.installEndedCallback = complete_install;
|
||||
Harness.installsCompletedCallback = finish_test;
|
||||
Harness.setup();
|
||||
|
||||
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 failed_install() {
|
||||
ok(true, "Install should fail");
|
||||
}
|
||||
|
||||
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 = Cc["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(Ci.nsIWindowWatcher);
|
||||
|
||||
Harness.finish();
|
||||
}
|
Loading…
Reference in New Issue
Block a user