gecko-dev/xpinstall/tests/browser_localfile.js

36 строки
1.3 KiB
JavaScript

// 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 installing an local file works when loading the url
function test() {
Harness.installEndedCallback = check_xpi_install;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIChromeRegistry);
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "unsigned.xpi")).spec;
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.loadURI(path);
}
function check_xpi_install(addon, status) {
is(status, 0, "Install should succeed");
}
function finish_test() {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
em.cancelInstallItem("unsigned-xpi@tests.mozilla.org");
gBrowser.removeCurrentTab();
Harness.finish();
}
// ----------------------------------------------------------------------------