toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.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_bug672485.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.6 + */
     1.7 +
     1.8 +gWindowWatcher = null;
     1.9 +
    1.10 +function test() {
    1.11 +  Harness.installConfirmCallback = confirm_install;
    1.12 +  Harness.installCancelledCallback = cancelled_install;
    1.13 +  Harness.installEndedCallback = complete_install;
    1.14 +  Harness.installsCompletedCallback = finish_test;
    1.15 +  Harness.setup();
    1.16 +
    1.17 +  gWindowWatcher = Services.ww;
    1.18 +  delete Services.ww;
    1.19 +  is(Services.ww, undefined, "Services.ww should now be undefined");
    1.20 +
    1.21 +  var pm = Services.perms;
    1.22 +  pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
    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(TESTROOT + "installtrigger.html?" + triggers);
    1.29 +}
    1.30 +
    1.31 +function confirm_install(window) {
    1.32 +  ok(false, "Should not see the install dialog");
    1.33 +  return false;
    1.34 +}
    1.35 +
    1.36 +function cancelled_install() {
    1.37 +  ok(true, "Install should b cancelled");
    1.38 +}
    1.39 +
    1.40 +function complete_install() {
    1.41 +  ok(false, "Install should not have completed");
    1.42 +  return false;
    1.43 +}
    1.44 +
    1.45 +function finish_test(count) {
    1.46 +  is(count, 0, "0 Add-ons should have been successfully installed");
    1.47 +
    1.48 +  gBrowser.removeCurrentTab();
    1.49 +
    1.50 +  Services.ww = gWindowWatcher;
    1.51 +
    1.52 +  Services.perms.remove("example.com", "install");
    1.53 +
    1.54 +  Harness.finish();
    1.55 +}

mercurial