blob: fa42397557b9d91d5bf0c4e0cb488b32825d8fc0 [file] [log] [blame]
Nicolás Peña Moreno66bb6b42019-05-01 17:40:581<!DOCTYPE HTML>
2<meta charset=utf-8>
3<title>Element Timing: element attribute returns null when element is disconnected</title>
4<body>
5<script src="/resources/testharness.js"></script>
6<script src="/resources/testharnessreport.js"></script>
7<script src="resources/element-timing-helpers.js"></script>
8<script>
9 let beforeRender;
10 let img;
11 async_test(function (t) {
James Graham163424c2019-05-17 16:47:0312 if (!window.PerformanceElementTiming) {
13 assert_unreached("PerformanceElementTiming is not implemented");
14 }
Nicolás Peña Moreno66bb6b42019-05-01 17:40:5815 const observer = new PerformanceObserver(
16 t.step_func_done(function(entryList) {
17 assert_equals(entryList.getEntries().length, 1);
18 const entry = entryList.getEntries()[0];
Nicolás Peña Morenoe42570f2019-10-21 21:23:0919 const pathname = window.location.origin + '/element-timing/resources/square100.png';
Nicolás Peña Moreno66bb6b42019-05-01 17:40:5820 // This method will check that entry.element is |img|.
21 checkElement(entry, pathname, 'my_image', 'my_id', beforeRender, img);
22
23 img.parentNode.removeChild(img);
24 // After removing image, entry.element should return null.
25 assert_equals(entry.element, null);
26 })
27 );
28 observer.observe({entryTypes: ['element']});
29 // We add the image during onload to be sure that the observer is registered
30 // in time for it to observe the element timing.
31 window.onload = () => {
32 // Add image of width equal to 100 and height equal to 100.
33 img = document.createElement('img');
34 img.src = 'resources/square100.png';
35 img.setAttribute('elementtiming', 'my_image');
36 img.setAttribute('id', 'my_id');
37 document.body.appendChild(img);
38 beforeRender = performance.now();
39 };
40 }, 'Disconnected elements have null as their |element| attribute.');
41</script>
42
43</body>