diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js')
-rw-r--r-- | testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js b/testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js new file mode 100644 index 0000000000..50d3c1f0d1 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js @@ -0,0 +1,42 @@ +// META: title=BFCache support test for page with open IndexedDB transaction +// META: script=/common/dispatcher/dispatcher.js +// META: script=/common/utils.js +// META: script=/html/browsers/browsing-the-web/back-forward-cache/resources/rc-helper.js +// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js +// META: timeout=long + +'use strict'; + +promise_test(async t => { + const rcHelper = new RemoteContextHelper(); + + // Open a window with noopener so that BFCache will work. + const rc1 = await rcHelper.addWindow( + /*config=*/ null, /*options=*/ {features: 'noopener'}); + + await rc1.executeScript(() => { + return new Promise(resolve => { + // Create an IndexedDB database and the object store named `store` as the + // test scope for the transaction later on. + const db = indexedDB.open(/*name=*/ 'test_idb', /*version=*/ 1); + db.onupgradeneeded = () => { + db.result.createObjectStore('store'); + addEventListener('pagehide', () => { + let transaction = db.result.transaction(['store'], 'readwrite'); + let store = transaction.objectStore('store'); + store.put('key', 'value'); + + // Queue a request to close the connection, while keeping the transaction + // open, so that the BFCache eligibility will be determined solely by the + // pending transaction. + db.result.close(); + }); + // Only resolve the promise when the connection is established + // and the `pagehide` event listener is added. + resolve(); + }; + }); + }); + + await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ true); +}); |