tor-browser

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

performance-navigation-timing-reload.tentative.window.js (1725B)


      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 const {ORIGIN, REMOTE_ORIGIN} = get_host_info();
     13 
     14 // Ensure that notRestoredReasons reset after the server redirect.
     15 promise_test(async t => {
     16  const rcHelper = new RemoteContextHelper();
     17  // Open a window with noopener so that BFCache will work.
     18  const rc1 = await rcHelper.addWindow(
     19      /*config=*/ null, /*options=*/ {features: 'noopener'});
     20  const rc1_url = await rc1.executeScript(() => {
     21    return location.href;
     22  });
     23  // Use WebSocket to block BFCache.
     24  await useWebSocket(rc1);
     25 
     26  // Check the BFCache result and the reported reasons.
     27  await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false);
     28  await assertNotRestoredReasonsEquals(
     29        rc1,
     30        /*url=*/ rc1_url,
     31        /*src=*/ null,
     32        /*id=*/ null,
     33        /*name=*/ null,
     34        /*reasons=*/[{'reason': 'websocket'}],
     35        /*children=*/ []);
     36 
     37  // Reload.
     38  await rc1.navigate(() => {
     39    location.reload();
     40  }, []);
     41 
     42  // Becauase of the reload, notRestoredReasons is reset.
     43  const navigation_entry = await rc1.executeScript(() => {
     44    return performance.getEntriesByType('navigation')[0];
     45  });
     46 
     47  assert_equals(
     48      navigation_entry.notRestoredReasons, null,
     49      'Expected notRestoredReasons is null.');
     50 });