From 197ffe4af0b5e91e9e8628eb8c39fb94ac585dd0 Mon Sep 17 00:00:00 2001
From: "sayrer@gmail.com"
Ev5f^-H+-Di={FM
z6ELfqlYm*#JPnvzN-7X}z;xDa7laF>!j(b}#2%2SYCZxI70s7GqTy5(h$fH@+*$zQ
z1<1Hw Ev5f^-H+-Di={FM
z6ELfqlYm*#JPnvzN-7X}z;xDa7laF>!j(b}#2%2SYCZxI70s7GqTy5(h$fH@+*$zQ
z1<1Hw
+
+
+
+
diff --git a/extensions/cookie/test/test_image.html b/extensions/cookie/test/test_image.html
new file mode 100644
index 00000000000..681a0075ea2
--- /dev/null
+++ b/extensions/cookie/test/test_image.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_loadflags.html b/extensions/cookie/test/test_loadflags.html
new file mode 100644
index 00000000000..1e50680d926
--- /dev/null
+++ b/extensions/cookie/test/test_loadflags.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain.html b/extensions/cookie/test/test_same_base_domain.html
new file mode 100644
index 00000000000..ef2a5d4f429
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain_2.html b/extensions/cookie/test/test_same_base_domain_2.html
new file mode 100644
index 00000000000..18cf5c15f56
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain_2.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain_3.html b/extensions/cookie/test/test_same_base_domain_3.html
new file mode 100644
index 00000000000..e768d8b84af
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain_3.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain_4.html b/extensions/cookie/test/test_same_base_domain_4.html
new file mode 100644
index 00000000000..60706b5f31d
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain_4.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain_5.html b/extensions/cookie/test/test_same_base_domain_5.html
new file mode 100644
index 00000000000..cf959e66190
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain_5.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain_6.html b/extensions/cookie/test/test_same_base_domain_6.html
new file mode 100644
index 00000000000..fbc5945fbd9
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain_6.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_same_base_domain_7.html b/extensions/cookie/test/test_same_base_domain_7.html
new file mode 100644
index 00000000000..06c7307d79d
--- /dev/null
+++ b/extensions/cookie/test/test_same_base_domain_7.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/test_samedomain.html b/extensions/cookie/test/test_samedomain.html
new file mode 100644
index 00000000000..51ed99b201b
--- /dev/null
+++ b/extensions/cookie/test/test_samedomain.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/extensions/cookie/test/unit/test_cookies.js b/extensions/cookie/test/unit/test_cookies.js
new file mode 100644
index 00000000000..ccda2a72bee
--- /dev/null
+++ b/extensions/cookie/test/unit/test_cookies.js
@@ -0,0 +1,49 @@
+// test third party cookie blocking, for the cases:
+// 1) with null channel
+// 2) with channel, but with no docshell parent
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+function run_test() {
+ var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
+ var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
+ var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+ var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+
+ var spec = "http://foo.com/dribble.html";
+ var uri = ios.newURI(spec, null, null);
+ var channel = ios.newChannelFromURI(uri);
+
+ // test with cookies enabled
+ prefs.setIntPref("network.cookie.cookieBehavior", 0);
+ // without channel
+ cs.setCookieString(uri, null, "oh=hai", null);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 1);
+ // with channel
+ cs.setCookieString(uri, null, "can=has", channel);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 2);
+ // without channel, from http
+ cs.setCookieStringFromHttp(uri, null, null, "cheez=burger", null, null);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 3);
+ // with channel, from http
+ cs.setCookieStringFromHttp(uri, null, null, "hot=dog", null, channel);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 4);
+ cs.removeAll();
+
+ // test with third party cookies blocked
+ prefs.setIntPref("network.cookie.cookieBehavior", 1);
+ // without channel
+ cs.setCookieString(uri, null, "oh=hai", null);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 0);
+ // with channel
+ cs.setCookieString(uri, null, "can=has", channel);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 0);
+ // without channel, from http
+ cs.setCookieStringFromHttp(uri, null, null, "cheez=burger", null, null);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 0);
+ // with channel, from http
+ cs.setCookieStringFromHttp(uri, null, null, "hot=dog", null, channel);
+ do_check_eq(cs.countCookiesFromHost("foo.com"), 0);
+}
+
diff --git a/netwerk/cookie/public/nsICookiePermission.idl b/netwerk/cookie/public/nsICookiePermission.idl
index 86aaf5200ea..511af410ffe 100644
--- a/netwerk/cookie/public/nsICookiePermission.idl
+++ b/netwerk/cookie/public/nsICookiePermission.idl
@@ -19,6 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Daniel Witte