tor-browser

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

performance-navigation-timing-same-origin-replace.tentative.window.js (1524B)


      1 // META: title=RemoteContextHelper navigation using BFCache
      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: script=/websockets/constants.sub.js
      9 // META: timeout=long
     10 
     11 'use strict';
     12 
     13 // Ensure that notRestoredReasons are accessible after history replace.
     14 promise_test(async t => {
     15  const rcHelper = new RemoteContextHelper();
     16  // Open a window with noopener so that BFCache will work.
     17  const rc1 = await rcHelper.addWindow(
     18      /*config=*/ null, /*options=*/ {features: 'noopener'});
     19  const rc1_url = await rc1.executeScript(() => {
     20    return location.href;
     21  });
     22 
     23  // Use WebSocket to block BFCache.
     24  await useWebSocket(rc1);
     25  // Navigate away.
     26  const newRemoteContextHelper = await rc1.navigateToNew();
     27  // Replace the history state to a same-origin site.
     28  await newRemoteContextHelper.executeScript((destUrl) => {
     29    window.history.replaceState(null, '', '#');
     30  });
     31  // Go back.
     32  await newRemoteContextHelper.historyBack();
     33 
     34  // Reasons are not reset for same-origin replace.
     35  await assertNotRestoredReasonsEquals(
     36      rc1,
     37      /*url=*/ rc1_url,
     38      /*src=*/ null,
     39      /*id=*/ null,
     40      /*name=*/ null,
     41      /*reasons=*/[{'reason': 'websocket'}],
     42      /*children=*/ []);
     43 });