Bug 1497323 [wpt PR 13366] - Enable FP reporting for EME policy violations., a=testonly
Automatic update from web-platform-testsEnable FP reporting for EME policy violations.
This queues a report through the Reporting API whenever
requestMediaKeySystemAccess is called in a frame in which the 'encrypted-media'
feature is not allowed according to feature policy.
Bug: 867471
Change-Id: I781cf9d9719bcbaffe0b328c2b6bfa5ca197920a
Reviewed-on: https://chromium-review.googlesource.com/c/1261921
Reviewed-by: David Dorwin <ddorwin@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596965}
--
wpt-commits: 45fe4bda8ce30614d0935b11b7d27e269401361c
wpt-pr: 13366
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/reporting/encrypted-media-reporting.https.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ </head>
+ <body>
+ <script>
+var check_report_format = (reports, observer) => {
+ let report = reports[0];
+ assert_equals(report.type, "feature-policy");
+ assert_equals(report.url, document.location.href);
+ assert_equals(report.body.feature, "encrypted-media");
+ assert_equals(report.body.sourceFile, document.location.href);
+ assert_equals(typeof report.body.message, "string");
+ assert_equals(typeof report.body.lineNumber, "number");
+ assert_equals(typeof report.body.columnNumber, "number");
+};
+
+promise_test(async t => {
+ const report = new Promise(resolve => {
+ new ReportingObserver((reports, observer) => resolve([reports, observer]),
+ {types: ['feature-policy']}).observe();
+ });
+ await promise_rejects(t, "SecurityError",
+ navigator.requestMediaKeySystemAccess("org.w3.clearkey",
+ [{
+ initDataTypes: ["webm"],
+ videoCapabilities: [{contentType: 'video/webm;codecs="vp8"'}],
+ }]),
+ "requestMediaKeySystemAccess() should not be allowed in this document.");
+ const [reports, observer] = await report;
+ check_report_format(reports, observer);
+}, "Encrypted Media report format");
+ </script>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/reporting/encrypted-media-reporting.https.html.headers
@@ -0,0 +1,1 @@
+Feature-Policy: encrypted-media 'none'