toolkit/mozapps/extensions/test/xpinstall/browser_localfile4.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_localfile4.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +// ----------------------------------------------------------------------------
     1.5 +// Tests installing an add-on from a local file with whitelisting disabled.
     1.6 +// This should be blocked by the whitelist check.
     1.7 +function test() {
     1.8 +  Harness.installBlockedCallback = allow_blocked;
     1.9 +  Harness.installsCompletedCallback = finish_test;
    1.10 +  Harness.setup();
    1.11 +
    1.12 +  // Disable file request whitelisting, installing by file referrer should be blocked.
    1.13 +  Services.prefs.setBoolPref("xpinstall.whitelist.fileRequest", false);
    1.14 +
    1.15 +  var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
    1.16 +                     .getService(Components.interfaces.nsIChromeRegistry);
    1.17 +
    1.18 +  var chromeroot = extractChromeRoot(gTestPath);
    1.19 +  try {
    1.20 +    var xpipath = cr.convertChromeURL(makeURI(chromeroot)).spec;
    1.21 +  } catch (ex) {
    1.22 +    var xpipath = chromeroot; //scenario where we are running from a .jar and already extracted
    1.23 +  }
    1.24 +  var triggers = encodeURIComponent(JSON.stringify({
    1.25 +    "Unsigned XPI": TESTROOT + "unsigned.xpi"
    1.26 +  }));
    1.27 +  gBrowser.selectedTab = gBrowser.addTab();
    1.28 +  gBrowser.loadURI(xpipath + "installtrigger.html?" + triggers);
    1.29 +}
    1.30 +
    1.31 +function allow_blocked(installInfo) {
    1.32 +  ok(true, "Seen blocked");
    1.33 +  return false;
    1.34 +}
    1.35 +
    1.36 +function finish_test(count) {
    1.37 +  is(count, 0, "No add-ons should have been installed");
    1.38 +
    1.39 +  Services.prefs.clearUserPref("xpinstall.whitelist.fileRequest");
    1.40 +
    1.41 +  gBrowser.removeCurrentTab();
    1.42 +  Harness.finish();
    1.43 +}

mercurial