forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1631676 - Part 1: add cookie behavior pref getter; r=baku
Differential Revision: https://phabricator.services.mozilla.com/D74049
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
toolkit/components/antitracking/test/xpcshell/test_cookie_behavior.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// Note: This test may cause intermittents if run at exactly midnight. | ||
|
||
"use strict"; | ||
|
||
const PREF_FPI = "privacy.firstparty.isolate"; | ||
const PREF_COOKIE_BEHAVIOR = "network.cookie.cookieBehavior"; | ||
|
||
registerCleanupFunction(() => { | ||
Services.prefs.clearUserPref(PREF_FPI); | ||
Services.prefs.clearUserPref(PREF_COOKIE_BEHAVIOR); | ||
}); | ||
|
||
add_task(function test_FPI_off() { | ||
Services.prefs.setBoolPref(PREF_FPI, false); | ||
|
||
for (let i = 0; i <= Ci.nsICookieService.BEHAVIOR_LAST; ++i) { | ||
Services.prefs.setIntPref(PREF_COOKIE_BEHAVIOR, i); | ||
equal(Services.prefs.getIntPref(PREF_COOKIE_BEHAVIOR), i); | ||
equal(Services.cookies.cookieBehavior, i); | ||
} | ||
}); | ||
|
||
add_task(function test_FPI_on() { | ||
Services.prefs.setBoolPref(PREF_FPI, true); | ||
|
||
for (let i = 0; i <= Ci.nsICookieService.BEHAVIOR_LAST; ++i) { | ||
Services.prefs.setIntPref(PREF_COOKIE_BEHAVIOR, i); | ||
equal(Services.prefs.getIntPref(PREF_COOKIE_BEHAVIOR), i); | ||
equal( | ||
Services.cookies.cookieBehavior, | ||
i == Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN | ||
? Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER | ||
: i | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters