Bug 1645896 - Add a console log origins that have their cookies partitioned by dFPI. r=timhuang

Differential Revision: https://phabricator.services.mozilla.com/D80675
This commit is contained in:
Nihanth Subramanya 2020-06-24 10:11:45 +00:00
Родитель a9516ee4f5
Коммит 6be693b933
7 изменённых файлов: 54 добавлений и 1 удалений

Просмотреть файл

@ -152,6 +152,7 @@ support-files =
test-syntaxerror-worklet.js
test-time-methods.html
test-trackingprotection-securityerrors.html
test-trackingprotection-securityerrors-thirdpartyonly.html
test-warning-groups.html
test-websocket.html
test-websocket.js

Просмотреть файл

@ -9,11 +9,18 @@ requestLongerTimeout(2);
const TEST_PATH = "browser/devtools/client/webconsole/test/browser/";
const TEST_FILE = TEST_PATH + "test-trackingprotection-securityerrors.html";
const TEST_FILE_THIRD_PARTY_ONLY =
TEST_PATH + "test-trackingprotection-securityerrors-thirdpartyonly.html";
const TEST_URI = "http://example.com/" + TEST_FILE;
const TEST_URI_THIRD_PARTY_ONLY =
"http://example.com/" + TEST_FILE_THIRD_PARTY_ONLY;
const TRACKER_URL = "http://tracking.example.org/";
const THIRD_PARTY_URL = "http://example.org/";
const BLOCKED_URL = `\u201c${TRACKER_URL +
TEST_PATH +
"cookieSetter.html"}\u201d`;
const PARTITIONED_URL = `\u201c${THIRD_PARTY_URL +
TEST_PATH}cookieSetter.html\u201d`;
const COOKIE_BEHAVIOR_PREF = "network.cookie.cookieBehavior";
const COOKIE_BEHAVIORS = {
@ -25,6 +32,8 @@ const COOKIE_BEHAVIORS = {
LIMIT_FOREIGN: 3,
// reject trackers
REJECT_TRACKER: 4,
// dFPI - partitioned access to third-party cookies
PARTITION_FOREIGN: 5,
};
const { UrlClassifierTestUtils } = ChromeUtils.import(
@ -158,6 +167,26 @@ add_task(async function testTrackerCookieBlockedMessage() {
win.close();
});
add_task(async function testForeignCookiePartitionedMessage() {
info("Test tracker cookie blocked message");
// We change the pref and open a new window to ensure it will be taken into account.
await pushPref(COOKIE_BEHAVIOR_PREF, COOKIE_BEHAVIORS.PARTITION_FOREIGN);
const { hud, win } = await openNewWindowAndConsole(TEST_URI_THIRD_PARTY_ONLY);
const message = await waitFor(() =>
findMessage(
hud,
`Partitioned cookie or storage access was provided to ${PARTITIONED_URL} because it is ` +
`loaded in the third-party context and storage partitioning is enabled.`
)
);
await testLearnMoreClickOpenNewTab(
message,
getStorageErrorUrl("CookiePartitionedForeign")
);
win.close();
});
add_task(async function testCookieBlockedByPermissionMessage() {
info("Test cookie blocked by permission message");
// Turn off tracking protection and add a block permission on the URL.

Просмотреть файл

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<!-- 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/. -->
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf8">
</head>
<body>
<iframe src="http://example.org/browser/devtools/client/webconsole/test/browser/cookieSetter.html"></iframe>
</body>
</html>

Просмотреть файл

@ -681,7 +681,8 @@ function isContentBlockingMessage(message) {
category == "cookieBlockedPermission" ||
category == "cookieBlockedTracker" ||
category == "cookieBlockedAll" ||
category == "cookieBlockedForeign"
category == "cookieBlockedForeign" ||
category == "cookiePartitionedForeign"
);
}

Просмотреть файл

@ -159,6 +159,7 @@ const StorageAccessPolicyErrorDocs = {
cookieBlockedTracker: "CookieBlockedTracker",
cookieBlockedAll: "CookieBlockedAll",
cookieBlockedForeign: "CookieBlockedForeign",
cookiePartitionedForeign: "CookiePartitionedForeign",
};
exports.GetURL = error => {

Просмотреть файл

@ -37,6 +37,10 @@ CookieBlockedByPermission=Request to access cookies or storage on “%1$S” was
CookieBlockedTracker=Request to access cookie or storage on “%1$S” was blocked because it came from a tracker and content blocking is enabled.
CookieBlockedAll=Request to access cookie or storage on “%1$S” was blocked because we are blocking all storage access requests.
CookieBlockedForeign=Request to access cookie or storage on “%1$S” was blocked because we are blocking all third-party storage access requests and content blocking is enabled.
# As part of dynamic first-party isolation, third-party resources might be limited to "partitioned" storage access that is separate from the first-party context.
# This allows e.g. cookies to still be set, and prevents tracking without totally blocking storage access. This message is shown in the web console when this happens
# to inform developers that their storage is isolated.
CookiePartitionedForeign=Partitioned cookie or storage access was provided to “%1$S” because it is loaded in the third-party context and storage partitioning is enabled.
# LOCALIZATION NOTE (CookieAllowedForOriginByStorageAccessAPI): %2$S and %1$S are URLs.
CookieAllowedForOriginByStorageAccessAPI=Storage access granted for origin “%2$S” on “%1$S”.

Просмотреть файл

@ -161,6 +161,11 @@ void ReportBlockingToConsole(uint64_t aWindowID, nsIURI* aURI,
category = NS_LITERAL_CSTRING("cookieBlockedForeign");
break;
case nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN:
message = "CookiePartitionedForeign";
category = NS_LITERAL_CSTRING("cookiePartitionedForeign");
break;
default:
return;
}