Bug 1634725 [wpt PR 23361] - Convert a CLS end to end test to wrap a WPT., a=testonly
authorSteve Kobes <skobes@chromium.org>
Wed, 13 May 2020 09:39:08 +0000
changeset 531051 6c679ef5a5f6f45879181c7a76977de97a4dd419
parent 531050 ab975ede8506e509b8fe638bd25efea774441885
child 531052 def1ef5a9c88a54f61cb05075578cbf8f38a095f
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1634725, 23361, 1045064, 2175636, 765156
milestone78.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 1634725 [wpt PR 23361] - Convert a CLS end to end test to wrap a WPT., a=testonly Automatic update from web-platform-tests Convert a CLS end to end test to wrap a WPT. This unifies MetricIntegrationTest.LayoutInstability with the nearly identical simple-block-movement.html, and introduces an abstraction for communicating expectations from the WPT to the wrapper, so that they can be verified in a generic way against the trace data and UMA/UKM results. We'll use this technique for CLSAttribution_* in a follow-up. Bug: 1045064 Change-Id: I401af5cd0186ad3de930130694ff2fcf7b43ed7e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2175636 Reviewed-by: Robert Ma <robertma@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Steve Kobes <skobes@chromium.org> Cr-Commit-Position: refs/heads/master@{#765156} -- wpt-commits: 79ecaf1d76018b995c2d438c28873288abfafd12 wpt-pr: 23361
testing/web-platform/tests/layout-instability/resources/test-adapter.js
testing/web-platform/tests/layout-instability/simple-block-movement.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/layout-instability/resources/test-adapter.js
@@ -0,0 +1,5 @@
+// Abstracts expectations for reuse in different test frameworks.
+
+cls_expect = (watcher, expectation) => {
+  assert_equals(watcher.score, expectation.score);
+};
--- a/testing/web-platform/tests/layout-instability/simple-block-movement.html
+++ b/testing/web-platform/tests/layout-instability/simple-block-movement.html
@@ -1,33 +1,32 @@
 <!DOCTYPE html>
 <title>Layout Instability: simple block movement is detected</title>
 <link rel="help" href="https://wicg.github.io/layout-instability/" />
 <style>
-
-#shifter { position: relative; width: 300px; height: 100px; }
-
+#shifter { position: relative; width: 300px; height: 200px; }
 </style>
 <div id="shifter"></div>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-adapter.js"></script>
 <script src="resources/util.js"></script>
 <script>
 
 promise_test(async () => {
   const watcher = new ScoreWatcher;
 
   // Wait for the initial render to complete.
   await waitForAnimationFrames(2);
 
   // Modify the position of the div.
-  document.querySelector("#shifter").style = "top: 60px";
+  document.querySelector("#shifter").style = "top: 160px";
 
-  // An element of size (300 x 100) has shifted by 60px.
-  const expectedScore = computeExpectedScore(300 * (100 + 60), 60);
+  // An element of size (300 x 200) has shifted by 160px.
+  const expectedScore = computeExpectedScore(300 * (200 + 160), 160);
 
   // Observer fires after the frame is painted.
-  assert_equals(watcher.score, 0);
+  cls_expect(watcher, {score: 0});
   await watcher.promise;
-  assert_equals(watcher.score, expectedScore);
+  cls_expect(watcher, {score: expectedScore});
 }, 'Simple block movement.');
 
 </script>