Skip to content

Commit

Permalink
Bug 1888518 [wpt PR 45413] - [SAA] Use async functions in wpts where …
Browse files Browse the repository at this point in the history
…possible, a=testonly

Automatic update from web-platform-tests
[SAA] Use async functions in wpts where possible

It's still easier to keep the top level as an async_test (which cannot
be async), but the inner functions can be async as needed.

Bug: 40282415
Change-Id: I6001912cf2510e140f7980154e24705a30088cc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5402469
Reviewed-by: Dylan Cutler <[email protected]>
Commit-Queue: Ari Chivukula <[email protected]>
Auto-Submit: Ari Chivukula <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1280016}

--

wpt-commits: 4f6add9c038f36f063a8fb5dbff015a376fec0ce
wpt-pr: 45413
  • Loading branch information
arichiv authored and moz-wptsync-bot committed Apr 10, 2024
1 parent c41117a commit 45dd725
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ async_test(t => {
assert_equals(e.data, "Same-origin handle access", "Relay worker should divert messages here");
// Step 8
const cookie_worker = new SharedWorker("/storage-access-api/resources/shared-worker-cookies.py", {name: id, sameSiteCookies: 'none'});
cookie_worker.port.onmessage = t.step_func(e => {
cookie_worker.port.onmessage = t.step_func(async (e) => {
assert_equals(e.data, "ReadOnLoad:None,ReadOnFetch:None,ConnectionsMade:2", "Worker should already have been opened and only see SameSite=None cookies");
test_driver.delete_all_cookies().then(t.step_func(() => {
t.done();
}));
await test_driver.delete_all_cookies();
t.done();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@

async_test(t => {
// Step 1
window.addEventListener("message", t.step_func(e => {
window.addEventListener("message", t.step_func((e) => {
if (e.data.type != "result") {
return;
}
// Step 8
assert_equals(e.data.message, "HasAccess for caches", "Storage Access API should be accessible and return first-party data");
test_driver.delete_all_cookies().then(t.step_func(() => {
t.done();
}));
t.add_cleanup(() => {test_driver.delete_all_cookies();});
t.done();
}));

// Step 2
Expand All @@ -32,12 +31,11 @@ async_test(t => {
document.cookie = "samesite_lax=test; SameSite=Lax; Secure";
document.cookie = "samesite_none=test; SameSite=None; Secure";

window.caches.open(id).then((cache) => {
cache.add("https://{{hosts[][]}}:{{ports[https][0]}}/storage-access-api/resources/get_cookies.py?1").then(() => {
// Step 3
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=caches&id="+id;
document.body.appendChild(iframe);
});
window.caches.open(id).then(async (cache) => {
await cache.add("https://{{hosts[][]}}:{{ports[https][0]}}/storage-access-api/resources/get_cookies.py?1");
// Step 3
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=caches&id="+id;
document.body.appendChild(iframe);
});
}, "Verify StorageAccessAPIBeyondCookies for Cache Storage");
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@

async_test(t => {
// Step 1
window.addEventListener("message", t.step_func(e => {
window.addEventListener("message", t.step_func((e) => {
if (e.data.type != "result") {
return;
}
// Step 8
assert_equals(e.data.message, "HasAccess for cookies", "Storage Access API should be accessible and return first-party data");
test_driver.delete_all_cookies().then(t.step_func(() => {
t.done();
}));
t.add_cleanup(() => {test_driver.delete_all_cookies();});
t.done();
}));

// Step 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ async_test(t => {
const id = "test";

// Step 1
window.addEventListener("message", t.step_func(e => {
window.addEventListener("message", t.step_func((e) => {
if (e.data.type != "result") {
return;
}
// Step 8
assert_equals(e.data.message, "HasAccess for estimate", "Storage Access API should be accessible and return first-party data");
caches.delete(id).then(() => {
t.done();
});
t.add_cleanup(() => {caches.delete(id);});
t.done();
}));

// Step 2
window.caches.open(id).then((cache) => {
cache.put('/test.json', new Response('x'.repeat(1024*1024))).then(() => {
// Step 3
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=estimate&id="+id;
document.body.appendChild(iframe);
});
window.caches.open(id).then(async (cache) => {
await cache.put('/test.json', new Response('x'.repeat(1024*1024)));
// Step 3
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=estimate&id="+id;
document.body.appendChild(iframe);
});
}, "Verify StorageAccessAPIBeyondCookies for Quota");
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ async_test(t => {

// Step 2
const id = Date.now();
window.navigator.storage.getDirectory().then((root) => {
root.getFileHandle(id, {create: true}).then(() => {
// Step 3
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=getDirectory&id="+id;
document.body.appendChild(iframe);
});
window.navigator.storage.getDirectory().then(async (root) => {
await root.getFileHandle(id, {create: true});
// Step 3
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=getDirectory&id="+id;
document.body.appendChild(iframe);
});
}, "Verify StorageAccessAPIBeyondCookies for Origin Private File System");

0 comments on commit 45dd725

Please sign in to comment.