| <!DOCTYPE html> |
| <html> |
| <meta charset=utf-8 /> |
| <title>Element Timing: buffer elements before onload</title> |
| <script src=/resources/testharness.js></script> |
| <script src=/resources/testharnessreport.js></script> |
| <script src="resources/element-timing-helpers.js"></script> |
| <body> |
| <img src=resources/slow-image.py?name=square20.png&sleep=500> |
| <script> |
| /* |
| In this test, a slow image is added to the frame to delay onload. The entry |
| for the other image should be available before onload, and thus delivered to |
| the performance timeline. |
| */ |
| async_test(function(t) { |
| if (!window.PerformanceElementTiming) { |
| assert_unreached("PerformanceElementTiming is not implemented"); |
| } |
| beforeRender = performance.now(); |
| const img = document.createElement('img'); |
| img.src = 'resources/square20.jpg'; |
| img.setAttribute('elementtiming', 'my_image'); |
| img.setAttribute('id', 'my_id'); |
| document.body.appendChild(img); |
| window.onload = t.step_func_done( () => { |
| const entries = performance.getEntriesByType('element'); |
| assert_greater_than_equal(entries.length, 1); |
| assert_equals(performance.getEntries().filter(e => e.identifier === 'my_image').length, 1); |
| const entry = entries[0]; |
| const index = window.location.href.lastIndexOf('/'); |
| const pathname = window.location.href.substring(0, index) + |
| '/resources/square20.jpg'; |
| checkElement(entry, pathname, 'my_image', 'my_id', beforeRender, img); |
| checkNaturalSize(entry, 20, 20); |
| }); |
| }, "Element Timing: image loads before onload."); |
| |
| </script> |
| </body> |
| </html> |