mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
61 lines
2.4 KiB
JavaScript
61 lines
2.4 KiB
JavaScript
// test third party persistence across sessions, for the cases:
|
|
// 1) network.cookie.thirdparty.sessionOnly = false
|
|
// 2) network.cookie.thirdparty.sessionOnly = true
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
|
|
function run_test() {
|
|
// Set up a profile.
|
|
let profile = do_get_profile();
|
|
|
|
var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
|
var cso = cs.QueryInterface(Ci.nsIObserver);
|
|
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);
|
|
|
|
// Create URIs and channels pointing to foo.com and bar.com.
|
|
// We will use these to put foo.com into first and third party contexts.
|
|
var spec1 = "http://foo.com/foo.html";
|
|
var spec2 = "http://bar.com/bar.html";
|
|
var uri1 = ios.newURI(spec1, null, null);
|
|
var uri2 = ios.newURI(spec2, null, null);
|
|
var channel1 = ios.newChannelFromURI(uri1);
|
|
var channel2 = ios.newChannelFromURI(uri2);
|
|
|
|
// Force the channel URI to be used when determining the originating URI of
|
|
// the channel.
|
|
var httpchannel1 = channel1.QueryInterface(Ci.nsIHttpChannelInternal);
|
|
var httpchannel2 = channel1.QueryInterface(Ci.nsIHttpChannelInternal);
|
|
httpchannel1.forceAllowThirdPartyCookie = true;
|
|
httpchannel2.forceAllowThirdPartyCookie = true;
|
|
|
|
// test with cookies enabled, and third party cookies persistent.
|
|
prefs.setIntPref("network.cookie.cookieBehavior", 0);
|
|
prefs.setBoolPref("network.cookie.thirdparty.sessionOnly", false);
|
|
do_set_cookies(uri1, channel2, false, [1, 2, 3, 4]);
|
|
do_set_cookies(uri2, channel1, true, [1, 2, 3, 4]);
|
|
|
|
// fake a profile change
|
|
do_reload_profile(profile, cso);
|
|
do_check_eq(cs.countCookiesFromHost(uri1.host), 4);
|
|
do_check_eq(cs.countCookiesFromHost(uri2.host), 0);
|
|
|
|
// cleanse them
|
|
do_reload_profile(profile, cso, "shutdown-cleanse");
|
|
do_check_eq(cs.countCookiesFromHost(uri1.host), 0);
|
|
do_check_eq(cs.countCookiesFromHost(uri2.host), 0);
|
|
|
|
// test with third party cookies for session only.
|
|
prefs.setBoolPref("network.cookie.thirdparty.sessionOnly", true);
|
|
do_set_cookies(uri1, channel2, false, [1, 2, 3, 4]);
|
|
do_set_cookies(uri2, channel1, true, [1, 2, 3, 4]);
|
|
|
|
// fake a profile change
|
|
do_reload_profile(profile, cso);
|
|
do_check_eq(cs.countCookiesFromHost(uri1.host), 0);
|
|
do_check_eq(cs.countCookiesFromHost(uri2.host), 0);
|
|
}
|
|
|