forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report synchronous script violations
Use the ReportingAPI to report violations of the "sync-script" document policy. Bug: 1314475 Change-Id: I554625e1b88170c999d52ad23f7c7a4dbefc3a68 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3573257 Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org> Commit-Queue: Ian Clelland <iclelland@chromium.org> Cr-Commit-Position: refs/heads/main@{#991516}
- Loading branch information
1 parent
4fa22e3
commit 458b046
Showing
3 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,20 @@ | ||
// This is deliberately split from sync-script-reporting.html so that it will | ||
// not be blocked by policy, and can actuall be executed. | ||
|
||
var t = async_test("Sync-script Report Format"); | ||
|
||
var check_report_format = (reports, observer) => { | ||
let report = reports[0]; | ||
assert_equals(report.type, "document-policy-violation"); | ||
assert_equals(report.url, document.location.href); | ||
assert_equals(report.body.featureId, "sync-script"); | ||
assert_equals(report.body.sourceFile, null); | ||
assert_equals(report.body.lineNumber, null); | ||
assert_equals(report.body.columnNumber, null); | ||
assert_equals(report.body.disposition, "enforce"); | ||
check_report_json(report); | ||
}; | ||
|
||
new ReportingObserver(t.step_func_done(check_report_format), | ||
{ types: ['document-policy-violation'], | ||
buffered: true}).observe(); |
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,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script defer src='/resources/testharness.js'></script> | ||
<script defer src='/resources/testharnessreport.js'></script> | ||
<script defer src='../resources/document-policy-report-json.js'></script> | ||
<script defer src="resources/sync-script.js"></script> | ||
</head> | ||
<body> | ||
<!-- The presence of this script will violate the sync-script policy, | ||
and will trigger a report. --> | ||
<script>var newGlobal = true;</script> | ||
</body> | ||
</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 @@ | ||
Document-Policy: sync-script=?0 |