-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cope with srcdoc and other headerless docs for EnabledForNone features.
This works by special-casing EnabledForNone in GetFeatureValueForOrigin for headerless docs and return true for that case. This produces the correct inherited value. Bug: 40285153 Change-Id: I4b9ff6353a21ca493f6ccc9a965b10005caa8896 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5311943 Commit-Queue: Fergal Daly <[email protected]> Reviewed-by: Jeremy Roman <[email protected]> Reviewed-by: Ian Clelland <[email protected]> Cr-Commit-Position: refs/heads/main@{#1407698}
- Loading branch information
1 parent
109d4a6
commit 6622504
Showing
3 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
permissions-policy/experimental-features/unload-allowed-headerless.tentative.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// META: title='unload' Policy : allowed in headerless doc when allowed in main frame. | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/utils.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=./resources/unload-helper.js | ||
// META: variant=?urlType=srcdoc | ||
// META: variant=?urlType=data | ||
// META: variant=?urlType=blob | ||
// META: variant=?urlType=blank | ||
|
||
'use strict'; | ||
|
||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper({ | ||
scripts: ['./resources/unload-helper.js'], | ||
}); | ||
// In the same browsing context group to ensure BFCache is not used. | ||
const main = await rcHelper.addWindow( | ||
{headers: [['Permissions-Policy', 'unload=*']]}, | ||
); | ||
|
||
const url = new URL(location); | ||
const urlType = url.searchParams.get('urlType'); | ||
|
||
if (urlType == 'srcdoc') { | ||
const subframe = await main.addIframeSrcdoc( | ||
/*extraConfig=*/ {}, /*attributes=*/ {allow: 'unload'}); | ||
await assertWindowRunsUnload(subframe, 'subframe', {shouldRunUnload: true}); | ||
} else { | ||
const subframe = await main.addIframe( | ||
/*extraConfig=*/ {urlType: urlType}, /*attributes=*/ {allow: 'unload'}); | ||
// The other URL types cannot easily test unload directly. `data: and | ||
// `blob:` documents cannot access storage. `about:blank` loses the content | ||
// that was written into it when reloaded on going back and so stops | ||
// functioning as a remote execution context. | ||
await assertWindowAllowsUnload( | ||
subframe, 'subframe', {shouldRunUnload: true}); | ||
} | ||
|
||
await assertWindowRunsUnload(main, 'main', {shouldRunUnload: true}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
permissions-policy/experimental-features/unload-disallowed-headerless.tentative.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// META: title='unload' Policy : disallowed in headerless doc when disallowed in main frame. | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/utils.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=./resources/unload-helper.js | ||
// META: variant=?urlType=srcdoc | ||
// META: variant=?urlType=data | ||
// META: variant=?urlType=blob | ||
// META: variant=?urlType=blank | ||
|
||
'use strict'; | ||
|
||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper({ | ||
scripts: ['./resources/unload-helper.js'], | ||
}); | ||
// In the same browsing context group to ensure BFCache is not used. | ||
const main = await rcHelper.addWindow( | ||
{headers: [['Permissions-Policy', 'unload=()']]}, | ||
); | ||
|
||
const url = new URL(location); | ||
const urlType = url.searchParams.get('urlType'); | ||
|
||
if (urlType == 'srcdoc') { | ||
const subframe = await main.addIframeSrcdoc( | ||
/*extraConfig=*/ {}, /*attributes=*/ {allow: 'unload'}); | ||
await assertWindowRunsUnload( | ||
subframe, 'subframe', {shouldRunUnload: false}); | ||
} else { | ||
const subframe = await main.addIframe( | ||
/*extraConfig=*/ {urlType: urlType}, /*attributes=*/ {allow: 'unload'}); | ||
|
||
// The other URL types cannot esaily test unload directly. `data: and | ||
// `blob:` documents cannot access storage. `about:blank` loses the content | ||
// that was written into it when reloaded on going back and so stops | ||
// functioning as a remote execution context. | ||
await assertWindowAllowsUnload( | ||
subframe, 'subframe', {shouldRunUnload: false}); | ||
} | ||
|
||
await assertWindowRunsUnload(main, 'main', {shouldRunUnload: false}); | ||
}); |