Bug 1572832 [wpt PR 18337] - Report image url for oversized/unoptimized images, a=testonly
authorCharlie Hu <chenleihu@google.com>
Sat, 24 Aug 2019 10:00:14 +0000
changeset 553859 1b4fe76c192ff4910122379e7669447e013d29aa
parent 553858 8b7461534ad951904348ef6ef124363d9d5c61a6
child 553860 60dd077f7c232ecf56eb67ce88c97facf0052e0b
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1572832, 18337, 989701, 1741958, 687829
milestone70.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 1572832 [wpt PR 18337] - Report image url for oversized/unoptimized images, a=testonly Automatic update from web-platform-tests Report image url for oversized/unoptimized images Add image url to FeaturePolicyViolationReportBody when there is a oversized/unoptimized image feature policy violated. Previously the fileSource field in report is set to null when policy is violated. The effect is achieved by letting LocationReportBody represents both a location in JavaScript source code and a location of a general resource, e.g. a image. Because image does not have line number and column number, these attrs are represented in optional value, and LocationReportBody now saves pieces of actual information it needs to generate the report, instead of a reference to SourceLocation. Bug: 989701 Change-Id: Ibe88f07e7fa93c3d54b17380f8627221c119e106 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1741958 Reviewed-by: Ian Clelland <iclelland@chromium.org> Reviewed-by: Jeremy Roman <jbroman@chromium.org> Commit-Queue: Charlie Hu <chenleihu@google.com> Cr-Commit-Position: refs/heads/master@{#687829} -- wpt-commits: a5424fdbac9e46bee33f081b5975878c6b17496e wpt-pr: 18337
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-lossy-images-reporting.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/reporting/oversized-images-reporting.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src='/resources/testharness.js'></script>
+        <script src='/resources/testharnessreport.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);
+                }),
+                {types: ['feature-policy-violation'], buffered: true}
+            ).observe();
+        },
+        "oversized-images Report Format")
+    </script>
+    </body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/reporting/oversized-images-reporting.html.headers
@@ -0,0 +1,1 @@
+Feature-Policy: oversized-images 'none'
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..497ed770bfb6fb367f2eeb1978225bc4d036055b
GIT binary patch
literal 1655
zc%1ux<NpH&0WUXCHwH#VMg|WcWcYuZ!5PG(2!ITs)C|V|2N(o77#SEDm>HEAm;@P_
z1sVSzVUTBFU}S|TV1NQfCT12^Hg*n9E^eTLtpW^8jLghTEX=H|EG$6TTA(}wiy*6z
zqM;+3a9|?4QlW@Z<HUs=%1#>(iUwW$pkka<)WpdpCN3c<rK+Z`p{ZqJYG!U>Y31zV
z>gMj@=@lFj8WtWA8I_!pnwFlCnN?g;T2@|BS=HRq+ScCD*)?hMl&RCE&zL!D(c&db
zmn~nha@D5ITefc7zGLUELx+zXJ$C%W$y1juU%7hi`i+~n9zJ^f<mt2LFJ8X-`04YP
zuiw7^`1uRuFOWZB0IR<Qf&OA*VPR%r2l<PUsT`z0kcCyzkWI)jkUg<bSjni7L&Ry~
z!i@(xm5qZwh$a<X<PuXcd8qmk<TbF*i1SzzSw4e%4B@X^3_Q$?z{q13WUy!Wb*M{Y
Y{m*#&M{_h5buo<MQ9O!A9{zt50QRX8_5c6?
--- a/testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting.html
+++ b/testing/web-platform/tests/feature-policy/reporting/unoptimized-lossy-images-reporting.html
@@ -8,16 +8,19 @@
     <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>