summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative....
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/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative.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/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative.window.js')
-rw-r--r--testing/web-platform/tests/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative.window.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative.window.js b/testing/web-platform/tests/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative.window.js
new file mode 100644
index 0000000000..7195dff654
--- /dev/null
+++ b/testing/web-platform/tests/fs/FileSystemFileHandle-writable-file-stream-back-forward-cache.https.tentative.window.js
@@ -0,0 +1,64 @@
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/utils.js
+// META: script=resources/test-helpers.js
+// META: script=resources/messaging-helpers.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';
+
+
+createBFCacheTest(async (t, testControls) => {
+ const {getRemoteFuncs, assertBFCacheEligibility} = testControls;
+ const [createAndReleaseWFS] = getRemoteFuncs('createAndReleaseWFS');
+
+ for (const mode of WFS_MODES) {
+ await createAndReleaseWFS(mode, 'hello.txt');
+ await assertBFCacheEligibility(/*shouldRestoreFromBFCache=*/ true);
+ }
+}, 'Creating an WFS should not make it ineligible for the BFCache.');
+
+createBFCacheTest(async (t, testControls) => {
+ const origFile = 'hello.txt';
+ const diffFile = 'world.txt';
+
+ const {getRemoteFuncs, forward, back} = testControls;
+ const [createWFS, releaseWFS, createAndReleaseWFS] =
+ getRemoteFuncs('createWFS', 'releaseWFS', 'createAndReleaseWFS');
+
+ async function testTakeLockOnForward(
+ mode, fileName, shouldRestoreFromBFCache) {
+ await forward();
+
+ assert_true(await createAndReleaseWFS(mode, fileName));
+
+ await back(shouldRestoreFromBFCache);
+ }
+
+ for (const backMode of WFS_MODES) {
+ for (const forwMode of WFS_MODES) {
+ const contentiousLocks = wfsModesAreContentious(backMode, forwMode);
+
+ // Create a lock on the page that will be BFCached.
+ const lockId = await createWFS(backMode, origFile);
+ assert_true(lockId !== undefined);
+
+ // Navigating to a new page and taking a lock on a different file should
+ // not evict the page from BFCache.
+ await testTakeLockOnForward(
+ forwMode, diffFile, /*shouldRestoreFromBFCache=*/ true);
+
+ // Navigating to a new page and taking a lock on the same file should only
+ // evict if the locks are contentious.
+ await testTakeLockOnForward(
+ forwMode, origFile, /*shouldRestoreFromBFCache=*/ !contentiousLocks);
+
+ // Release the lock when there isn't contention since it won't have been
+ // evicted.
+ if (!contentiousLocks) {
+ await releaseWFS(lockId);
+ }
+ }
+ }
+}, `Creating a WFS on an active page evicts an inactive page on contention.`)