Bug 1497323 [wpt PR 13366] - Enable FP reporting for EME policy violations., a=testonly
authorIan Clelland <iclelland@chromium.org>
Thu, 11 Oct 2018 09:30:36 +0000
changeset 489235 b8e822211da2d7b707f8b89b4d28146ad5e0f141
parent 489234 7f9995d90affed02070d111f906f7fa676f285cc
child 489236 629151c9becabbb8648e3badcce0fb96335c08c6
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerstestonly
bugs1497323, 13366, 867471, 1261921, 596965
milestone64.0a1
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
testing/web-platform/tests/feature-policy/reporting/encrypted-media-reporting.https.html
testing/web-platform/tests/feature-policy/reporting/encrypted-media-reporting.https.html.headers
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'