Skip to content

Commit 04d44ba

Browse files
committed
Bug 1616570 - Part 1: Rename CookieSettings to CookieJarSettings. r=Ehsan
Given that we are going to add ContentBlockingAllowList in CookieSettings, so CookieSettings will be responsible for more stuff than the cookie behavior and cookie permission. We should use a proper name to reflect the purpose of it. The name 'CookieSettings' is misleading that this is only for cookie related stuff. So, we decide to rename 'CookieSettins' to 'CookieJarSettings' which serves better meaning here. Differential Revision: https://phabricator.services.mozilla.com/D63935 --HG-- rename : netwerk/cookie/CookieSettings.cpp => netwerk/cookie/CookieJarSettings.cpp rename : netwerk/cookie/nsICookieSettings.idl => netwerk/cookie/nsICookieJarSettings.idl extra : moz-landing-system : lando
1 parent d4bc188 commit 04d44ba

File tree

113 files changed

+723
-696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+723
-696
lines changed

browser/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ XPCOMUtils.defineLazyServiceGetter(
2121
function restore_prefs() {
2222
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
2323
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
24-
Services.prefs.clearUserPref("network.cookieSettings.unblocked_for_testing");
24+
Services.prefs.clearUserPref(
25+
"network.cookieJarSettings.unblocked_for_testing"
26+
);
2527
}
2628

2729
registerCleanupFunction(restore_prefs);
@@ -52,7 +54,7 @@ async function test_cookie_settings({
5254
thirdPartyCookiesEnabled,
5355
cookiesExpireAfterSession,
5456
rejectTrackers,
55-
cookieSettingsLocked,
57+
cookieJarSettingsLocked,
5658
}) {
5759
let firstPartyURI = NetUtil.newURI("http://example.com/");
5860
let thirdPartyURI = NetUtil.newURI("http://example.org/");
@@ -111,12 +113,12 @@ async function test_cookie_settings({
111113

112114
is(
113115
Services.prefs.prefIsLocked("network.cookie.cookieBehavior"),
114-
cookieSettingsLocked,
116+
cookieJarSettingsLocked,
115117
"Cookie behavior pref lock status should be what is expected"
116118
);
117119
is(
118120
Services.prefs.prefIsLocked("network.cookie.lifetimePolicy"),
119-
cookieSettingsLocked,
121+
cookieJarSettingsLocked,
120122
"Cookie lifetime pref lock status should be what is expected"
121123
);
122124

@@ -127,9 +129,9 @@ async function test_cookie_settings({
127129
await tab.linkedBrowser.contentWindow.gotoPref("panePrivacy");
128130
await SpecialPowers.spawn(
129131
tab.linkedBrowser,
130-
[{ cookiesEnabled, cookieSettingsLocked }],
132+
[{ cookiesEnabled, cookieJarSettingsLocked }],
131133
// eslint-disable-next-line no-shadow
132-
async function({ cookiesEnabled, cookieSettingsLocked }) {
134+
async function({ cookiesEnabled, cookieJarSettingsLocked }) {
133135
let deleteOnCloseCheckbox = content.document.getElementById(
134136
"deleteOnClose"
135137
);
@@ -139,7 +141,7 @@ async function test_cookie_settings({
139141
"deleteOnCloseCheckbox should not be null."
140142
);
141143

142-
let expectControlsDisabled = !cookiesEnabled || cookieSettingsLocked;
144+
let expectControlsDisabled = !cookiesEnabled || cookieJarSettingsLocked;
143145
is(
144146
deleteOnCloseCheckbox.disabled,
145147
expectControlsDisabled,
@@ -197,14 +199,14 @@ add_task(async function prepare_tracker_tables() {
197199

198200
add_task(async function test_initial_state() {
199201
Services.prefs.setBoolPref(
200-
"network.cookieSettings.unblocked_for_testing",
202+
"network.cookieJarSettings.unblocked_for_testing",
201203
true
202204
);
203205
await test_cookie_settings({
204206
cookiesEnabled: true,
205207
thirdPartyCookiesEnabled: true,
206208
cookiesExpireAfterSession: false,
207-
cookieSettingsLocked: false,
209+
cookieJarSettingsLocked: false,
208210
});
209211
restore_prefs();
210212
});
@@ -213,7 +215,7 @@ add_task(async function test_undefined_unlocked() {
213215
Services.prefs.setIntPref("network.cookie.cookieBehavior", 3);
214216
Services.prefs.setIntPref("network.cookie.lifetimePolicy", 2);
215217
Services.prefs.setBoolPref(
216-
"network.cookieSettings.unblocked_for_testing",
218+
"network.cookieJarSettings.unblocked_for_testing",
217219
true
218220
);
219221
await setupPolicyEngineWithJson({
@@ -236,7 +238,7 @@ add_task(async function test_undefined_unlocked() {
236238

237239
add_task(async function test_disabled() {
238240
Services.prefs.setBoolPref(
239-
"network.cookieSettings.unblocked_for_testing",
241+
"network.cookieJarSettings.unblocked_for_testing",
240242
true
241243
);
242244
await setupPolicyEngineWithJson({
@@ -251,14 +253,14 @@ add_task(async function test_disabled() {
251253
cookiesEnabled: false,
252254
thirdPartyCookiesEnabled: true,
253255
cookiesExpireAfterSession: false,
254-
cookieSettingsLocked: false,
256+
cookieJarSettingsLocked: false,
255257
});
256258
restore_prefs();
257259
});
258260

259261
add_task(async function test_third_party_disabled() {
260262
Services.prefs.setBoolPref(
261-
"network.cookieSettings.unblocked_for_testing",
263+
"network.cookieJarSettings.unblocked_for_testing",
262264
true
263265
);
264266
await setupPolicyEngineWithJson({
@@ -273,14 +275,14 @@ add_task(async function test_third_party_disabled() {
273275
cookiesEnabled: true,
274276
thirdPartyCookiesEnabled: false,
275277
cookiesExpireAfterSession: false,
276-
cookieSettingsLocked: false,
278+
cookieJarSettingsLocked: false,
277279
});
278280
restore_prefs();
279281
});
280282

281283
add_task(async function test_disabled_and_third_party_disabled() {
282284
Services.prefs.setBoolPref(
283-
"network.cookieSettings.unblocked_for_testing",
285+
"network.cookieJarSettings.unblocked_for_testing",
284286
true
285287
);
286288
await setupPolicyEngineWithJson({
@@ -296,14 +298,14 @@ add_task(async function test_disabled_and_third_party_disabled() {
296298
cookiesEnabled: false,
297299
thirdPartyCookiesEnabled: false,
298300
cookiesExpireAfterSession: false,
299-
cookieSettingsLocked: false,
301+
cookieJarSettingsLocked: false,
300302
});
301303
restore_prefs();
302304
});
303305

304306
add_task(async function test_disabled_and_third_party_disabled_locked() {
305307
Services.prefs.setBoolPref(
306-
"network.cookieSettings.unblocked_for_testing",
308+
"network.cookieJarSettings.unblocked_for_testing",
307309
true
308310
);
309311
await setupPolicyEngineWithJson({
@@ -320,14 +322,14 @@ add_task(async function test_disabled_and_third_party_disabled_locked() {
320322
cookiesEnabled: false,
321323
thirdPartyCookiesEnabled: false,
322324
cookiesExpireAfterSession: false,
323-
cookieSettingsLocked: true,
325+
cookieJarSettingsLocked: true,
324326
});
325327
restore_prefs();
326328
});
327329

328330
add_task(async function test_undefined_locked() {
329331
Services.prefs.setBoolPref(
330-
"network.cookieSettings.unblocked_for_testing",
332+
"network.cookieJarSettings.unblocked_for_testing",
331333
true
332334
);
333335
await setupPolicyEngineWithJson({
@@ -342,14 +344,14 @@ add_task(async function test_undefined_locked() {
342344
cookiesEnabled: true,
343345
thirdPartyCookiesEnabled: true,
344346
cookiesExpireAfterSession: false,
345-
cookieSettingsLocked: true,
347+
cookieJarSettingsLocked: true,
346348
});
347349
restore_prefs();
348350
});
349351

350352
add_task(async function test_cookie_expire() {
351353
Services.prefs.setBoolPref(
352-
"network.cookieSettings.unblocked_for_testing",
354+
"network.cookieJarSettings.unblocked_for_testing",
353355
true
354356
);
355357
await setupPolicyEngineWithJson({
@@ -364,14 +366,14 @@ add_task(async function test_cookie_expire() {
364366
cookiesEnabled: true,
365367
thirdPartyCookiesEnabled: true,
366368
cookiesExpireAfterSession: true,
367-
cookieSettingsLocked: false,
369+
cookieJarSettingsLocked: false,
368370
});
369371
restore_prefs();
370372
});
371373

372374
add_task(async function test_cookie_reject_trackers() {
373375
Services.prefs.setBoolPref(
374-
"network.cookieSettings.unblocked_for_testing",
376+
"network.cookieJarSettings.unblocked_for_testing",
375377
true
376378
);
377379
await setupPolicyEngineWithJson({
@@ -387,14 +389,14 @@ add_task(async function test_cookie_reject_trackers() {
387389
thirdPartyCookiesEnabled: true,
388390
cookiesExpireAfterSession: false,
389391
rejectTrackers: true,
390-
cookieSettingsLocked: false,
392+
cookieJarSettingsLocked: false,
391393
});
392394
restore_prefs();
393395
});
394396

395397
add_task(async function test_cookie_expire_locked() {
396398
Services.prefs.setBoolPref(
397-
"network.cookieSettings.unblocked_for_testing",
399+
"network.cookieJarSettings.unblocked_for_testing",
398400
true
399401
);
400402
await setupPolicyEngineWithJson({
@@ -410,14 +412,14 @@ add_task(async function test_cookie_expire_locked() {
410412
cookiesEnabled: true,
411413
thirdPartyCookiesEnabled: true,
412414
cookiesExpireAfterSession: true,
413-
cookieSettingsLocked: true,
415+
cookieJarSettingsLocked: true,
414416
});
415417
restore_prefs();
416418
});
417419

418420
add_task(async function test_disabled_cookie_expire_locked() {
419421
Services.prefs.setBoolPref(
420-
"network.cookieSettings.unblocked_for_testing",
422+
"network.cookieJarSettings.unblocked_for_testing",
421423
true
422424
);
423425
await setupPolicyEngineWithJson({
@@ -435,7 +437,7 @@ add_task(async function test_disabled_cookie_expire_locked() {
435437
cookiesEnabled: false,
436438
thirdPartyCookiesEnabled: false,
437439
cookiesExpireAfterSession: true,
438-
cookieSettingsLocked: true,
440+
cookieJarSettingsLocked: true,
439441
});
440442
restore_prefs();
441443
});

dom/base/Document.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
#include "mozilla/dom/StyleSheetList.h"
126126
#include "mozilla/dom/SVGUseElement.h"
127127
#include "mozilla/dom/UserActivation.h"
128-
#include "mozilla/net/CookieSettings.h"
128+
#include "mozilla/net/CookieJarSettings.h"
129129
#include "nsGenericHTMLElement.h"
130130
#include "mozilla/dom/CDATASection.h"
131131
#include "mozilla/dom/ProcessingInstruction.h"
@@ -3211,7 +3211,7 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
32113211
rv = InitFeaturePolicy(aChannel);
32123212
NS_ENSURE_SUCCESS(rv, rv);
32133213

3214-
rv = loadInfo->GetCookieSettings(getter_AddRefs(mCookieSettings));
3214+
rv = loadInfo->GetCookieJarSettings(getter_AddRefs(mCookieJarSettings));
32153215
NS_ENSURE_SUCCESS(rv, rv);
32163216

32173217
return NS_OK;
@@ -5680,7 +5680,7 @@ void Document::GetCookie(nsAString& aCookie, ErrorResult& rv) {
56805680
}
56815681

56825682
if (ShouldPartitionStorage(storageAccess) &&
5683-
!StoragePartitioningEnabled(storageAccess, CookieSettings())) {
5683+
!StoragePartitioningEnabled(storageAccess, CookieJarSettings())) {
56845684
return;
56855685
}
56865686

@@ -5739,7 +5739,7 @@ void Document::SetCookie(const nsAString& aCookie, ErrorResult& rv) {
57395739
}
57405740

57415741
if (ShouldPartitionStorage(storageAccess) &&
5742-
!StoragePartitioningEnabled(storageAccess, CookieSettings())) {
5742+
!StoragePartitioningEnabled(storageAccess, CookieJarSettings())) {
57435743
return;
57445744
}
57455745

@@ -14999,7 +14999,7 @@ DocumentAutoplayPolicy Document::AutoplayPolicy() const {
1499914999
}
1500015000

1500115001
void Document::MaybeAllowStorageForOpenerAfterUserInteraction() {
15002-
if (!CookieSettings()->GetRejectThirdPartyTrackers()) {
15002+
if (!CookieJarSettings()->GetRejectThirdPartyTrackers()) {
1500315003
return;
1500415004
}
1500515005

@@ -15567,7 +15567,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
1556715567
}
1556815568

1556915569
// Only enforce third-party checks when there is a reason to enforce them.
15570-
if (!CookieSettings()->GetRejectThirdPartyTrackers()) {
15570+
if (!CookieJarSettings()->GetRejectThirdPartyTrackers()) {
1557115571
// Step 3. If the document's frame is the main frame, resolve.
1557215572
if (IsTopLevelContentDocument()) {
1557315573
promise->MaybeResolveWithUndefined();
@@ -15612,7 +15612,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
1561215612
// user settings, anti-clickjacking heuristics, or prompting the
1561315613
// user for explicit permission. Reject if some rule is not fulfilled.
1561415614

15615-
if (CookieSettings()->GetRejectThirdPartyTrackers()) {
15615+
if (CookieJarSettings()->GetRejectThirdPartyTrackers()) {
1561615616
// Only do something special for third-party tracking content.
1561715617
if (StorageDisabledByAntiTracking(this, nullptr)) {
1561815618
// Note: If this has returned true, the top-level document is guaranteed
@@ -16006,20 +16006,20 @@ void Document::RecomputeLanguageFromCharset() {
1600616006
mLanguageFromCharset = std::move(language);
1600716007
}
1600816008

16009-
nsICookieSettings* Document::CookieSettings() {
16009+
nsICookieJarSettings* Document::CookieJarSettings() {
1601016010
// If we are here, this is probably a javascript: URL document. In any case,
16011-
// we must have a nsCookieSettings. Let's create it.
16012-
if (!mCookieSettings) {
16011+
// we must have a nsCookieJarSettings. Let's create it.
16012+
if (!mCookieJarSettings) {
1601316013
Document* inProcessParent = GetInProcessParentDocument();
1601416014

16015-
mCookieSettings =
16015+
mCookieJarSettings =
1601616016
inProcessParent
16017-
? net::CookieSettings::Create(
16018-
inProcessParent->CookieSettings()->GetCookieBehavior())
16019-
: net::CookieSettings::Create();
16017+
? net::CookieJarSettings::Create(
16018+
inProcessParent->CookieJarSettings()->GetCookieBehavior())
16019+
: net::CookieJarSettings::Create();
1602016020
}
1602116021

16022-
return mCookieSettings;
16022+
return mCookieJarSettings;
1602316023
}
1602416024

1602516025
nsIPrincipal* Document::EffectiveStoragePrincipal() const {
@@ -16046,7 +16046,7 @@ nsIPrincipal* Document::EffectiveStoragePrincipal() const {
1604616046
// normal principal will be used.
1604716047
if (ShouldPartitionStorage(rejectedReason) &&
1604816048
!StoragePartitioningEnabled(
16049-
rejectedReason, const_cast<Document*>(this)->CookieSettings())) {
16049+
rejectedReason, const_cast<Document*>(this)->CookieJarSettings())) {
1605016050
return mActiveStoragePrincipal = NodePrincipal();
1605116051
}
1605216052

dom/base/Document.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "nsCOMArray.h" // for member
1616
#include "nsCompatibility.h" // for member
1717
#include "nsCOMPtr.h" // for member
18-
#include "nsICookieSettings.h"
18+
#include "nsICookieJarSettings.h"
1919
#include "nsGkAtoms.h" // for static class members
2020
#include "nsNameSpaceManager.h" // for static class members
2121
#include "nsIApplicationCache.h"
@@ -1425,8 +1425,8 @@ class Document : public nsINode,
14251425
// flag.
14261426
bool StorageAccessSandboxed() const;
14271427

1428-
// Returns the cookie settings for this and sub contexts.
1429-
nsICookieSettings* CookieSettings();
1428+
// Returns the cookie jar settings for this and sub contexts.
1429+
nsICookieJarSettings* CookieJarSettings();
14301430

14311431
// Increments the document generation.
14321432
inline void Changed() { ++mGeneration; }
@@ -5054,7 +5054,7 @@ class Document : public nsINode,
50545054

50555055
bool mPendingInitialTranslation;
50565056

5057-
nsCOMPtr<nsICookieSettings> mCookieSettings;
5057+
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
50585058

50595059
// Document generation. Gets incremented everytime it changes.
50605060
int32_t mGeneration;

0 commit comments

Comments
 (0)