-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement FeaturePolicy sync-script (as an experimental feature policy)
Spec discussion: https://github.com/WICG/feature-policy/issues/135 Intent to implement: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/b7f_K30MBYo Bug: 862422 Change-Id: Icd8a5d747373a819c7073ac459b5e8823d7986a8 Reviewed-on: https://chromium-review.googlesource.com/894137 Reviewed-by: Ojan Vafai <ojan@chromium.org> Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Ian Clelland <iclelland@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/master@{#576652}
- Loading branch information
1 parent
abd18b3
commit 0cc3831
Showing
6 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
window.didExecuteExternalAsyncScript = true; |
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 @@ | ||
window.didExecuteExternalDeferredScript = true; |
1 change: 1 addition & 0 deletions
1
feature-policy/experimental-features/resources/parser-blocking-script.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 @@ | ||
window.didExecuteExternalParsingBlockingScript = true; |
9 changes: 9 additions & 0 deletions
9
feature-policy/experimental-features/resources/sync-script-test.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,9 @@ | ||
var t = async_test('Test behavior of sync-script feature policy for different script types'); | ||
|
||
window.onload = t.step_func(function() { | ||
assert_equals(undefined, window.didExecuteInlineParsingBlockingScript, 'inline parser blocking script should be blocked'); | ||
assert_equals(undefined, window.didExecuteExternalParsingBlockingScript, 'external parser blocking script should be blocked'); | ||
assert_true(window.didExecuteExternalAsyncScript, 'external async script should not be blocked'); | ||
assert_true(window.didExecuteExternalDeferredScript, 'external defer script should not be blocked'); | ||
t.done(); | ||
}); |
22 changes: 22 additions & 0 deletions
22
feature-policy/experimental-features/sync-script.tentative.https.sub.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,22 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script defer src="/resources/testharness.js"></script> | ||
<script defer src="/resources/testharnessreport.js"></script> | ||
<script> | ||
// The test harness scripts above are loaded as <script defer> because | ||
// they would be blocked if loaded synchronously. | ||
// Harness scripts should be evaluated before sync-script-test.js, so it | ||
// is also loaded as <script defer> | ||
// | ||
// The other scripts (both inline and external) are testing whether those | ||
// scripts are blocked or not. | ||
// sync-script-test.js asserts the results of the other scripts in onload | ||
// in order to guarantee that all scripts have either loaded or been blocked | ||
// before verifying the behavior. | ||
window.didExecuteInlineParsingBlockingScript = true; | ||
</script> | ||
<script src="/feature-policy/experimental-features/resources/parser-blocking-script.js"></script> | ||
<script async src="/feature-policy/experimental-features/resources/async-script.js"></script> | ||
<script defer src="/feature-policy/experimental-features/resources/defer-script.js"></script> | ||
<script defer src="/feature-policy/experimental-features/resources/sync-script-test.js"></script> | ||
</body> |
1 change: 1 addition & 0 deletions
1
feature-policy/experimental-features/sync-script.tentative.https.sub.html.headers
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 @@ | ||
Feature-Policy: sync-script 'none' |