tor-browser

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

navigation-bfcache.window.js (1067B)


      1 // META: title=RemoteContextHelper navigation using BFCache
      2 // META: script=/common/dispatcher/dispatcher.js
      3 // META: script=/common/get-host-info.sub.js
      4 // META: script=/common/utils.js
      5 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
      6 // META: script=./resources/test-helper.js
      7 
      8 'use strict';
      9 
     10 promise_test(async t => {
     11  const rcHelper = new RemoteContextHelper();
     12 
     13  // Open a window with noopener so that BFCache will work.
     14  const rc1 = await rcHelper.addWindow(
     15      /*config=*/ null, /*options=*/ {features: 'noopener'});
     16 
     17  // Add a pageshow listener to stash the event.
     18  await rc1.executeScript(() => {
     19    window.addEventListener('pageshow', (event) => {
     20      window.pageshowEvent = event;
     21    });
     22  });
     23 
     24  // Navigate away.
     25  const rc2 = await rc1.navigateToNew();
     26  await assertSimplestScriptRuns(rc2);
     27 
     28  // Navigate back.
     29  await rc2.historyBack();
     30 
     31  // Verify that the document was BFCached.
     32  assert_true(await rc1.executeScript(() => {
     33    return window.pageshowEvent.persisted;
     34  }));
     35 });