-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WPT: Tentative test HTTP cache vs credentials.
Add a test. Check whether the HTTP cache discriminate the credentialled requests from the anonymous ones. The expectations used are the ones from the specification. That's also Firefox's behavior. Chrome fails the test. Safari fail similarly + do not support SharedWorker. At some point, we would like to make Chrome to converge with the spec, or update with the specification. whatwg/fetch issue: whatwg/fetch#307 whatwg/fetch#1253 Design doc: https://docs.google.com/document/d/1lvbiy4n-GM5I56Ncw304sgvY5Td32R6KHitjRXvkZ6U/edit# Test results: https://github.com/web-platform-tests/wpt/pull/29867/checks?check_run_id=3279839968 ``` ┌────────────────────────────────────────────┬───────┬───────┬────────┐ │Test │ Chrome│ Safari│ Firefox│ ├────────────────────────────────────────────┼───────┼───────┼────────┤ │credentials.tentative.any.html │ 1/3 │ 1/3 │ 3/3 │ ├────────────────────────────────────────────┼───────┼───────┼────────┤ │credentials.tentative.any.serviceworker.html│ 1/3 │ 1/3 │ 3/3 │ ├────────────────────────────────────────────┼───────┼───────┼────────┤ │credentials.tentative.any.sharedworker.html │ 1/3 │ 0/3 │ 3/3 │ ├────────────────────────────────────────────┼───────┼───────┼────────┤ │credentials.tentative.any.worker.html │ 1/3 │ 1/3 │ 3/3 │ └────────────────────────────────────────────┴───────┴───────┴────────┘ ``` Bug: 1221529 Change-Id: I0537108f473f37f42eef7b4fa1079cd88d987b62 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3066251 Reviewed-by: Maksim Orlovich <[email protected]> Commit-Queue: Arthur Sonzogni <[email protected]> Cr-Commit-Position: refs/heads/master@{#909780} NOKEYCHECK=True GitOrigin-RevId: de5fcb86dc21f385e370d07dc9720c8e7a868388
- Loading branch information
1 parent
b20cf60
commit 3cbc20a
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
blink/web_tests/external/wpt/fetch/http-cache/credentials.tentative.any-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,5 @@ | ||
This is a testharness.js-based test. | ||
FAIL same-origin: 2xAnonymous, 2xCredentialled, 1xAnonymous assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
FAIL same-origin: 2xCredentialled, 2xAnonymous, 1xCredentialled assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
Harness: the test ran to completion. | ||
|
62 changes: 62 additions & 0 deletions
62
blink/web_tests/external/wpt/fetch/http-cache/credentials.tentative.any.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,62 @@ | ||
// META: global=window,worker | ||
// META: title=HTTP Cache - Content | ||
// META: timeout=long | ||
// META: script=/common/utils.js | ||
// META: script=http-cache.js | ||
|
||
// This is a tentative test. | ||
// Firefox behavior is used as expectations. | ||
// | ||
// whatwg/fetch issue: | ||
// https://github.com/whatwg/fetch/issues/1253 | ||
// | ||
// Chrome design doc: | ||
// https://docs.google.com/document/d/1lvbiy4n-GM5I56Ncw304sgvY5Td32R6KHitjRXvkZ6U/edit# | ||
|
||
const request_cacheable = { | ||
request_headers: [], | ||
response_headers: [ | ||
['Cache-Control', 'max-age=3600'], | ||
], | ||
// TODO(arthursonzogni): The behavior is tested only for same-origin requests. | ||
// It must behave similarly for cross-site and cross-origin requests. The | ||
// problems is the http-cache.js infrastructure returns the | ||
// "Server-Request-Count" as HTTP response headers, which aren't readable for | ||
// CORS requests. | ||
base_url: location.href.replace(/\/[^\/]*$/, '/'), | ||
}; | ||
|
||
const request_credentialled = { ...request_cacheable, credentials: 'include', }; | ||
const request_anonymous = { ...request_cacheable, credentials: 'omit', }; | ||
|
||
const responseIndex = count => { | ||
return { | ||
expected_response_headers: [ | ||
['Server-Request-Count', count.toString()], | ||
], | ||
} | ||
}; | ||
|
||
var tests = [ | ||
{ | ||
name: 'same-origin: 2xAnonymous, 2xCredentialled, 1xAnonymous', | ||
requests: [ | ||
{ ...request_anonymous , ...responseIndex(1)} , | ||
{ ...request_anonymous , ...responseIndex(1)} , | ||
{ ...request_credentialled , ...responseIndex(2)} , | ||
{ ...request_credentialled , ...responseIndex(2)} , | ||
{ ...request_anonymous , ...responseIndex(1)} , | ||
] | ||
}, | ||
{ | ||
name: 'same-origin: 2xCredentialled, 2xAnonymous, 1xCredentialled', | ||
requests: [ | ||
{ ...request_credentialled , ...responseIndex(1)} , | ||
{ ...request_credentialled , ...responseIndex(1)} , | ||
{ ...request_anonymous , ...responseIndex(2)} , | ||
{ ...request_anonymous , ...responseIndex(2)} , | ||
{ ...request_credentialled , ...responseIndex(1)} , | ||
] | ||
}, | ||
]; | ||
run_tests(tests); |
5 changes: 5 additions & 0 deletions
5
..._tests/external/wpt/fetch/http-cache/credentials.tentative.any.serviceworker-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,5 @@ | ||
This is a testharness.js-based test. | ||
FAIL same-origin: 2xAnonymous, 2xCredentialled, 1xAnonymous assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
FAIL same-origin: 2xCredentialled, 2xAnonymous, 1xCredentialled assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
Harness: the test ran to completion. | ||
|
5 changes: 5 additions & 0 deletions
5
...b_tests/external/wpt/fetch/http-cache/credentials.tentative.any.sharedworker-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,5 @@ | ||
This is a testharness.js-based test. | ||
FAIL same-origin: 2xAnonymous, 2xCredentialled, 1xAnonymous assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
FAIL same-origin: 2xCredentialled, 2xAnonymous, 1xCredentialled assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
Harness: the test ran to completion. | ||
|
5 changes: 5 additions & 0 deletions
5
blink/web_tests/external/wpt/fetch/http-cache/credentials.tentative.any.worker-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,5 @@ | ||
This is a testharness.js-based test. | ||
FAIL same-origin: 2xAnonymous, 2xCredentialled, 1xAnonymous assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
FAIL same-origin: 2xCredentialled, 2xAnonymous, 1xCredentialled assert_equals: Response 3 header Server-Request-Count is "1", not "2" expected "2" but got "1" | ||
Harness: the test ran to completion. | ||
|