| Nicolás Peña Moreno | 26c2cf8 | 2019-04-29 18:55:22 | [diff] [blame] | 1 | <!DOCTYPE HTML> |
| 2 | <meta charset=utf-8> |
| 3 | <title>Element Timing: do not observe a disconnected image</title> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script> |
| 7 | async_test(function (t) { |
| Stephen McGruer | dcfc14d | 2020-04-16 13:23:03 | [diff] [blame] | 8 | assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented"); |
| Nicolás Peña Moreno | 26c2cf8 | 2019-04-29 18:55:22 | [diff] [blame] | 9 | const observer = new PerformanceObserver( |
| 10 | t.step_func_done(() => { |
| 11 | // The image should not have caused an entry, so fail test. |
| 12 | assert_unreached('Should not have received an entry!'); |
| 13 | }) |
| 14 | ); |
| 15 | observer.observe({entryTypes: ['element']}); |
| 16 | // We add the image during onload to be sure that the observer is registered |
| 17 | // in time for it to observe the element timing. |
| 18 | window.onload = () => { |
| 19 | // Add image of width equal to 100 and height equal to 100. |
| 20 | const img = document.createElement('img'); |
| 21 | img.src = 'resources/square100.png'; |
| 22 | img.setAttribute('elementtiming', 'my_image'); |
| 23 | img.setAttribute('id', 'my_id'); |
| 24 | // Image has been created but not added. |
| 25 | // Wait for 500ms and end test, ensuring no entry was created. |
| 26 | t.step_timeout(() => { |
| 27 | t.done(); |
| 28 | }, 500); |
| 29 | }; |
| 30 | }, 'Image which is not added to DOM tree is not observable.'); |
| 31 | </script> |