Bug 1616970 [wpt PR 21908] - Migrate image policies from feature policy to document policy, a=testonly
authorCharlie Hu <chenleihu@google.com>
Thu, 12 Mar 2020 12:12:25 +0000
changeset 518636 378bf331c4a5c5ff35e9a32007ad5b497ae3d352
parent 518635 1c6439903ffef7b234327a56c23575bb217578bd
child 518637 69cf3613cf2a7ae893276d9bc724eaca8655178f
push id110076
push userwptsync@mozilla.com
push dateFri, 13 Mar 2020 16:50:09 +0000
treeherderautoland@7381ff2b16e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1616970, 21908, 1548869, 993790, 2058702, 748930
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1616970 [wpt PR 21908] - Migrate image policies from feature policy to document policy, a=testonly Automatic update from web-platform-tests Migrate image policies from feature policy to document policy This CL migrates following features from feature policy to document policy: - unoptimized-lossless-images - unoptimized-lossless-images-strict - unoptimized-lossy-images - oversized-images Following tests are being migrated to document policy: - feature-policy-unoptimized-lossless-images - feature-policy-unoptimized-lossless-images-strict - feature-policy-unoptimized-lossy-images - feature-policy-image-policies-with-border-radius - feature-policy-unoptimized-images-cached-image - unoptimized-lossy-images-reporting - unoptimized-lossy-images-reporting-onload - feature-policy-oversized-images - feature-policy-oversized-images-edge-cases - feature-policy-oversized-images-forced-layout - feature-policy-oversized-images-responsive-image - feature-policy-oversized-images-styles - feature-policy-oversized-images-resize - oversizsed-images-reporting Changed the test content of feature-policy-image-policies-with-border-radius. As legacy-image-formats is removed, The bmp image is not expected to be blocked. Previously ekaramad@ removed allow=”legacy-image-formats” in the test but did not update the expected png file in CL( https://chromium-review.googlesource.com/c/chromium/src/+/1548869). Also removed flaky expectations on test feature-policy-image-policies-with-border-radius. Following web tests are removed: - external/wpt/feature-policy/parameters/ Bug: 993790 Change-Id: I10e5c4a646efcfab1cdc757c012ae35e75a42241 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2058702 Commit-Queue: Charlie Hu <chenleihu@google.com> Reviewed-by: Robert Sesek <rsesek@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Reviewed-by: Ian Clelland <iclelland@chromium.org> Cr-Commit-Position: refs/heads/master@{#748930} -- wpt-commits: 3bf9565b16741968f6b02d55e6f359285fd4a414 wpt-pr: 21908
testing/web-platform/tests/document-policy/reporting/oversized-images-reporting.html
testing/web-platform/tests/document-policy/reporting/oversized-images-reporting.html.headers
testing/web-platform/tests/document-policy/reporting/oversized.jpg
testing/web-platform/tests/document-policy/reporting/unoptimized-image.jpg
testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting-onload.html
testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting-onload.html.headers
testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting.html
testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting.html.headers
testing/web-platform/tests/document-policy/resources/document-policy-report-json.js
testing/web-platform/tests/feature-policy/reporting/oversized-images-reporting.html
testing/web-platform/tests/feature-policy/reporting/oversized-images-reporting.html.headers
testing/web-platform/tests/feature-policy/reporting/oversized.jpg
testing/web-platform/tests/feature-policy/reporting/unoptimized-image.jpg
testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting-onload.html
testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting-onload.html.headers
testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting.html
testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting.html.headers
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src='/resources/testharness.js'></script>
+        <script src='/resources/testharnessreport.js'></script>
+        <script src='../resources/document-policy-report-json.js'></script>
+    </head>
+    <body>
+        <img src="./oversized.jpg" alt="oversized image" width="50" height="50">
+    <script>
+        async_test(t => {
+            new ReportingObserver(
+                t.step_func_done((reports, _) => {
+                    assert_greater_than(reports.length, 0);
+                    const report = reports[0];
+                    assert_equals(report.type, "document-policy-violation");
+                    assert_equals(report.url, document.location.href);
+                    const rbody = report.body;
+                    assert_equals(rbody.featureId, "oversized-images");
+                    assert_equals(rbody.sourceFile, document.getElementsByTagName('img')[0].src);
+                    assert_equals(rbody.lineNumber, null);
+                    assert_equals(rbody.columnNumber, null);
+                    check_report_json(reports[0]);
+                }),
+                {types: ['document-policy-violation'], buffered: true}
+            ).observe();
+        },
+        "oversized-images Report Format")
+    </script>
+    </body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/oversized-images-reporting.html.headers
@@ -0,0 +1,1 @@
+Document-Policy: oversized-images;scale=2.0
rename from testing/web-platform/tests/feature-policy/reporting/oversized.jpg
rename to testing/web-platform/tests/document-policy/reporting/oversized.jpg
rename from testing/web-platform/tests/feature-policy/reporting/unoptimized-image.jpg
rename to testing/web-platform/tests/document-policy/reporting/unoptimized-image.jpg
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting-onload.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <script src='/resources/testharness.js'></script>
+    <script src='/resources/testharnessreport.js'></script>
+  </head>
+  <body>
+    <script>
+var image = new Image();
+image.src = "./unoptimized-image.jpg";
+
+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, "unoptimized-lossy-images");
+  assert_equals(report.body.disposition, "enforce");
+};
+
+async_test(t => {
+  new ReportingObserver(t.step_func_done(check_report_format),
+                        {types: ['document-policy-violation'], buffered: true}).observe();
+}, "unoptimized-images Report Format");
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting-onload.html.headers
@@ -0,0 +1,1 @@
+Document-Policy: unoptimized-lossy-images;bpp=0.5
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <script src='/resources/testharness.js'></script>
+    <script src='/resources/testharnessreport.js'></script>
+  </head>
+  <body>
+    <img src="./unoptimized-image.jpg">
+    <script>
+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, "unoptimized-lossy-images");
+  assert_equals(report.body.disposition, "enforce");
+  assert_equals(report.body.sourceFile, document.getElementsByTagName('img')[0].src);
+  assert_equals(report.body.lineNumber, null);
+  assert_equals(report.body.columnNumber, null);
+};
+
+async_test(t => {
+  new ReportingObserver(t.step_func_done(check_report_format),
+                        {types: ['document-policy-violation'], buffered: true}).observe();
+}, "unoptimized-images Report Format");
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/reporting/unoptimized-lossy-images-reporting.html.headers
@@ -0,0 +1,1 @@
+Document-Policy: unoptimized-lossy-images;bpp=0.5
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/resources/document-policy-report-json.js
@@ -0,0 +1,20 @@
+/**
+ * @fileoverview functions for ensuring document policy report is serializable
+ */
+
+const check_report_json = (report) => {
+  // Ensures toJSON method exists on report.
+  assert_equals(typeof report.toJSON, "function");
+  const report_json = report.toJSON();
+  // Ensures toJSON() call is successful.
+  assert_equals(report.type, report_json.type);
+  assert_equals(report.url, report_json.url);
+  assert_equals(report.body.featureId, report_json.body.featureId);
+  assert_equals(report.body.disposition, report_json.body.disposition);
+  assert_equals(report.body.sourceFile, report_json.body.sourceFile);
+  assert_equals(report.body.lineNumber, report_json.body.lineNumber);
+  assert_equals(report.body.columnNumber, report_json.body.columnNumber);
+  // Ensures JSON.stringify() serializes the report correctly.
+  assert_false(JSON.stringify(report) === "{}");
+  assert_equals(JSON.stringify(report), JSON.stringify(report_json));
+}
\ No newline at end of file
deleted file mode 100644
--- a/testing/web-platform/tests/feature-policy/reporting/oversized-images-reporting.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <script src='/resources/testharness.js'></script>
-        <script src='/resources/testharnessreport.js'></script>
-        <script src='../resources/feature-policy-report-json.js'></script>
-    </head>
-    <body>
-        <img src="./oversized.jpg" alt="oversized image" width="50" height="50">
-    <script>
-        async_test(t => {
-            new ReportingObserver(
-                t.step_func_done((reports, _) => {
-                    assert_greater_than(reports.length, 0);
-                    const report = reports[0];
-                    assert_equals(report.type, "feature-policy-violation");
-                    assert_equals(report.url, document.location.href);
-                    const rbody = report.body;
-                    assert_equals(rbody.featureId, "oversized-images");
-                    assert_equals(rbody.sourceFile, document.getElementsByTagName('img')[0].src);
-                    assert_equals(rbody.lineNumber, null);
-                    assert_equals(rbody.columnNumber, null);
-                    check_report_json(reports[0]);
-                }),
-                {types: ['feature-policy-violation'], buffered: true}
-            ).observe();
-        },
-        "oversized-images Report Format")
-    </script>
-    </body>
-</html>
-
deleted file mode 100644
--- a/testing/web-platform/tests/feature-policy/reporting/oversized-images-reporting.html.headers
+++ /dev/null
@@ -1,1 +0,0 @@
-Feature-Policy: oversized-images 'none'
deleted file mode 100644
--- a/testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting-onload.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <script src='/resources/testharness.js'></script>
-    <script src='/resources/testharnessreport.js'></script>
-  </head>
-  <body>
-    <script>
-var image = new Image();
-image.src = "./unoptimized-image.jpg";
-
-var check_report_format = (reports, observer) => {
-  let report = reports[0];
-  assert_equals(report.type, "feature-policy-violation");
-  assert_equals(report.url, document.location.href);
-  assert_equals(report.body.featureId, "unoptimized-lossy-images");
-  assert_equals(report.body.disposition, "enforce");
-};
-
-async_test(t => {
-  new ReportingObserver(t.step_func_done(check_report_format),
-                        {types: ['feature-policy-violation'], buffered: true}).observe();
-}, "unoptimized-images Report Format");
-    </script>
-  </body>
-</html>
deleted file mode 100644
--- a/testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting-onload.html.headers
+++ /dev/null
@@ -1,1 +0,0 @@
-Feature-Policy: unoptimized-lossy-images 'none'
deleted file mode 100644
--- a/testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <script src='/resources/testharness.js'></script>
-    <script src='/resources/testharnessreport.js'></script>
-  </head>
-  <body>
-    <img src="./unoptimized-image.jpg">
-    <script>
-var check_report_format = (reports, observer) => {
-  let report = reports[0];
-  assert_equals(report.type, "feature-policy-violation");
-  assert_equals(report.url, document.location.href);
-  assert_equals(report.body.featureId, "unoptimized-lossy-images");
-  assert_equals(report.body.disposition, "enforce");
-  assert_equals(report.body.sourceFile, document.getElementsByTagName('img')[0].src);
-  assert_equals(report.body.lineNumber, null);
-  assert_equals(report.body.columnNumber, null);
-};
-
-async_test(t => {
-  new ReportingObserver(t.step_func_done(check_report_format),
-                        {types: ['feature-policy-violation'], buffered: true}).observe();
-}, "unoptimized-images Report Format");
-    </script>
-  </body>
-</html>
deleted file mode 100644
--- a/testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting.html.headers
+++ /dev/null
@@ -1,1 +0,0 @@
-Feature-Policy: unoptimized-lossy-images 'none'