| Nicolás Peña Moreno | bb603cc | 2019-04-04 15:03:43 | [diff] [blame] | 1 | <!DOCTYPE HTML> |
| 2 | <meta charset=utf-8> |
| 3 | <title>Element Timing: observe element with background image</title> |
| 4 | <body> |
| 5 | <style> |
| 6 | body { |
| 7 | margin: 0; |
| 8 | } |
| 9 | #target { |
| 10 | width: 100px; |
| 11 | height: 50px; |
| 12 | background-image: url('/images/black-rectangle.png'); |
| 13 | } |
| 14 | </style> |
| 15 | <script src="/resources/testharness.js"></script> |
| 16 | <script src="/resources/testharnessreport.js"></script> |
| 17 | <script src="resources/element-timing-helpers.js"></script> |
| 18 | <script> |
| 19 | let beforeRender = performance.now(); |
| 20 | async_test(function (t) { |
| James Graham | 163424c | 2019-05-17 16:47:03 | [diff] [blame] | 21 | if (!window.PerformanceElementTiming) { |
| 22 | assert_unreached("PerformanceElementTiming is not implemented"); |
| 23 | } |
| Nicolás Peña Moreno | bb603cc | 2019-04-04 15:03:43 | [diff] [blame] | 24 | const observer = new PerformanceObserver( |
| 25 | t.step_func_done(function(entryList) { |
| 26 | assert_equals(entryList.getEntries().length, 1); |
| 27 | const entry = entryList.getEntries()[0]; |
| 28 | const index = window.location.href.lastIndexOf('/'); |
| 29 | const pathname = window.location.href.substring(0, index - 14) + |
| 30 | 'images/black-rectangle.png'; |
| Nicolás Peña Moreno | 66bb6b4 | 2019-05-01 17:40:58 | [diff] [blame] | 31 | checkElement(entry, pathname, 'my_div', 'target', beforeRender, |
| 32 | document.getElementById('target')); |
| Nicolás Peña Moreno | bb603cc | 2019-04-04 15:03:43 | [diff] [blame] | 33 | checkRect(entry, [0, 100, 0, 50]); |
| 34 | checkNaturalSize(entry, 100, 50); |
| 35 | }) |
| 36 | ); |
| 37 | observer.observe({entryTypes: ['element']}); |
| 38 | }, 'Element with elementtiming attribute and background image is observable.'); |
| 39 | </script> |
| 40 | <div id='target' elementtiming='my_div'></div> |
| 41 | </body> |