Bug 1528204 [wpt PR 15368] - [LayoutStability] Move layout tests to WPT, a=testonly
authorNicolás Peña <npm@chromium.org>
Tue, 05 Mar 2019 12:12:35 +0000
changeset 464527 2c7bc14204be05e3c4c0a53fb79ae74f7b5412ab
parent 464526 24c31f79b5add4d2b053c5faaaf6fcdb1c123436
child 464528 1d35d06964626a7a283b924892bb81eefeb563b5
push id35717
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:45:26 +0000
treeherdermozilla-central@e0861be8d6c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1528204, 15368, 581518, 1468581, 631861
milestone67.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 1528204 [wpt PR 15368] - [LayoutStability] Move layout tests to WPT, a=testonly Automatic update from web-platform-tests [LayoutStability] Move layout tests to WPT Bug: 581518 Change-Id: I475757c9dc66e192275b1ae02353f15a1fc8f926 Reviewed-on: https://chromium-review.googlesource.com/c/1468581 Reviewed-by: Steve Kobes <skobes@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#631861} -- wpt-commits: 92d1f6c0a381ca9c56910b9bbe6788175e8f8460 wpt-pr: 15368
testing/web-platform/tests/layout-stability/buffer-layout-jank.html
testing/web-platform/tests/layout-stability/observe-layoutjank.html
testing/web-platform/tests/layout-stability/resources/slow-image.py
testing/web-platform/tests/layout-stability/supported-layout-type.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/layout-stability/buffer-layout-jank.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>Layout Jank: query jank via the performance timeline</title>
+<body>
+<style>
+#myDiv { position: relative; width: 300px; height: 100px; }
+</style>
+<div id='myDiv'></div>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<!-- Delay onload by inserting a slow image.-->
+<img src="resources/slow-image.py">
+<script>
+  async_test(function (t) {
+    // Modify the position of the div.
+    document.getElementById('myDiv').style = "top: 60px";
+    function testBufferedEntry() {
+      if (performance.getEntriesByType('layoutJank').length === 0) {
+        t.step_timeout(testBufferedEntry, 0);
+        return;
+      }
+      assert_equals(performance.getEntriesByType('layoutJank').length, 1);
+      assert_equals(performance.getEntries().filter(
+        entry => entry.entryType === 'layoutJank').length, 1);
+      const entry = performance.getEntriesByType('layoutJank')[0];
+      assert_equals(entry.entryType, "layoutJank");
+      assert_equals(entry.name, "");
+      assert_equals(entry.startTime, 0.0);
+      assert_equals(entry.duration, 0.0);
+      // The layout jank fraction should be: 300 * (100 + 60) / viewport size.
+      assert_equals(entry.fraction, 300 * (100 + 60) /
+        (document.documentElement.clientWidth * document.documentElement.clientHeight));
+      t.done();
+    }
+    t.step(testBufferedEntry);
+  }, 'LayoutJank before onload is buffered into the performance timeline.');
+</script>
+
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/layout-stability/observe-layoutjank.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>Layout Jank: observe jank fraction via PerformanceObserver</title>
+<body>
+<style>
+#myDiv { position: relative; width: 300px; height: 100px; }
+</style>
+<div id='myDiv'></div>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+  async_test(function (t) {
+    const observer = new PerformanceObserver(
+      t.step_func_done(function(entryList) {
+        assert_equals(entryList.getEntries().length, 1);
+        const entry = entryList.getEntries()[0];
+        assert_equals(entry.entryType, "layoutJank");
+        assert_equals(entry.name, "");
+        assert_equals(entry.startTime, 0.0);
+        assert_equals(entry.duration, 0.0);
+        // The layout jank fraction should be: 300 * (100 + 60) / viewport size.
+        assert_equals(entry.fraction, 300 * (100 + 60) /
+          (document.documentElement.clientWidth * document.documentElement.clientHeight));
+      })
+    );
+    observer.observe({entryTypes: ['layoutJank']});
+    window.onload = () => {
+      // Modify the position of the div.
+      document.getElementById('myDiv').style = "top: 60px";
+    };
+  }, 'LayoutJank is observable via PerformanceObserver.');
+</script>
+
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/layout-stability/resources/slow-image.py
@@ -0,0 +1,6 @@
+import time
+
+def main(request, response):
+    # Sleep for 3s to delay onload.
+    time.sleep(3)
+    return [], ""
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/layout-stability/supported-layout-type.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<head>
+<title>PerformanceObserver.supportedEntryTypes contains "layoutJank"</title>
+</head>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+  if (typeof PerformanceObserver.supportedEntryTypes === "undefined")
+    assert_unreached("supportedEntryTypes is not supported.");
+  assert_greater_than(PerformanceObserver.supportedEntryTypes.indexOf("layoutJank"), -1,
+    "There should be an entry 'layoutJank' in PerformanceObserver.supportedEntryTypes");
+}, "supportedEntryTypes contains 'layoutJank'.");
+</script>
+</body>
+</html>