first-contentful-canvas-webgl2.html (1618B)
1 <!DOCTYPE html> 2 3 <head> 4 <title>Performance Paint Timing Test: FCP due to canvas</title> 5 </head> 6 7 <body> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <canvas id="canvas" width="200" height="200"></canvas> 11 12 <script> 13 setup({ "hide_test_state": true }); 14 async_test(function (t) { 15 assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported."); 16 const canvas = document.getElementById("canvas"); 17 const context = canvas.getContext("webgl2"); 18 if (!context) { 19 assert_implements_optional(context, "WebGL 2 Canvas isn't supported.") 20 } 21 context.clearColor(0.3, 0.3, 0.3, 1); 22 context.clear(context.COLOR_BUFFER_BIT); 23 function testPaintEntries() { 24 const bufferedEntries = performance.getEntriesByType('paint'); 25 if (bufferedEntries.length < 2) { 26 t.step_timeout(function () { 27 testPaintEntries(); 28 }, 20); 29 return; 30 } 31 t.step(function () { 32 assert_equals(bufferedEntries.length, 2, "There should be two paint timing instances."); 33 assert_equals(bufferedEntries[0].entryType, "paint"); 34 assert_equals(bufferedEntries[0].name, "first-paint"); 35 assert_equals(bufferedEntries[1].entryType, "paint"); 36 assert_equals(bufferedEntries[1].name, "first-contentful-paint"); 37 t.done(); 38 }); 39 }; 40 t.step(function () { 41 testPaintEntries(); 42 }); 43 }, "First contentful paint fires due to webgl2 canvas render."); 44 </script> 45 </body> 46 47 </html>