Skip to content

Commit

Permalink
WPT: Tentative test HTTP cache vs credentials.
Browse files Browse the repository at this point in the history
Add a test. Check whether the HTTP cache discriminate the credentialled
requests from the anonymous ones.

The expectations used are Firefox's behavior.
Chrome fail the test. Later, I would like to make Chrome to converge
toward Firefox and run a performance experiment.

whatwg/fetch issue:
whatwg/fetch#1253

Design doc:
https://docs.google.com/document/d/1lvbiy4n-GM5I56Ncw304sgvY5Td32R6KHitjRXvkZ6U/edit#

See:
https://github.com/web-platform-tests/wpt/pull/29867/checks?check_run_id=3222766321

Once:
#29612 (comment)
resolved, I am expecting:
┌────────────────────────────────────────────┬───────┬───────┬────────┐
│Test                                        │ Chrome│ Safari│ Firefox│
├────────────────────────────────────────────┼───────┼───────┼────────┤
│credentials.tentative.any.html              │ FAIL  │ Fail  │ PASS   │
├────────────────────────────────────────────┼───────┼───────┼────────┤
│credentials.tentative.any.serviceworker.html│ FAIL  │ FAIL  │ PASS   │
├────────────────────────────────────────────┼───────┼───────┼────────┤
│credentials.tentative.any.sharedworker.html │ FAIL  │ FAIL  │ PASS   │
├────────────────────────────────────────────┼───────┼───────┼────────┤
│credentials.tentative.any.worker.html       │ FAIL  │ FAIL  │ PASS   │
└────────────────────────────────────────────┴───────┴───────┴────────┘

Bug:1221529
Change-Id: I0537108f473f37f42eef7b4fa1079cd88d987b62
  • Loading branch information
ArthurSonzogni authored and chromium-wpt-export-bot committed Aug 3, 2021
1 parent f76ae81 commit 21ec8dc
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions fetch/http-cache/credentials.tentative.any.js
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 21ec8dc

Please sign in to comment.