toolkit/mozapps/extensions/test/xpinstall/browser_cookies.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_cookies.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +// ----------------------------------------------------------------------------
     1.5 +// Test that an install that requires cookies to be sent fails when no cookies
     1.6 +// are set
     1.7 +// This verifies bug 462739
     1.8 +function test() {
     1.9 +  Harness.downloadFailedCallback = download_failed;
    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.com/"), "install", pm.ALLOW_ACTION);
    1.15 +
    1.16 +  var triggers = encodeURIComponent(JSON.stringify({
    1.17 +    "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "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 download_failed(install) {
    1.24 +  is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should fail");
    1.25 +}
    1.26 +
    1.27 +function finish_test(count) {
    1.28 +  is(count, 0, "No add-ons should have been installed");
    1.29 +  Services.perms.remove("example.com", "install");
    1.30 +
    1.31 +  gBrowser.removeCurrentTab();
    1.32 +  Harness.finish();
    1.33 +}

mercurial