[tbb-commits] [tor-browser/tor-browser-52.1.0esr-7.0-2] Bug 1282655 - Test if site permissions are universal across origin attributes. r=tanvi
gk at torproject.org
gk at torproject.org
Thu Apr 27 10:52:22 UTC 2017
commit 59cba8d0681caf53c46cd3718e34c9a49f9c5921
Author: Jonathan Hao <jhao at mozilla.com>
Date: Mon Dec 26 22:38:00 2016 -0500
Bug 1282655 - Test if site permissions are universal across origin attributes. r=tanvi
--HG--
extra : rebase_source : 6155960b626c29092c96ea7fbc605cc0b637d918
---
.../originattributes/test/browser/browser.ini | 1 +
.../test/browser/browser_permissions.js | 44 ++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/browser/components/originattributes/test/browser/browser.ini b/browser/components/originattributes/test/browser/browser.ini
index 911d42f..d503e9e 100644
--- a/browser/components/originattributes/test/browser/browser.ini
+++ b/browser/components/originattributes/test/browser/browser.ini
@@ -69,3 +69,4 @@ support-files =
[browser_httpauth.js]
[browser_clientAuth.js]
[browser_cacheAPI.js]
+[browser_permissions.js]
diff --git a/browser/components/originattributes/test/browser/browser_permissions.js b/browser/components/originattributes/test/browser/browser_permissions.js
new file mode 100644
index 0000000..fd3220b
--- /dev/null
+++ b/browser/components/originattributes/test/browser/browser_permissions.js
@@ -0,0 +1,44 @@
+/**
+ * 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();
+});
More information about the tbb-commits
mailing list