mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
// Load in the test harness
|
|
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
|
.getService(Components.interfaces.mozIJSSubScriptLoader);
|
|
scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this);
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Tests that starting a download from chrome works and bypasses the whitelist
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
var xpimgr = Components.classes["@mozilla.org/xpinstall/install-manager;1"]
|
|
.createInstance(Components.interfaces.nsIXPInstallManager);
|
|
xpimgr.initManagerFromChrome([ TESTROOT + "unsigned.xpi" ],
|
|
1, listener);
|
|
}
|
|
|
|
function finish_test() {
|
|
var em = Components.classes["@mozilla.org/extensions/manager;1"]
|
|
.getService(Components.interfaces.nsIExtensionManager);
|
|
em.cancelInstallItem("unsigned-xpi@tests.mozilla.org");
|
|
|
|
finish();
|
|
}
|
|
|
|
var listener = {
|
|
onStateChange: function(index, state, value) {
|
|
is(index, 0, "There is only one download");
|
|
if (state == Components.interfaces.nsIXPIProgressDialog.INSTALL_DONE)
|
|
is(value, 0, "Install should have succeeded");
|
|
else if (state == Components.interfaces.nsIXPIProgressDialog.DIALOG_CLOSE)
|
|
finish_test();
|
|
},
|
|
|
|
onProgress: function(index, value, maxValue) {
|
|
is(index, 0, "There is only one download");
|
|
},
|
|
|
|
QueryInterface: function(iid) {
|
|
if (iid.equals(Components.interfaces.nsIXPIProgressDialog) ||
|
|
iid.equals(Components.interfaces.nsISupports))
|
|
return this;
|
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
}
|
|
};
|
|
// ----------------------------------------------------------------------------
|