Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(818)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/first-contentful-paint.html

Issue 2860143002: Add tests for paint-timing, and move existing tests to same location (Closed)
Patch Set: add more tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/first-contentful-paint.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/first-contentful-paint.html b/third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/first-contentful-paint.html
new file mode 100644
index 0000000000000000000000000000000000000000..bff785b10d9016e844a0d7cfe21d9a970612923f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/first-contentful-paint.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<head>
+<title>Performance Paint Timing Test</title>
+</head>
+<body>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+ <div id="image"></div>
+
+ <script>
+ async_test(function (t) {
+ var observer = new PerformanceObserver(
+ t.step_func(function (entryList) {
+ var entries = entryList.getEntries();
+ // Nothing contentful to be painted yet.
+ assert_equals(entries.length, 1,
+ "There should be only first paint timing instance.");
tdresser 2017/05/09 13:53:27 This string is incorrect, isn't it? The second ti
panicker 2017/05/09 17:55:06 Done.
+ assert_equals(entries[0].entryType, "paint",
+ "Expected entryType to be: paint.");
+ if (entries[0].name == "first-paint") {
+ t.first_paint_time = entries[0].startTime;
+ } else if (entries[0].name == "first-contentful-paint") {
tdresser 2017/05/09 13:53:27 Maybe check explicitly that t.first_paint_time has
panicker 2017/05/09 17:55:06 Done.
+ t.first_contentful_paint_time = entries[0].startTime;
+ assert_greater_than(t.first_contentful_paint_time - t.first_paint_time, 100);
+ observer.disconnect();
+ t.done();
+ }
+ })
+ );
+ observer.observe({entryTypes: ["paint"]});
+
+ // Wait 100ms, then load image
+ setTimeout(function() {
+ var img = document.createElement("IMG");
+ img.src = "resources/circles.png";
+ document.getElementById('image').appendChild(img);
+ }, 100);
+ }, "First Paint triggerd by non-contentful paint. Image load triggers First Contentful Paint.");
tdresser 2017/05/09 13:53:27 triggerd -> triggered
panicker 2017/05/09 17:55:06 Done.
+
+ </script>
+ <div style="background-color:black;color:white;padding:20px;"></div>
+
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698