Skip to content

Commit

Permalink
Bug 1723558 [wpt PR 29867] - WPT: Tentative test HTTP cache vs creden…
Browse files Browse the repository at this point in the history
…tials., a=testonly

Automatic update from web-platform-tests
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 <morlovich@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#909780}

--

wpt-commits: 7d357243857d2ae0383120c22d43cd1b1b6fc371
wpt-pr: 29867
  • Loading branch information
ArthurSonzogni authored and moz-wptsync-bot committed Aug 14, 2021
1 parent 1010ae5 commit cc9a9ea
Showing 1 changed file with 62 additions and 0 deletions.
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);

0 comments on commit cc9a9ea

Please sign in to comment.