-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DevTools backend support for cookie same-site redirect issue
Implements DevTools backend support to show an issue when cookies are blocked due to cross-site redirect chain context downgrades. This issue will only be shown when kCookieSameSiteConsidersRedirectChain is enabled. Bug: 1221316 Change-Id: I0a646953b2d4e82e8f98cf7f73ff17b7b6f81363 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4936302 Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Commit-Queue: Steven Bingler <bingler@chromium.org> Reviewed-by: Ken Buchanan <kenrb@chromium.org> Cr-Commit-Position: refs/heads/main@{#1211697}
- Loading branch information
sbingler
authored and
Chromium LUCI CQ
committed
Oct 18, 2023
1 parent
88f7523
commit 508be75
Showing
8 changed files
with
117 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
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
30 changes: 30 additions & 0 deletions
30
...sts/http/tests/inspector-protocol/issues/cross-site-redirect-chain-exclusion-expected.txt
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,30 @@ | ||
Verifies that after a cross-site redirect SameSite cookies file an Issue | ||
|
||
{ | ||
issue : { | ||
code : CookieIssue | ||
details : { | ||
cookieIssueDetails : { | ||
cookie : { | ||
domain : firstparty.test | ||
name : fooStrict | ||
path : / | ||
} | ||
cookieExclusionReasons : [ | ||
[0] : ExcludeSameSiteStrict | ||
] | ||
cookieUrl : https://firstparty.test:8443/inspector-protocol/resources/redirect-chain.html?end | ||
cookieWarningReasons : [ | ||
[0] : WarnCrossSiteRedirectDowngradeChangesInclusion | ||
] | ||
operation : ReadCookie | ||
request : { | ||
requestId : <string> | ||
url : https://firstparty.test:8443/inspector-protocol/resources/redirect-chain.html?end | ||
} | ||
siteForCookies : https://firstparty.test/ | ||
} | ||
} | ||
} | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
...ink/web_tests/http/tests/inspector-protocol/issues/cross-site-redirect-chain-exclusion.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,48 @@ | ||
(async testRunner => { | ||
// This test requires kCookieSameSiteConsidersRedirectChain to be enabled in order to pass. | ||
const {page, session, dp} = await testRunner.startBlank( | ||
`Verifies that after a cross-site redirect SameSite cookies file an Issue\n`); | ||
|
||
await dp.Network.enable(); | ||
await dp.Audits.enable(); | ||
|
||
// Set the cookie. | ||
const response = await dp.Network.setCookie({ | ||
url: 'https://firstparty.test:8443', | ||
secure: true, | ||
name: 'fooStrict', | ||
value: 'bar', | ||
sameSite: 'Strict', | ||
}); | ||
|
||
if (response.error) | ||
testRunner.log(`setCookie failed: ${response.error.message}`); | ||
|
||
// Push events to arrays to prevent async races from causing flakes. | ||
const requestWillBeSentExtraInfos = []; | ||
let issueAdded; | ||
|
||
const expectedRequests = | ||
new Promise(resolve => dp.Network.onRequestWillBeSentExtraInfo(event => { | ||
requestWillBeSentExtraInfos.push(event.params); | ||
// There will be the first navigation -> redirect -> final navigation == 3 | ||
if (requestWillBeSentExtraInfos.length === 3) { | ||
resolve(); | ||
} | ||
})); | ||
|
||
const expectedIssue = dp.Audits.onceIssueAdded(event => { | ||
// Safely ignore irrelevant issue... | ||
return event.params.issue.code !== 'QuirksModeIssue'; | ||
}); | ||
|
||
page.navigate( | ||
'https://firstparty.test:8443/inspector-protocol/resources/redirect-chain.html?start'); | ||
|
||
await expectedRequests; | ||
|
||
issueAdded = await expectedIssue; | ||
testRunner.log(issueAdded.params); | ||
|
||
testRunner.completeTest(); | ||
}); |
8 changes: 8 additions & 0 deletions
8
third_party/blink/web_tests/http/tests/inspector-protocol/resources/cross-site-redirect.php
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,8 @@ | ||
<?php | ||
// Redirects back to the first party site. | ||
header('HTTP/1.1 307 Temporary Redirect'); | ||
header('Expires: Thu, 01 Dec 2003 16:00:00 GMT'); | ||
header('Cache-Control: no-cache, must-revalidate'); | ||
header('Pragma: no-cache'); | ||
header('Location: https://firstparty.test:8443/inspector-protocol/resources/redirect-chain.html?end'); | ||
?> |
11 changes: 11 additions & 0 deletions
11
third_party/blink/web_tests/http/tests/inspector-protocol/resources/redirect-chain.html
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,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script> | ||
const urlParams = new URLSearchParams(window.location.search); | ||
if(urlParams.has("start")) { | ||
window.location = "https://example.test:8443/inspector-protocol/resources/cross-site-redirect.php" | ||
} | ||
</script> | ||
</body> | ||
</html> |