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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // ----------------------------------------------------------------------------
     2 // Tests installing an add-on from a local file with whitelisting disabled.
     3 // This should be blocked by the whitelist check.
     4 function test() {
     5   Harness.installBlockedCallback = allow_blocked;
     6   Harness.installsCompletedCallback = finish_test;
     7   Harness.setup();
     9   // Disable direct request whitelisting, installing from file should be blocked.
    10   Services.prefs.setBoolPref("xpinstall.whitelist.directRequest", false);
    12   var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
    13                      .getService(Components.interfaces.nsIChromeRegistry);
    15   var chromeroot = extractChromeRoot(gTestPath);
    16   try {
    17     var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec;
    18   } catch (ex) {
    19     var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted
    20   }
    21   gBrowser.selectedTab = gBrowser.addTab();
    22   gBrowser.loadURI(xpipath);
    23 }
    25 function allow_blocked(installInfo) {
    26   ok(true, "Seen blocked");
    27   return false;
    28 }
    30 function finish_test(count) {
    31   is(count, 0, "No add-ons should have been installed");
    33   Services.prefs.clearUserPref("xpinstall.whitelist.directRequest");
    35   gBrowser.removeCurrentTab();
    36   Harness.finish();
    37 }

mercurial