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

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

Issue 2932593002: Attempt 2: Update PaintTiming Web Perf APIs for FP & FCP to report swap time (Closed)
Patch Set: rebase to head Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <head> 2 <head>
3 <title>Performance Paint Timing Test</title> 3 <title>Performance Paint Timing Test: FP followed by FCP</title>
4 </head> 4 </head>
5 <body> 5 <body>
6 <script src="../../resources/testharness.js"></script> 6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script> 7 <script src="../../resources/testharnessreport.js"></script>
8 <div id="main"></div>
8 <div id="image"></div> 9 <div id="image"></div>
9 10
10 <script> 11 <script>
11 async_test(function (t) { 12 async_test(function (t) {
12 var observer = new PerformanceObserver( 13 testRunner.capturePixelsAsyncThen(t.step_func(function() {
13 t.step_func(function (entryList) { 14 const bufferedEntries = performance.getEntriesByType('paint');
14 var entries = entryList.getEntries(); 15 assert_equals(bufferedEntries.length, 0, "No paint entries yet");
15 // Nothing contentful to be painted yet.
16 assert_equals(entries.length, 1,
17 "There should be only one paint timing instance delivered at a time.");
18 assert_equals(entries[0].entryType, "paint",
19 "Expected entryType to be: paint.");
20 if (entries[0].name == "first-paint") {
21 t.first_paint_time = entries[0].startTime;
22 } else if (entries[0].name == "first-contentful-paint") {
23 assert_not_equals(t.first_paint_time, "");
24 t.first_contentful_paint_time = entries[0].startTime;
25 assert_greater_than(t.first_contentful_paint_time - t.first_ paint_time, 100);
26 observer.disconnect();
27 t.done();
28 }
29 })
30 );
31 observer.observe({entryTypes: ["paint"]});
32 16
33 // Wait 100ms, then load image 17 const div = document.createElement("div");
34 setTimeout(function() { 18 div.style.width = "100px";
35 var img = document.createElement("IMG"); 19 div.style.height = "100px";
36 img.src = "resources/circles.png"; 20 div.style.backgroundColor = "red";
37 document.getElementById('image').appendChild(img); 21 div.style.color = "blue";
38 }, 100); 22 document.getElementById("main").appendChild(div);
39 }, "First Paint triggered by non-contentful paint. Image load triggers First Contentful Paint.");
40 23
24 testRunner.capturePixelsAsyncThen(t.step_func(function() {
25 const bufferedEntries = performance.getEntriesByType('paint');
26 assert_equals(bufferedEntries.length, 1, "FP only.");
27 assert_equals(bufferedEntries[0].entryType, "paint");
28 assert_equals(bufferedEntries[0].name, "first-paint");
29
30 const img = document.createElement("IMG");
31 img.src = "resources/circles.png";
32 img.onload = function() {
33 testRunner.capturePixelsAsyncThen(t.step_func_done(function( ) {
34 const bufferedEntries = performance.getEntriesByType('pa int');
35 assert_equals(bufferedEntries.length, 2, "FP and FCP.");
36 assert_equals(bufferedEntries[0].entryType, "paint");
37 assert_equals(bufferedEntries[0].name, "first-paint");
38 assert_equals(bufferedEntries[1].entryType, "paint");
39 assert_equals(bufferedEntries[1].name, "first-contentful -paint");
40 }));
41 };
42 document.getElementById('image').appendChild(img);
43 }));
44 }));
45 }, "First Paint triggered by non-contentful paint. Image load triggers Fir st Contentful Paint.");
41 </script> 46 </script>
42 <div style="background-color:black;color:white;padding:20px;"></div>
43
44
45 </body> 47 </body>
46 </html> 48 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698