Files
tubestation/testing/web-platform/tests/IndexedDB/idb-partitioned-basic.tentative.sub.html
Ari Chivukula 6f62e22fe2 Bug 1760841 [wpt PR 33303] - [IndexedDB Storage Partition] (3) Add WPT to check for persistence, a=testonly
Automatic update from web-platform-tests
[IndexedDB Storage Partition] (3) Add WPT to check for persistence

Now that we have a stop-gap which simply de-persists all third-party idb
storage, we should add a WPT to check that when partitioning is on, the
storage is persisted.

This CL is a part of a series:
(1) Tentative WPT
(2) Add to third-party-storage-partitioning virtual suite
(3) Add WPT to check for persistence
(4) Migrate third party storage to buckets

Bug: 1218100
Change-Id: I3c43b70692c343830a2b14d7336b91642f5cb547
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3543365
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Ari Chivukula <arichiv@chromium.org>
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#984984}

--

wpt-commits: 2d11a98a69004ff9b62713080c7c67d5b7124e0e
wpt-pr: 33303
2022-04-01 13:26:49 +00:00

56 lines
2.2 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: partitioned storage test</title>
<meta name=help href="https://privacycg.github.io/storage-partitioning/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="shared-iframe" src="http://{{host}}:{{ports[http][0]}}/IndexedDB/resources/idb-partitioned-basic-iframe.tentative.html"></iframe>
<body>
<script>
// Here's the set-up for this test:
// Step 1. (window) set up listeners for main window.
// Step 2. (same-site iframe) loads, creates a database, and sends "same-site iframe loaded" message.
// Step 3. (window) receives "same-site iframe loaded" message and opens cross-site window.
// Step 4. (cross-site iframe) loads, checks if database exists, and sends "cross-site iframe loaded" message.
// Step 5. (window) receives "cross-site iframe loaded" message, asserts that database should not exist, sends "delete database" message.
// Step 6. (same-site iframe) receives "delete database" message, deletes the database, sends "database deleted" message.
// Step 7. (window) receives the "database deleted" and then exits.
const altOrigin = "http://{{hosts[alt][]}}:{{ports[http][0]}}";
async_test(t => {
const iframe = document.getElementById("shared-iframe");
// Step 1
window.addEventListener("message", t.step_func(e => {
// Step 3
if (e.data.message === "same-site iframe loaded") {
if (location.origin !== altOrigin) {
const crossSiteWindow = window.open(`${altOrigin}/IndexedDB/idb-partitioned-basic.tentative.sub.html`, "", "noopener=false");
t.add_cleanup(() => crossSiteWindow.close());
}
}
// Step 5
if (e.data.message === "cross-site iframe loaded") {
t.step(() => {
assert_false(
e.data.doesDatabaseExist,
"The cross-site iframe should not see the same-site database",
);
});
iframe.contentWindow.postMessage(
{message: "delete database"},
iframe.contentWindow.origin,
);
};
// Step 7
if (e.data.message === "database deleted") {
t.done();
};
}));
}, "Simple test for partitioned IndexedDB");
</script>
</body>