Skip to content

Commit 367f451

Browse files
lozy219chromium-wpt-export-bot
authored andcommitted
[WPT] Add WPT for BFCache eligibility with open IndexedDB transaction
This CL adds WPT to test if a page with open transaction can be restored from BFCache or not. It's expected for it to be not supported and result in `PRECONDITION_FAILED`. This will be turned to `PASS` after the CL that implements the unblocking. Bug: 1378823 Change-Id: I8be1d43badf07fa28eed894f176156a88b7b6a7b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4060378 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Commit-Queue: Mingyu Lei <leimy@chromium.org> Reviewed-by: Evan Stade <estade@chromium.org> Cr-Commit-Position: refs/heads/main@{#1093723}
1 parent 2d7c53f commit 367f451

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// META: title=BFCache support test for page with open IndexedDB transaction
2+
// META: script=/common/dispatcher/dispatcher.js
3+
// META: script=/common/utils.js
4+
// META: script=/html/browsers/browsing-the-web/back-forward-cache/resources/rc-helper.js
5+
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
6+
7+
'use strict';
8+
9+
promise_test(async t => {
10+
const rcHelper = new RemoteContextHelper();
11+
12+
// Open a window with noopener so that BFCache will work.
13+
const rc1 = await rcHelper.addWindow(
14+
/*config=*/ null, /*options=*/ {features: 'noopener'});
15+
16+
await rc1.executeScript(() => {
17+
// Create an IndexedDB database and the object store named `store` as the
18+
// test scope for the transaction later on.
19+
const db = indexedDB.open(/*name=*/ 'test_idb', /*version=*/ 1);
20+
db.onupgradeneeded = () => {
21+
db.result.createObjectStore('store');
22+
};
23+
addEventListener('pagehide', () => {
24+
let transaction = db.result.transaction(['store'], 'readwrite');
25+
let store = transaction.objectStore('store');
26+
store.put("key", "value");
27+
28+
// Queue a request to close the connection, while keeping the transaction
29+
// open, so that the BFCache eligibility will be determined solely by the
30+
// pending transaction.
31+
db.result.close();
32+
});
33+
});
34+
35+
await assertBFCache(rc1, /*shouldRestoreFromBFCache=*/ true);
36+
});

0 commit comments

Comments
 (0)