Commit f5feb64d authored by Jonathan Hao's avatar Jonathan Hao Committed by Georg Koppen
Browse files

Bug 1282655 - Test if site permissions are universal across origin attributes. r=tanvi

--HG--
extra : rebase_source : 6155960b626c29092c96ea7fbc605cc0b637d918
parent 42e02834
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -69,3 +69,4 @@ support-files =
[browser_httpauth.js]
[browser_clientAuth.js]
[browser_cacheAPI.js]
[browser_permissions.js]
+44 −0
Original line number Diff line number Diff line
/**
 * Bug 1282655 - Test if site permissions are universal across origin attributes.
 *
 * This test is testing the cookie "permission" for a specific URI.
 */

const TEST_PAGE = "http://example.net";
const uri = Services.io.newURI(TEST_PAGE, null, null);

function disableCookies() {
  Services.cookies.removeAll();
  Services.perms.add(uri, "cookie", Services.perms.DENY_ACTION);
}

function ensureCookieNotSet(aBrowser) {
  ContentTask.spawn(aBrowser, null, function*() {
    content.document.cookie = "key=value";
    is(content.document.cookie, "", "Setting/reading cookies should be disabled"
      + " for this domain for all origin attribute combinations.");
  });
}

IsolationTestTools.runTests(TEST_PAGE, ensureCookieNotSet, () => true,
                            disableCookies);

function enableCookies() {
  Services.cookies.removeAll();
  Services.perms.add(uri, "cookie", Services.perms.ALLOW_ACTION);
}

function ensureCookieSet(aBrowser) {
  ContentTask.spawn(aBrowser, null, function() {
    content.document.cookie = "key=value";
    is(content.document.cookie, "key=value", "Setting/reading cookies should be"
      + " enabled for this domain for all origin attribute combinations.");
  });
}

IsolationTestTools.runTests(TEST_PAGE, ensureCookieSet, () => true,
                            enableCookies);

registerCleanupFunction(() => {
    Services.cookies.removeAll();
});