tor-browser

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

performance-navigation-timing-same-origin-bfcache.tentative.window.js (2050B)


      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 
     12 'use strict';
     13 
     14 // Ensure that same-origin subtree's reasons are exposed to notRestoredReasons.
     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  // Add a same-origin iframe and use WebSocket.
     24  const rc1_child = await rc1.addIframe(
     25      /*extra_config=*/ {}, /*attributes=*/ {id: 'test-id'});
     26  await useWebSocket(rc1_child);
     27 
     28  const rc1_child_url = await rc1_child.executeScript(() => {
     29    return location.href;
     30  });
     31  // Add a child to the iframe.
     32  const rc1_grand_child = await rc1_child.addIframe();
     33  const rc1_grand_child_url = await rc1_grand_child.executeScript(() => {
     34    return location.href;
     35  });
     36 
     37  // Check the BFCache result and the reported reasons.
     38  await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false);
     39  await assertNotRestoredReasonsEquals(
     40      rc1,
     41      /*url=*/ rc1_url,
     42      /*src=*/ null,
     43      /*id=*/ null,
     44      /*name=*/ null,
     45      /*reasons=*/[],
     46      /*children=*/[{
     47        'url': rc1_child_url,
     48        'src': rc1_child_url,
     49        'id': 'test-id',
     50        'name': '',
     51        'reasons': [{'reason': 'websocket'}],
     52        'children': [{
     53          'url': rc1_grand_child_url,
     54          'src': rc1_grand_child_url,
     55          'id': '',
     56          'name': '',
     57          'reasons': [],
     58          'children': []
     59        }]
     60      }]);
     61 });