| <!doctype html> |
| <meta charset="utf-8"> |
| <script src="/resources/testdriver.js"></script> |
| <script src="/resources/testdriver-vendor.js"></script> |
| <body> |
| <script> |
| (async function() { |
| test_driver.set_test_context(window.top); |
| const type = (new URLSearchParams(window.location.search)).get("type"); |
| const id = (new URLSearchParams(window.location.search)).get("id"); |
| let message = ""; |
| // Step 4 (storage-access-api/storage-access-beyond-cookies.{}.tentative.sub.https.html) |
| try { |
| await test_driver.set_permission({ name: 'storage-access' }, 'granted'); |
| const handle = await document.requestStorageAccess({all: true}); |
| switch (type) { |
| case "sessionStorage": { |
| if (!!handle.sessionStorage.getItem("test")) { |
| message = "Cross-site first-party Session Storage should be empty"; |
| } |
| break; |
| } |
| case "localStorage": { |
| if (!!handle.localStorage.getItem("test")) { |
| message = "Cross-site first-party Local Storage should be empty"; |
| } |
| break; |
| } |
| case "indexedDB": { |
| const dbs = await handle.indexedDB.databases(); |
| if (dbs.length != 0) { |
| message = "Cross-site first-party IndexedDB should be empty"; |
| } |
| break; |
| } |
| case "locks": { |
| const state = await handle.locks.query(); |
| if (state.held.length != 0) { |
| message = "Cross-site first-party Web Locks should be empty"; |
| } |
| break; |
| } |
| case "caches": { |
| const has = await handle.caches.has(id); |
| if (has) { |
| message = "Cross-site first-party Cache Storage should be empty"; |
| } |
| break; |
| } |
| case "getDirectory": { |
| const root = await handle.getDirectory(); |
| let has = await root.getFileHandle(id).then(() => true, () => false);; |
| if (has) { |
| message = "Cross-site first-party Origin Private File System should be empty"; |
| } |
| break; |
| } |
| case "estimate": { |
| const estimate = await handle.estimate(); |
| if (estimate.usage > 0) { |
| message = "Cross-site first-party estimate should be empty"; |
| } |
| break; |
| } |
| case "blobStorage": { |
| const blob = await fetch(atob(id)).then( |
| (response) => response.text(), |
| () => ""); |
| if (blob != "") { |
| message = "Cross-site first-party blob storage should be empty"; |
| } |
| break; |
| } |
| default: { |
| message = "Unexpected type " + type; |
| break; |
| } |
| } |
| } catch (_) { |
| message = "Unable to load handle in cross-site context for all"; |
| } |
| await test_driver.set_permission({ name: 'storage-access' }, 'prompt'); |
| if (message) { |
| window.top.postMessage(message, "*"); |
| return; |
| } |
| // Step 5 (storage-access-api/storage-access-beyond-cookies.{}.tentative.sub.https.html) |
| let iframe = document.createElement("iframe"); |
| iframe.src = "https://{{hosts[][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe-iframe.html?type=" + type + "&id=" + id; |
| document.body.appendChild(iframe); |
| })(); |
| </script> |
| </body> |