toolkit/mozapps/extensions/test/xpinstall/browser_whitelist2.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_whitelist2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +// ----------------------------------------------------------------------------
     1.5 +// Tests installing an unsigned add-on through an InstallTrigger call in web
     1.6 +// content. This should be blocked by the whitelist check because the source
     1.7 +// is not whitelisted, even though the target is.
     1.8 +function test() {
     1.9 +  Harness.installBlockedCallback = allow_blocked;
    1.10 +  Harness.installsCompletedCallback = finish_test;
    1.11 +  Harness.setup();
    1.12 +
    1.13 +  var pm = Services.perms;
    1.14 +  pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION);
    1.15 +
    1.16 +  var triggers = encodeURIComponent(JSON.stringify({
    1.17 +    "Unsigned XPI": TESTROOT2 + "unsigned.xpi"
    1.18 +  }));
    1.19 +  gBrowser.selectedTab = gBrowser.addTab();
    1.20 +  gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    1.21 +}
    1.22 +
    1.23 +function allow_blocked(installInfo) {
    1.24 +  is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window");
    1.25 +  is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
    1.26 +  return false;
    1.27 +}
    1.28 +
    1.29 +function finish_test() {
    1.30 +  Services.perms.remove("example.org", "install");
    1.31 +
    1.32 +  gBrowser.removeCurrentTab();
    1.33 +  Harness.finish();
    1.34 +}

mercurial