summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/IndexedDB/back-forward-cache-open-transaction.window.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.js42
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);
+});