tor-browser

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

unload-allowed-headerless.tentative.window.js (1652B)


      1 // META: title='unload' Policy : allowed in headerless doc when allowed in main frame.
      2 // META: script=/common/dispatcher/dispatcher.js
      3 // META: script=/common/utils.js
      4 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
      5 // META: script=./resources/unload-helper.js
      6 // META: variant=?urlType=srcdoc
      7 // META: variant=?urlType=data
      8 // META: variant=?urlType=blob
      9 // META: variant=?urlType=blank
     10 
     11 'use strict';
     12 
     13 promise_test(async t => {
     14  const rcHelper = new RemoteContextHelper({
     15    scripts: ['./resources/unload-helper.js'],
     16  });
     17  // In the same browsing context group to ensure BFCache is not used.
     18  const main = await rcHelper.addWindow(
     19      {headers: [['Permissions-Policy', 'unload=*']]},
     20  );
     21 
     22  const url = new URL(location);
     23  const urlType = url.searchParams.get('urlType');
     24 
     25  if (urlType == 'srcdoc') {
     26    const subframe = await main.addIframeSrcdoc(
     27        /*extraConfig=*/ {}, /*attributes=*/ {allow: 'unload'});
     28    await assertWindowRunsUnload(subframe, 'subframe', {shouldRunUnload: true});
     29  } else {
     30    const subframe = await main.addIframe(
     31        /*extraConfig=*/ {urlType: urlType}, /*attributes=*/ {allow: 'unload'});
     32    // The other URL types cannot easily test unload directly. `data: and
     33    // `blob:` documents cannot access storage. `about:blank` loses the content
     34    // that was written into it when reloaded on going back and so stops
     35    // functioning as a remote execution context.
     36    await assertWindowAllowsUnload(
     37        subframe, 'subframe', {shouldRunUnload: true});
     38  }
     39 
     40  await assertWindowRunsUnload(main, 'main', {shouldRunUnload: true});
     41 });