[devtools] Add 'SameParty' cookie attribute to Network.Cookie type
As part of the "First Party Sets" privacy effort, cookies get a new
boolean attribute 'SameParty'. The attribute works similarly as
'SameSite' and allows cookies to be sent in same-party, cross-site
contexts.
This CL adds the attribute to the DevTools protocol, so it can be
shown in the various Cookie tables in the DevTools frontend.
R=caseq@chromium.org
Bug: chromium:1161427
Change-Id: Ica094fcc3acc38e8fb36cada40c198c41ca82262
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598846
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841959}
diff --git a/content/browser/devtools/protocol/network_handler.cc b/content/browser/devtools/protocol/network_handler.cc
index 7a729b9..2e0dd90 100644
--- a/content/browser/devtools/protocol/network_handler.cc
+++ b/content/browser/devtools/protocol/network_handler.cc
@@ -155,6 +155,7 @@
.SetSecure(cookie.IsSecure())
.SetSession(!cookie.IsPersistent())
.SetPriority(cp)
+ .SetSameParty(cookie.IsSameParty())
.Build();
switch (cookie.SameSite()) {
diff --git a/third_party/blink/public/devtools_protocol/browser_protocol.pdl b/third_party/blink/public/devtools_protocol/browser_protocol.pdl
index dbbad849..af1c31a5 100644
--- a/third_party/blink/public/devtools_protocol/browser_protocol.pdl
+++ b/third_party/blink/public/devtools_protocol/browser_protocol.pdl
@@ -4749,6 +4749,8 @@
optional CookieSameSite sameSite
# Cookie Priority
experimental CookiePriority priority
+ # True if cookie is SameParty.
+ experimental boolean sameParty
# Types of reasons why a cookie may not be stored from a response.
experimental type SetCookieBlockedReason extends string
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-domain-mismatch-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-domain-mismatch-expected.txt
index 55f29b1..41bc4ee 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-domain-mismatch-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-domain-mismatch-expected.txt
@@ -12,6 +12,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : false
session : true
size : 9
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-not-on-path-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-not-on-path-expected.txt
index 9f5bbeee..5e0f94b28 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-not-on-path-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-not-on-path-expected.txt
@@ -12,6 +12,7 @@
name : name
path : /inspector-protocol/network/resources/set-cookie.php
priority : Medium
+ sameParty : false
secure : false
session : true
size : 9
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-lax-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-lax-expected.txt
index 1e30fae..4c6f2c6 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-lax-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-lax-expected.txt
@@ -11,6 +11,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Lax
secure : false
session : true
@@ -30,6 +31,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Lax
secure : false
session : true
@@ -50,6 +52,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Lax
secure : false
session : true
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-strict-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-strict-expected.txt
index 46209a6b..ef9d7c1 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-strict-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-same-site-strict-expected.txt
@@ -11,6 +11,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Strict
secure : false
session : true
@@ -31,6 +32,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Strict
secure : false
session : true
@@ -51,6 +53,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Strict
secure : false
session : true
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-secure-only-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-secure-only-expected.txt
index 1be6a37..99fcb01 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-secure-only-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-cookie-secure-only-expected.txt
@@ -12,6 +12,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : true
session : true
size : 9
@@ -32,6 +33,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : true
session : true
size : 9
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-multiple-reasons-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-multiple-reasons-expected.txt
index 87306866..24724bfd 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-multiple-reasons-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-multiple-reasons-expected.txt
@@ -12,6 +12,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : true
session : true
size : 9
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-overwrite-secure-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-overwrite-secure-expected.txt
index 96abb98d..37a1b08 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-overwrite-secure-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-overwrite-secure-expected.txt
@@ -11,6 +11,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : false
session : true
size : 9
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-lax-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-lax-expected.txt
index 91b798c..386dabe9 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-lax-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-lax-expected.txt
@@ -12,6 +12,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Lax
secure : false
session : true
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-strict-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-strict-expected.txt
index 5ce0fd37..cb06cf0 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-strict-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/blocked-setcookie-same-site-strict-expected.txt
@@ -12,6 +12,7 @@
name : name
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : Strict
secure : false
session : true
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-expected.txt
index 784cf5eb0..92826cf 100644
--- a/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-expected.txt
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-expected.txt
@@ -11,6 +11,7 @@
name : name1
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : None
secure : true
session : true
@@ -28,6 +29,7 @@
name : name2
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : false
session : true
size : 11
@@ -47,6 +49,7 @@
name : name2
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
secure : false
session : true
size : 11
@@ -63,6 +66,7 @@
name : name1
path : /inspector-protocol/network/resources
priority : Medium
+ sameParty : false
sameSite : None
secure : true
session : true
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-same-party-expected.txt b/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-same-party-expected.txt
new file mode 100644
index 0000000..979e9fec
--- /dev/null
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-same-party-expected.txt
@@ -0,0 +1,22 @@
+Verifies that Network.RequestWillBeSentExtraInfo events report structured request cookies with the correct SameParty attribute.
+
+requestWillBeSentExtraInfo request cookies on same domain:[
+ [0] : {
+ blockedReasons : [
+ ]
+ cookie : {
+ domain : .cookie.test
+ expires : -1
+ httpOnly : false
+ name : name1
+ path : /inspector-protocol/network/resources
+ priority : Medium
+ sameParty : true
+ secure : true
+ session : true
+ size : 11
+ value : value1
+ }
+ }
+]
+
diff --git a/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-same-party.js b/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-same-party.js
new file mode 100644
index 0000000..8c0bf4c8
--- /dev/null
+++ b/third_party/blink/web_tests/http/tests/inspector-protocol/network/extra-info-request-cookies-same-party.js
@@ -0,0 +1,18 @@
+(async function(testRunner) {
+ const {page, session, dp} = await testRunner.startBlank(
+ `Verifies that Network.RequestWillBeSentExtraInfo events report structured request cookies with the correct SameParty attribute.\n`);
+ await dp.Network.enable();
+ const helper = (await testRunner.loadScript('resources/extra-info-helper.js'))(dp, session);
+
+ const setCookieUrl = 'https://cookie.test:8443/inspector-protocol/network/resources/set-cookie.php?cookie='
+ + encodeURIComponent('name1=value1;SameParty;Secure;Domain=cookie.test');
+
+ // Set cookies in a domain.
+ await helper.navigateWithExtraInfo(setCookieUrl);
+
+ // Navigate to a the same domain to see that the cookie is reported.
+ const sendCookieUrl = 'https://cookie.test:8443/inspector-protocol/network/resources/hello-world.html';
+ const response = await helper.navigateWithExtraInfo(sendCookieUrl);
+ testRunner.log(response.requestExtraInfo.params.associatedCookies, 'requestWillBeSentExtraInfo request cookies on same domain:');
+ testRunner.completeTest();
+})