Bug 1505638 [wpt PR 13972] - Violation reports for 'layout-animations', a=testonly
☠☠ backed out by 46ad93280b06 ☠ ☠
authorEhsan Karamad <ekaramad@chromium.org>
Mon, 19 Nov 2018 18:46:33 +0000
changeset 503752 a96795d1de3f259153af0a66f2c00b1ac684f905
parent 503751 6e08180c8ba3db7fa707e76b97069d7fc4d2f4ba
child 503753 2b4e8d16551955833b71358bcf2f0ba617fcc3df
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1505638, 13972, 902836, 867471, 1324138, 608984
milestone65.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 1505638 [wpt PR 13972] - Violation reports for 'layout-animations', a=testonly Automatic update from web-platform-testsViolation reports for 'layout-animations' This CL adds support for generating violation reports for 'layout-animations' feature policy. The new implementation triggers a report when: 1- CSS Parser finds usage of @keyframes for one of the banned styles. 2- element.animate() changes a banned style. Bug: 902836,867471 Change-Id: I79900603eb0166514d7986dc189ec914bd95f899 Reviewed-on: https://chromium-review.googlesource.com/c/1324138 Commit-Queue: Ehsan Karamad <ekaramad@chromium.org> Reviewed-by: Alan Cutter <alancutter@chromium.org> Cr-Commit-Position: refs/heads/master@{#608984} -- wpt-commits: b8ac03b76dc36f29c66bef25bc69c322b85dc57c wpt-pr: 13972
testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html
testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html.headers
testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html
testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html.headers
testing/web-platform/tests/feature-policy/experimental-features/resources/animation-property-height.js
testing/web-platform/tests/feature-policy/experimental-features/resources/common.js
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/feature-policy/experimental-features/resources/common.js"></script>
+<title> 'layout-animations' Policy : violation reports from javascript
+</title>
+<body>
+<script>
+  test(() => {
+    document.policy.allowedFeatures().forEach((enabled_feature) => {
+      assert_not_equals(enabled_feature, "layout-animations");
+    });
+  },
+  "Verify 'layout-animations' is not in document's feature list.");
+
+  promise_test(async () => {
+    let promise = wait_for_violation_in_file(
+      "layout-animations",
+      "animation-property-height.js");
+    let script = document.createElement("script");
+    script.src = "/feature-policy/experimental-features/resources/" +
+                 "animation-property-height.js";
+    document.body.appendChild(script);
+    await promise;
+  },
+  "Verify that when 'layout-animations' is disabled, an 'element.animate' " +
+  "API including a keyframe that uses a blocked property generates violation " +
+  "report (linked scripts).");
+
+  promise_test(async () => {
+    let promise = wait_for_violation_in_file(
+      "layout-animations",
+      "layout-animations-disabled-violation-report-js-tentative.html");
+    let div = document.createElement("div");
+    document.body.appendChild(div);
+    div.animate([{width: "100px"}, {width: "200px"}]);
+    await promise;
+  },
+  "Verify that when 'layout-animations' is disabled, an 'element.animate' " +
+  "API including a keyframe that uses a blocked property generates violation " +
+  "report (inline scripts).");
+</script>
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html.headers
@@ -0,0 +1,1 @@
+Feature-Policy: layout-animations 'none'
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/feature-policy/experimental-features/resources/common.js"></script>
+<title> 'layout-animations' Policy : violation reports from CSS keyframes
+</title>
+<body>
+<script>
+  test(() => {
+    document.policy.allowedFeatures().forEach((enabled_feature) => {
+      assert_not_equals(enabled_feature, "layout-animations");
+    });
+  },
+  "Sanity-check: 'layout-animations' is not in document's feature list.");
+
+  promise_test(async () => {
+    let promise = wait_for_violation_in_file(
+      "layout-animations", null /* source not specified */);
+    let style = document.createElement("style");
+    style.innerHTML = `@keyframes animation_property_top {
+                          from { top: 0px }
+                          to { top: 100px }
+                      }`;
+    document.body.appendChild(style);
+    await promise;
+  },
+  "Verify that when 'layout-animations' is disabled, a keyframes which " +
+  "includes a blocked property generates violation report.");
+</script>
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html.headers
@@ -0,0 +1,1 @@
+Feature-Policy: layout-animations 'none'
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/feature-policy/experimental-features/resources/animation-property-height.js
@@ -0,0 +1,3 @@
+let div = document.createElement("div");
+document.body.appendChild(div);
+div.animate([{"height": "0px"}, {"height": "100px"}]);
--- a/testing/web-platform/tests/feature-policy/experimental-features/resources/common.js
+++ b/testing/web-platform/tests/feature-policy/experimental-features/resources/common.js
@@ -59,9 +59,34 @@ function createIframe(container, attribu
   return new_iframe;
 }
 
 // Returns a promise which is resolved when |load| event is dispatched for |e|.
 function wait_for_load(e) {
   return new Promise((resolve) => {
     e.addEventListener("load", resolve);
   });
-}
\ No newline at end of file
+}
+
+window.reporting_observer_instance = new ReportingObserver((reports, observer) => {
+  if (window.reporting_observer_callback) {
+    reports.forEach(window.reporting_observer_callback);
+  }
+}, {types: ["feature-policy"]});
+window.reporting_observer_instance.observe();
+window.reporting_observer_callback = null;
+
+// Waits for a violation in |feature| and source file containing |file_name|.
+function wait_for_violation_in_file(feature, file_name) {
+  return new Promise( (resolve) => {
+    assert_equals(null, window.reporting_observer_callback);
+    window.reporting_observer_callback = (report) => {
+        var feature_match = (feature === report.body.feature);
+        var file_name_match =
+            !file_name ||
+            (report.body.sourceFile.indexOf(file_name) !== -1);
+        if (feature_match && file_name_match) {
+          window.reporting_observer_callback = null;
+          resolve(report);
+        }
+    };
+  });
+}