Skip to content

Commit

Permalink
Implement FeaturePolicy sync-script (as an experimental feature policy)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
natechapin authored and Chrome-bot committed Jul 11, 2018
1 parent 828cbf6 commit 79dc5f5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.didExecuteExternalAsyncScript = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.didExecuteExternalDeferredScript = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.didExecuteExternalParsingBlockingScript = true;
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();
});
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature-Policy: sync-script 'none'

0 comments on commit 79dc5f5

Please sign in to comment.