tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

back-forward-cache-open-connection.window.js (1616B)


      1 // META: title=Testing BFCache support for page with open IndexedDB connection, and eviction behavior when receiving versionchange event.
      2 // META: script=/common/dispatcher/dispatcher.js
      3 // META: script=/common/utils.js
      4 // META: script=resources/support.js
      5 // META: script=/html/browsers/browsing-the-web/back-forward-cache/resources/rc-helper.js
      6 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
      7 // META: timeout=long
      8 
      9 'use strict';
     10 
     11 promise_test(async t => {
     12  const rcHelper = new RemoteContextHelper();
     13 
     14  // Open a window with noopener so that BFCache will work.
     15  const rc1 = await rcHelper.addWindow(
     16      /*config=*/ null, /*options=*/ {features: 'noopener'});
     17 
     18  const prefix = t.name + Math.random();
     19  const dbname1 = prefix + "_1";
     20  const dbname2 = prefix + "_2";
     21  await waitUntilIndexedDBOpenForTesting(rc1, dbname1, 1);
     22  await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ true);
     23 
     24  // The page is ensured to be eligible for BFCache even with open connection,
     25  // otherwise the previous assertion will fail with PRECONDITION_FAILED.
     26  // Now we can test if the versionchange event will evict the BFCache.
     27  await waitUntilIndexedDBOpenForTesting(rc1, dbname2, 1);
     28 
     29  const rc2 = await rc1.navigateToNew();
     30  // Create an IndexedDB database with higher version.
     31  // This will fire a version change event on existing connection with the
     32  // same database name.  The new database will only be opened if the existing
     33  // connection is closed on receiving the event.
     34  await waitUntilIndexedDBOpenForTesting(rc2, dbname2, 2);
     35 });