This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbrowser_chrome.js
47 lines (39 loc) · 1.75 KB
/
browser_chrome.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Load in the test harness
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
var rootDir = getRootDirectory(window.location.href);
scriptLoader.loadSubScript(rootDir + "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;
}
};
// ----------------------------------------------------------------------------