Chromium Code Reviews| 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 |
| index 032bb97ec8b085151aa6c28dbfe3a2102402df7e..e92a733a6cb61dbdb63cc5868d1c1880f05b6f70 100644 |
| --- 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 |
| @@ -5,42 +5,43 @@ |
| <body> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| + <div id="main"></div> |
| <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 one paint timing instance delivered at a time."); |
| - 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") { |
| - assert_not_equals(t.first_paint_time, ""); |
| - 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"]}); |
| + testRunner.capturePixelsAsyncThen(t.step_func(function() { |
|
tdresser
2017/06/08 14:34:32
Can we make a promise based version of capturePixe
panicker
2017/06/08 22:47:04
this is C++ exposed, I suppose we can talk to test
tdresser
2017/06/09 14:26:27
I was thinking we'd just wrap capturePixelsAsyncTh
panicker
2017/06/09 20:29:48
Nice! This seems like a great follow-up (I couldn'
|
| + bufferedEntries = performance.getEntriesByType('paint'); |
| + assert_equals(bufferedEntries.length, 0, "No paint entries yet"); |
| - // 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 triggered by non-contentful paint. Image load triggers First Contentful Paint."); |
| + var div = document.createElement("div"); |
| + div.style.width = "100px"; |
| + div.style.height = "100px"; |
| + div.style.backgroundColor = "red"; |
| + div.style.color = "blue"; |
| + document.getElementById("main").appendChild(div); |
| - </script> |
| - <div style="background-color:black;color:white;padding:20px;"></div> |
| + testRunner.capturePixelsAsyncThen(t.step_func(function() { |
| + bufferedEntries = performance.getEntriesByType('paint'); |
| + assert_equals(bufferedEntries.length, 1, "FP only."); |
| + assert_equals(bufferedEntries[0].entryType, "paint"); |
| + assert_equals(bufferedEntries[0].name, "first-paint"); |
| + var img = document.createElement("IMG"); |
| + img.src = "resources/circles.png"; |
| + document.getElementById('image').appendChild(img); |
| + testRunner.capturePixelsAsyncThen(t.step_func_done(function() { |
| + bufferedEntries = performance.getEntriesByType('paint'); |
| + assert_equals(bufferedEntries.length, 2, "FP and FCP."); |
| + assert_equals(bufferedEntries[0].entryType, "paint"); |
| + assert_equals(bufferedEntries[0].name, "first-paint"); |
| + assert_equals(bufferedEntries[1].entryType, "paint"); |
| + assert_equals(bufferedEntries[1].name, "first-contentful-paint"); |
| + })); |
| + })); |
| + })); |
| + }, "First Paint triggered by non-contentful paint. Image load triggers First Contentful Paint."); |
| + </script> |
| </body> |
| </html> |