Skip to content

Commit

Permalink
Add Initial Web Platform Tests for Storage Access Headers (#49502)
Browse files Browse the repository at this point in the history
This change adds web platform tests that confirm the inclusion of the
`Sec-Fetch-Storage-Access` header on cross-site navigations, and that confirm the browser properly handles responses which include the `Activate-Storage-Access` header.

Bug: 332335089
Change-Id: If453daea7b77292a6498f22b86a552a5a064b521
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5972601
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Chris Fredrickson <[email protected]>
Commit-Queue: Sam LeDoux <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1391183}

Co-authored-by: Sam LeDoux <[email protected]>
  • Loading branch information
chromium-wpt-export-bot and Sam LeDoux authored Dec 10, 2024
1 parent bc62de4 commit 6a03539
Show file tree
Hide file tree
Showing 67 changed files with 3,669 additions and 2 deletions.
26 changes: 26 additions & 0 deletions fetch/metadata/generated/audioworklet.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,32 @@
assert_not_own_property(headers, 'sec-fetch-user');
});
}, 'sec-fetch-user');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(key, ['httpsCrossSite'], {mime: 'text/javascript'}),
t
)
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Cross-site');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(key, ['httpsSameSite'], {mime: 'text/javascript'}),
t
)
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Same site');
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions fetch/metadata/generated/css-font-face.https.sub.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,26 @@
assert_not_own_property(headers, 'sec-fetch-user');
});
}, 'sec-fetch-user');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(t, makeRequestURL(key, ['httpsCrossSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Cross-site');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(t, makeRequestURL(key, ['httpsSameSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Same site');
</script>
</body>
</html>
30 changes: 30 additions & 0 deletions fetch/metadata/generated/css-font-face.sub.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,36 @@
});
}, 'sec-fetch-user - Not sent to non-trustworthy cross-site destination');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(t, makeRequestURL(key, ['httpOrigin']))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Not sent to non-trustworthy same-origin destination');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(t, makeRequestURL(key, ['httpSameSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Not sent to non-trustworthy same-site destination');

promise_test((t) => {
const key = '{{uuid()}}';

return induceRequest(t, makeRequestURL(key, ['httpCrossSite']))
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
});
}, 'sec-fetch-storage-access - Not sent to non-trustworthy cross-site destination');

promise_test((t) => {
const key = '{{uuid()}}';

Expand Down
145 changes: 145 additions & 0 deletions fetch/metadata/generated/css-images.https.sub.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,151 @@
.then(t.step_func_done(), t.unreached_func());
}, 'list-style-image sec-fetch-user');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsCrossSite']);

declarations.push(`background-image: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-storage-access');
assert_equals(headers['sec-fetch-storage-access'], 'none');
})
.then(t.step_func_done(), (error) => t.unreached_func());
}, 'background-image sec-fetch-storage-access - Cross-site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsCrossSite']);

declarations.push(`border-image: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-storage-access');
assert_array_equals(headers['sec-fetch-storage-access'], ['none']);
})
.then(t.step_func_done(), t.unreached_func());
}, 'border-image sec-fetch-storage-access - Cross-site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsCrossSite']);

declarations.push(`content: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-storage-access');
assert_array_equals(headers['sec-fetch-storage-access'], ['none']);
})
.then(t.step_func_done(), t.unreached_func());
}, 'content sec-fetch-storage-access - Cross-site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsCrossSite']);

declarations.push(`cursor: url("${url}"), auto;`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-storage-access');
assert_array_equals(headers['sec-fetch-storage-access'], ['none']);
})
.then(t.step_func_done(), t.unreached_func());
}, 'cursor sec-fetch-storage-access - Cross-site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsCrossSite']);

declarations.push(`list-style-image: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-storage-access');
assert_array_equals(headers['sec-fetch-storage-access'], ['none']);
})
.then(t.step_func_done(), t.unreached_func());
}, 'list-style-image sec-fetch-storage-access - Cross-site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsSameSite']);

declarations.push(`background-image: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
})
.then(t.step_func_done(), (error) => t.unreached_func());
}, 'background-image sec-fetch-storage-access - Same site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsSameSite']);

declarations.push(`border-image: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
})
.then(t.step_func_done(), t.unreached_func());
}, 'border-image sec-fetch-storage-access - Same site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsSameSite']);

declarations.push(`content: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
})
.then(t.step_func_done(), t.unreached_func());
}, 'content sec-fetch-storage-access - Same site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsSameSite']);

declarations.push(`cursor: url("${url}"), auto;`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
})
.then(t.step_func_done(), t.unreached_func());
}, 'cursor sec-fetch-storage-access - Same site');

async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, ['httpsSameSite']);

declarations.push(`list-style-image: url("${url}");`);

whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-storage-access');
})
.then(t.step_func_done(), t.unreached_func());
}, 'list-style-image sec-fetch-storage-access - Same site');

iframe.srcdoc = declarations.map((declaration, index) => `
<style>.el${index} { ${declaration} }</style><div class="el${index}"></div>`
).join('');
Expand Down
Loading

0 comments on commit 6a03539

Please sign in to comment.