-
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.
[ FeaturePolicy ] 'sandbox' vs 'allow' attributes
This CL ensures that sandbox features set through 'allow' attribute take precedence over the 'sandbox' attribute itsef. In line with this, any sandbox flag which is converted to a container policy will be removed from the set of flags for the corresponding frame owner. This ensures that the container policy will not be overwritten by FrameOwner sandbox at the time of receiving the feature policy headers. The CL also packs a WPT which verifies the precedence of 'allow' over 'sandbox'. Bug: 795538, 812381, 926293 Change-Id: Ic1d31dfb17ce4a81b5ead23b789119c04cfacd8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1508925 Reviewed-by: Kent Tamura <[email protected]> Reviewed-by: Ian Clelland <[email protected]> Commit-Queue: Ehsan Karamad <[email protected]> Cr-Commit-Position: refs/heads/master@{#645769}
- Loading branch information
1 parent
c5bd0d1
commit 52d8660
Showing
2 changed files
with
80 additions
and
4 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
46 changes: 46 additions & 0 deletions
46
feature-policy/feature-policy-for-sandbox/sandbox-policies-in-allow-attribute.html
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,46 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<div id="iframe-embedder"></div> | ||
<script src="./resources/helper.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
const iframe_src = "/feature-policy/feature-policy-for-sandbox/resources/window_opener.html"; | ||
|
||
promise_test( async () => { | ||
for (const feature of sandbox_features) { | ||
// For the test to work correctly we need "scripts"; | ||
const sandbox_flags = feature === "scripts" ? "" : "allow-scripts"; | ||
const iframe = await add_iframe( | ||
{src: iframe_src, allow: `${feature} *`, sandbox: sandbox_flags}); | ||
iframe.contentWindow.postMessage({type: "feature", feature: feature}, "*"); | ||
const iframe_state = await feature_update(feature); | ||
assert_true(iframe_state, | ||
`'${feature}' should not be disabled in <iframe>.'`); | ||
iframe.parentElement.removeChild(iframe); | ||
} | ||
}, "Verify that when a sandbox related feature is enabled in 'allow' then " + | ||
" the feature will be enabled regardless of sandbox attribute's value."); | ||
|
||
promise_test( async() => { | ||
for (const feature of sandbox_features) { | ||
const sandbox_flags = `allow-${feature} allow-scripts`; | ||
const iframe = await add_iframe( | ||
{src: iframe_src, allow: `${feature} 'none'`, sandbox: sandbox_flags}); | ||
iframe.contentWindow.postMessage({type: "feature", feature: feature}, "*"); | ||
// 'scripts' will block running code in the subframe and no update can be | ||
// sent. A timeout determines the feature is disabled. | ||
const timeout = (feature === "scripts") ? 10 : false; | ||
const iframe_state = await feature_update(feature, timeout); | ||
assert_false(iframe_state, | ||
`'${feature}' should be disabled in <iframe>.'`); | ||
iframe.parentElement.removeChild(iframe); | ||
} | ||
}, "Verify that when a sandbox related feature is disabled in 'allow' then " + | ||
" the feature will be disabled regardless of sandbox attribute's value."); | ||
</script> | ||
</body> |