summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.sessionStorage.tentative.sub.https.window.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.sessionStorage.tentative.sub.https.window.js')
-rw-r--r--testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.sessionStorage.tentative.sub.https.window.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.sessionStorage.tentative.sub.https.window.js b/testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.sessionStorage.tentative.sub.https.window.js
new file mode 100644
index 0000000000..1b12f133b2
--- /dev/null
+++ b/testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.sessionStorage.tentative.sub.https.window.js
@@ -0,0 +1,40 @@
+// META: script=/resources/testdriver.js
+// META: script=/resources/testdriver-vendor.js
+
+'use strict';
+
+// Here's the set-up for this test:
+// Step 1 (top-frame) Set up listener for "HasAccess" message and set data for window_event if so.
+// Step 2 (top-frame) Add data to first-party session storage and set up listener for handle_event.
+// Step 3 (top-frame) Embed an iframe that's cross-site with top-frame.
+// Step 4 (sub-frame) Try to use storage access API and read first-party data.
+// Step 5 (sub-frame) Embed an iframe that's same-origin with top-frame.
+// Step 6 (sub-sub-frame) Try to use storage access API and read first-party data.
+// Step 7 (sub-sub-frame) Send "HasAccess for sessionStorage" message to top-frame.
+// Step 8 (top-frame) Expect new data to be set and properly trigger listener.
+
+async_test(t => {
+ // Step 1
+ window.addEventListener("message", t.step_func(e => {
+ assert_equals(e.data, "HasAccess for sessionStorage", "Storage Access API should be accessible and return first-party data");
+ window.sessionStorage.setItem("window_event", id);
+ }));
+
+ // Step 2
+ const id = String(Date.now());
+ window.sessionStorage.setItem("test", id);
+ window.addEventListener("storage", t.step_func(e => {
+ if (e.key == "handle_event") {
+ // Step 8
+ assert_equals(e.newValue, id);
+ assert_equals(e.storageArea, window.sessionStorage);
+ window.sessionStorage.clear();
+ t.done();
+ }
+ }));
+
+ // 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=sessionStorage&id=" + id;
+ document.body.appendChild(iframe);
+}, "Verify StorageAccessAPIBeyondCookies for Session Storage");