1 // Load in the test harness
2 var scriptLoader
= Components
.classes
["@mozilla.org/moz/jssubscript-loader;1"]
3 .getService(Components
.interfaces
.mozIJSSubScriptLoader
);
5 var rootDir
= getRootDirectory(window
.location
.href
);
6 scriptLoader
.loadSubScript(rootDir
+ "harness.js", this);
8 // ----------------------------------------------------------------------------
9 // Tests that cancelling an in progress download works.
13 waitForExplicitFinish();
14 gManager
= Components
.classes
["@mozilla.org/xpinstall/install-manager;1"]
15 .createInstance(Components
.interfaces
.nsIXPInstallManager
);
16 gManager
.initManagerFromChrome([ TESTROOT
+ "unsigned.xpi" ],
20 function finish_test() {
25 onStateChange: function(index
, state
, value
) {
26 is(index
, 0, "There is only one download");
27 if (state
== Components
.interfaces
.nsIXPIProgressDialog
.INSTALL_DONE
)
28 is(value
, -210, "Install should have been cancelled");
29 else if (state
== Components
.interfaces
.nsIXPIProgressDialog
.DIALOG_CLOSE
)
33 onProgress: function(index
, value
, maxValue
) {
34 is(index
, 0, "There is only one download");
35 gManager
.QueryInterface(Components
.interfaces
.nsIObserver
);
36 gManager
.observe(null, "xpinstall-progress", "cancel");
39 QueryInterface: function(iid
) {
40 if (iid
.equals(Components
.interfaces
.nsIXPIProgressDialog
) ||
41 iid
.equals(Components
.interfaces
.nsISupports
))
44 throw Components
.results
.NS_ERROR_NO_INTERFACE
;
47 // ----------------------------------------------------------------------------