tor-browser

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

performance-navigation-timing-lock.https.tentative.window.js (1278B)


      1 // META: title=Ensure that if WebLock is held upon entering bfcache, it cannot enter bfcache and gets reported.
      2 // META: script=./test-helper.js
      3 // META: script=/common/dispatcher/dispatcher.js
      4 // META: script=/common/get-host-info.sub.js
      5 // META: script=/common/utils.js
      6 // META: script=/html/browsers/browsing-the-web/back-forward-cache/resources/rc-helper.js
      7 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
      8 // META: timeout=long
      9 
     10 promise_test(async t => {
     11  const rcHelper = new RemoteContextHelper();
     12  // Open a window with noopener so that BFCache will work.
     13  const rc1 = await rcHelper.addWindow(
     14      /*config=*/ null, /*options=*/ {features: 'noopener'});
     15  const rc1_url = await rc1.executeScript(() => {
     16    return location.href;
     17  });
     18 
     19  // Request a WebLock.
     20  let return_value = await rc1.executeScript(() => {
     21    return new Promise((resolve) => {
     22      navigator.locks.request('resource', () => {
     23        resolve(42);
     24        return new Promise(() => {});
     25      });
     26    })
     27  });
     28  assert_equals(return_value, 42);
     29 
     30  // Check the BFCache result and the reported reasons.
     31  await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false);
     32  await assertNotRestoredFromBFCache(rc1, ['lock']);
     33 });