tor-browser

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

performance-navigation-timing-iframes-without-attributes.tentative.window.js (3053B)


      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 empty attributes are reported as empty strings and missing
     14 // attributes are reported as null.
     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 cross-origin iframe.
     24  const rc1_child = await rc1.addIframe(
     25      /*extraConfig=*/ {
     26        origin: 'HTTP_REMOTE_ORIGIN',
     27        scripts: [],
     28        headers: [],
     29      },
     30      /*attributes=*/ {id: '', name: ''},
     31  );
     32  const rc2_child = await rc1.addIframe(
     33    /*extraConfig=*/ {
     34      origin: 'HTTP_REMOTE_ORIGIN',
     35      scripts: [],
     36      headers: [],
     37    },
     38    /*attributes=*/ {},
     39  );
     40  const rc3_child = await rc1.addIframe(
     41    /*extraConfig=*/ {},
     42    /*attributes=*/ {},
     43  );
     44  const rc4_child = await rc1.addIframe(
     45    /*extraConfig=*/ {},
     46    /*attributes=*/ {id: '', name: ''},
     47  );
     48  // Use WebSocket to block BFCache.
     49  await useWebSocket(rc1);
     50  const rc1_child_url = await rc1_child.executeScript(() => {
     51    return location.href;
     52  });
     53  const rc2_child_url = await rc2_child.executeScript(() => {
     54    return location.href;
     55  });
     56  const rc3_child_url = await rc3_child.executeScript(() => {
     57    return location.href;
     58  });
     59  const rc4_child_url = await rc4_child.executeScript(() => {
     60    return location.href;
     61  });
     62  // Check the BFCache result and the reported reasons.
     63  await assertBFCacheEligibility(rc1, /*shouldRestoreFromBFCache=*/ false);
     64  await assertNotRestoredReasonsEquals(
     65      rc1,
     66      /*url=*/ rc1_url,
     67      /*src=*/ null,
     68      /*id=*/ null,
     69      /*name=*/ null,
     70      /*reasons=*/[{'reason': 'websocket'}],
     71      /*children=*/[{
     72        'url': null,
     73        'src': rc1_child_url,
     74        // Id and name should be empty.
     75        'id': '',
     76        'name': '',
     77        'reasons': null,
     78        'children': null
     79      }, {
     80        'url': null,
     81        'src': rc2_child_url,
     82        // Id and name should be null.
     83        'id': null,
     84        'name': null,
     85        'reasons': null,
     86        'children': null
     87      },{
     88        'url': rc3_child_url,
     89        'src': rc3_child_url,
     90        // Id and name should be null.
     91        'id': null,
     92        'name': null,
     93        'reasons': [],
     94        'children': []
     95      }, {
     96        'url': rc4_child_url,
     97        'src': rc4_child_url,
     98        'id': '',
     99        'name': '',
    100        'reasons': [],
    101        'children': []
    102      }]);
    103 });