storage-access-beyond-cookies.estimate.sub.https.window.js (1573B)
1 // META: script=/resources/testdriver.js 2 // META: script=/resources/testdriver-vendor.js 3 4 'use strict'; 5 6 // Here's the set-up for this test: 7 // Step 1 (top-frame) Set up listener for "HasAccess" message. 8 // Step 2 (top-frame) Add data to first-party cache storage. 9 // Step 3 (top-frame) Embed an iframe that's cross-site with top-frame. 10 // Step 4 (sub-frame) Try to use storage access API and estimate first-party data. 11 // Step 5 (sub-frame) Embed an iframe that's same-origin with top-frame. 12 // Step 6 (sub-sub-frame) Try to use storage access API and estimate first-party data. 13 // Step 7 (sub-sub-frame) Send "HasAccess for estimate" message to top-frame. 14 // Step 8 (top-frame) Receive "HasAccess for estimate" message and cleanup. 15 16 async_test(t => { 17 const id = "test"; 18 19 // Step 1 20 window.addEventListener("message", t.step_func((e) => { 21 if (e.data.type != "result") { 22 return; 23 } 24 // Step 8 25 assert_equals(e.data.message, "HasAccess for estimate", "Storage Access API should be accessible and return first-party data"); 26 t.add_cleanup(() => {caches.delete(id);}); 27 t.done(); 28 })); 29 30 // Step 2 31 window.caches.open(id).then(async (cache) => { 32 await cache.put('/test.json', new Response('x'.repeat(1024*1024))); 33 // Step 3 34 let iframe = document.createElement("iframe"); 35 iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=estimate&id="+id; 36 document.body.appendChild(iframe); 37 }); 38 }, "Verify StorageAccessAPIBeyondCookies for Quota");