unload-disallowed-headerless.tentative.window.js (1672B)
1 // META: title='unload' Policy : disallowed in headerless doc when disallowed 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( 29 subframe, 'subframe', {shouldRunUnload: false}); 30 } else { 31 const subframe = await main.addIframe( 32 /*extraConfig=*/ {urlType: urlType}, /*attributes=*/ {allow: 'unload'}); 33 34 // The other URL types cannot esaily test unload directly. `data: and 35 // `blob:` documents cannot access storage. `about:blank` loses the content 36 // that was written into it when reloaded on going back and so stops 37 // functioning as a remote execution context. 38 await assertWindowAllowsUnload( 39 subframe, 'subframe', {shouldRunUnload: false}); 40 } 41 42 await assertWindowRunsUnload(main, 'main', {shouldRunUnload: false}); 43 });