diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/test/unit/test_private_cookie_changed.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/test_private_cookie_changed.js')
-rw-r--r-- | netwerk/test/unit/test_private_cookie_changed.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_private_cookie_changed.js b/netwerk/test/unit/test_private_cookie_changed.js new file mode 100644 index 000000000..6c6f31de4 --- /dev/null +++ b/netwerk/test/unit/test_private_cookie_changed.js @@ -0,0 +1,34 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ +Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/NetUtil.jsm"); + +function makeChan(uri, isPrivate) { + var chan = NetUtil.newChannel ({ + uri: uri.spec, + loadUsingSystemPrincipal: true + }).QueryInterface(Components.interfaces.nsIHttpChannel); + + chan.QueryInterface(Ci.nsIPrivateBrowsingChannel).setPrivate(isPrivate); + return chan; +} + +function run_test() { + // Allow all cookies. + Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); + + let publicNotifications = 0; + let privateNotifications = 0; + Services.obs.addObserver(function() {publicNotifications++;}, "cookie-changed", false); + Services.obs.addObserver(function() {privateNotifications++;}, "private-cookie-changed", false); + + let uri = NetUtil.newURI("http://foo.com/"); + let publicChan = makeChan(uri, false); + let svc = Services.cookies.QueryInterface(Ci.nsICookieService); + svc.setCookieString(uri, null, "oh=hai", publicChan); + let privateChan = makeChan(uri, true); + svc.setCookieString(uri, null, "oh=hai", privateChan); + do_check_eq(publicNotifications, 1); + do_check_eq(privateNotifications, 1); +} |