| Nicolas Pena | 3381ef3 | 2017-11-09 20:09:15 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <head> |
| 3 | <title>Performance Paint Timing Test: child ignores parent FCP</title> |
| 4 | </head> |
| 5 | <body> |
| 6 | <script src="/resources/testharness.js"></script> |
| 7 | <script src="/resources/testharnessreport.js"></script> |
| 8 | <div id="image"></div> |
| 9 | |
| 10 | <script> |
| 11 | async_test(function (t) { |
| 12 | const iframe = document.createElement('iframe'); |
| 13 | iframe.id = 'child-iframe'; |
| 14 | iframe.src = 'resources/subframe-sending-paint.html'; |
| 15 | document.body.appendChild(iframe); |
| 16 | window.addEventListener('message', t.step_func(e => { |
| 17 | // Child iframe should not have any paint-timing entries. |
| 18 | assert_equals(e.data, '0'); |
| 19 | t.done(); |
| 20 | })); |
| 21 | const img = document.createElement('IMG'); |
| 22 | img.src = 'resources/circles.png'; |
| 23 | img.onload = function() { |
| 24 | function testPaintEntries() { |
| 25 | const bufferedEntries = performance.getEntriesByType('paint'); |
| 26 | if (bufferedEntries.length < 2) { |
| 27 | t.step_timeout(testPaintEntries, 20); |
| 28 | return; |
| 29 | } |
| 30 | t.step(function() { |
| 31 | assert_equals(bufferedEntries.length, 2, 'There should be two paint timing instances.'); |
| 32 | assert_equals(bufferedEntries[0].entryType, 'paint'); |
| 33 | assert_equals(bufferedEntries[0].name, 'first-paint'); |
| 34 | assert_equals(bufferedEntries[1].entryType, 'paint'); |
| 35 | assert_equals(bufferedEntries[1].name, 'first-contentful-paint'); |
| 36 | // Ask child iframe to send its paint-timing entries. |
| 37 | document.getElementById('child-iframe'). |
| 38 | contentWindow.postMessage('', '*'); |
| 39 | }) |
| 40 | } |
| 41 | testPaintEntries(); |
| 42 | }; |
| 43 | document.getElementById('image').appendChild(img); |
| 44 | }, 'Child iframe ignores paint-timing events fired from parent image rendering.'); |
| 45 | </script> |
| 46 | </body> |
| 47 | </html> |