Skip to content

Commit ac0502f

Browse files
Uzlopakgithub-actions[bot]
authored andcommitted
chore: update WPT
1 parent b7513d4 commit ac0502f

File tree

4 files changed

+96
-7
lines changed

4 files changed

+96
-7
lines changed

test/fixtures/wpt/common/get-host-info.sub.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function get_host_info() {
2020
var REMOTE_HOST = (ORIGINAL_HOST === 'localhost') ? '127.0.0.1' : ('www1.' + ORIGINAL_HOST);
2121
var OTHER_HOST = '{{domains[www2]}}';
2222
var NOTSAMESITE_HOST = (ORIGINAL_HOST === 'localhost') ? '127.0.0.1' : ('{{hosts[alt][]}}');
23+
var OTHER_NOTSAMESITE_HOST = '{{hosts[alt][www2]}}';
2324

2425
return {
2526
HTTP_PORT: HTTP_PORT,
@@ -45,6 +46,7 @@ function get_host_info() {
4546
HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + HTTPS_PORT_ELIDED,
4647
HTTPS_REMOTE_ORIGIN_WITH_CREDS: 'https://foo:bar@' + REMOTE_HOST + HTTPS_PORT_ELIDED,
4748
HTTPS_NOTSAMESITE_ORIGIN: 'https://' + NOTSAMESITE_HOST + HTTPS_PORT_ELIDED,
49+
HTTPS_OTHER_NOTSAMESITE_ORIGIN: 'https://' + OTHER_NOTSAMESITE_HOST + HTTPS_PORT_ELIDED,
4850
UNAUTHENTICATED_ORIGIN: 'http://' + OTHER_HOST + HTTP_PORT_ELIDED,
4951
AUTHENTICATED_ORIGIN: 'https://' + OTHER_HOST + HTTPS_PORT_ELIDED
5052
};

test/fixtures/wpt/fetch/local-network-access/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ the Fetch specification.
55

66
See also:
77

8-
* [Explainer](https://github.com/explainers-by-googlers/local-network-access)
8+
* [Spec](https://wicg.github.io/local-network-access/)
99

1010
Local Network Access replaced [Private Network
11-
Access](https://wicg.github.io/local-network-access/).
11+
Access](https://wicg.github.io/private-network-access/).

test/fixtures/wpt/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
<body>
99
<script>
10+
// Helper function to obtain cache usage data for this test window.
1011
const usageDetails = async () =>
1112
(await navigator.storage.estimate()).usageDetails.caches || 0;
1213

14+
// Helper function to create usage of the cache so that our test
15+
// can estimate that usage.
1316
const createSomeUsage = async () => {
1417
const cache_name = token();
1518
const cache_url = `/foo-${cache_name}`;
@@ -18,49 +21,113 @@
1821
return [cache, cache_url];
1922
}
2023

24+
// Helper function for creating pathnames to test resources.
2125
const testPath = () => location.pathname.split("/").slice(0, -1).join("/");
2226

27+
// Define our test variables.
2328
let alt_origin = "https://{{hosts[alt][]}}:{{ports[https][0]}}";
2429
let details = {};
2530

31+
// Step 0: Construct an iframe. The content of this iframe includes
32+
// a script that will intercept and send postMessages back to this test
33+
// window. The iframe will be same-site with the window that opened it.
2634
const iframe = document.createElement("iframe");
2735
iframe.src = `https://{{host}}:{{ports[https][0]}}${testPath()}` +
2836
`/resources/partitioned-estimate-usage-details-caches-helper-frame.html`
2937
document.body.appendChild(iframe);
3038

31-
39+
// Our test will perform the following steps to demonstrate the partitioning
40+
// of storage estimate usage details for cache. Some steps are defined in:
41+
// wpt/storage/resources/partitioned-estimate-usage-details-caches-helper-frame.html
42+
// --------------------
43+
// (0) Construct a same-site iframe on our test page. The content of this
44+
// iframe includes a script that will intercept and send postMessages back
45+
// to this test window.
46+
// (1) The same-site iframe sends a postMessage notifying that the iframe
47+
// was constructed and we are ready to proceed with the test.
48+
// (2) Our test window intercepts this "iframe-is-ready" message.
49+
// (3) We create some cache usage and ensure that the cache usage data
50+
// reflects that increase in the test window.
51+
// (4) postMessage the same-site iframe to obtain cache usage data from that
52+
// frame.
53+
// (5) Our same-site iframe intercepts the "get-details" postMessage,
54+
// obtains the cache usage details available to the iframe, and postMessages
55+
// the usage back to the test window.
56+
// (6) Our test window intercepts the "same-site" message from the same-site
57+
// iframe containing usage data obtained there.
58+
// (7) We record the same-site usage data. Then, we open a cross-site window
59+
// containing this test script. As a result, Step 0 will be repeated, and a
60+
// cross-site iframe will be created in that cross-site window. Our cross-
61+
// site iframe will receive the same script as our same-site iframe. We then
62+
// return early to avoid running another instance of this test.
63+
// (8) Once created and loaded, our cross-site iframe has an on-load
64+
// listener that is triggered. To check that our script is executing in the
65+
// cross-site iframe (and not the same-site iframe), we check that our
66+
// parent has a valid opener value.
67+
// (9) Then, our cross-site iframe obtains the cache usage details available
68+
// to it and postMessages the usage back to the test window.
69+
// (10) Our test window intercepts the "cross-site" message from the cross-
70+
// site iframe containing the usage data obtained there.
71+
// (11) We record the cross-site usage data. Then we make our final
72+
// assertions.
3273
async_test(test => {
74+
// Since this script is loaded in two windows (our original test window
75+
// and the cross-site window opened later in the test), and we only want
76+
// to run the test body in the original test window, we return early
77+
// if our origin matches the "cross-site" window.
3378
if (location.origin === alt_origin)
3479
return;
3580

36-
81+
// Step 2: Our test window intercepts the "iframe-is-ready" message from
82+
// the same-site iframe.
3783
let cache, cache_url;
3884
window.addEventListener("message", test.step_func(async event => {
3985
if (event.data === "iframe-is-ready") {
86+
// Step 3: We create some cache usage and ensure that the cache usage
87+
// data reflects that increase in the test window.
4088
details.init = await usageDetails();
4189
[cache, cache_url] = await createSomeUsage(test);
4290
details.after = await usageDetails();
4391
assert_greater_than(details.after, details.init);
4492

93+
// Step 4: postMessage the same-site iframe to request that cache
94+
// usage data be obtained and sent from that frame.
4595
iframe.contentWindow.postMessage("get-details", iframe.origin);
4696
}
4797
}));
4898

4999
window.addEventListener("message", test.step_func(event => {
100+
// Step 6: Our test window intercepts the "same-site" message from the
101+
// same-site iframe containing usage data obtained there.
50102
if (event.data.source === "same-site") {
103+
// Step 7: We record the same-site data here. Then, we open a
104+
// cross-site window containing this test script. As a result, Step 0
105+
// will be repeated, and a cross-site iframe will be created in that
106+
// cross-site window. Our cross-site iframe will receive the same
107+
// script as our same-site iframe. We then return early to avoid
108+
// running another instance of this test.
51109
details.same_site = event.data;
52110

53111
const cross_site_window = window
54112
.open(`${alt_origin}${location.pathname}`, "", "noopener=false");
55113

56114
test.add_cleanup(() => cross_site_window.close());
57115
}
116+
// Step 10: Our test window intercepts the "cross-site" message from
117+
// the cross-site iframe containing the usage data obtained there.
58118
if (event.data.source === "cross-site") {
119+
// Step 11: We record the cross-site data. Then we make our final
120+
// assertions.
59121
details.cross_site = event.data;
60122

61-
// Some cleanup
123+
// Some cleanup.
62124
test.step(async () => await cache.delete(cache_url));
63125

126+
// Usage data is correctly partitioned if:
127+
// a. Our cross-site iframe recorded no cache usage data AND
128+
// b. The cache usage data for our test window (after the usage was
129+
// created) is equal to the cache usage data recorded by our
130+
// same-site iframe.
64131
test.step(() => {
65132
assert_true(details.cross_site.init == 0, "Usage should be 0.");
66133
assert_equals(details.same_site.init, details.after);
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
<!-- ToDo: Change the virtual suite expected file content once the necessary
2-
partitioning implementation is completed -->
31
<!DOCTYPE html>
42
<meta name=help href="https://privacycg.github.io/storage-partitioning/">
53
<title>Helper frame</title>
64

5+
<!-- This resource file is used in the WPT at:
6+
wpt/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html
7+
A full list of the test steps referenced here are defined in that WPT -->
8+
79
<script>
10+
// Helper function to obtain cache usage details for both the same-site
11+
// iframe and cross-site iframe.
812
const usageDetails = async () =>
913
(await navigator.storage.estimate()).usageDetails.caches || 0;
1014

15+
// Define test variables.
1116
let details = {};
1217

18+
// Step 5: Our same-site iframe intercepts the "get-details" postMessage,
19+
// obtains the cache usage details available to the iframe, and postMessages
20+
// the usage back to the test window.
1321
window.addEventListener("message", async event => {
1422
if (event.data === "get-details") {
1523
details.source = "same-site";
@@ -18,13 +26,25 @@
1826
}
1927
});
2028

29+
// Step 8: Once created and loaded, our cross-site iframe has an on-load
30+
// listener that is triggered. To check that our script is executing in
31+
// the cross-site iframe (and not the same-site iframe), we check that
32+
// our parent has a valid opener value.
2133
window.addEventListener("load", async () => {
2234
if (parent.opener) {
35+
// Step 9: Then, our cross-site iframe obtains the cache usage details
36+
// available to it and postMessages the usage back to the test window.
2337
details.source = "cross-site";
2438
details.init = await usageDetails();
2539
parent.opener.postMessage(details, parent.opener.origin);
2640
}
2741
});
2842

43+
// Step 1: Notify our parent test window that the same-site iframe
44+
// has been created. (Note: this script is shared between both the same-
45+
// site iframe and the cross-site iframe, but is only intercepted by
46+
// the test window in the case of the same-site iframe). This
47+
// postMessage alerts our test window that it can begin recording
48+
// cache usage.
2949
window.parent.postMessage("iframe-is-ready", window.parent.origin);
3050
</script>

0 commit comments

Comments
 (0)