OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <head> |
| 3 <script src="./resizeTestHelper.js"></script> |
| 4 </head> |
| 5 <p>iframe test</p> |
| 6 <div id="itarget1" style="width:100px;height:100px;">t1</div> |
| 7 <script> |
| 8 'use strict'; |
| 9 |
| 10 let t1 = document.querySelector('#itarget1'); |
| 11 |
| 12 function test0() { |
| 13 |
| 14 let timeoutId = window.setTimeout( () => { |
| 15 window.parent.postMessage('fail', '*'); |
| 16 }, ResizeTestHelper.TIMEOUT); |
| 17 |
| 18 let ro = new ResizeObserver(function(entries) { |
| 19 window.clearTimeout(timeoutId); |
| 20 window.parent.postMessage('success', '*'); |
| 21 }); |
| 22 |
| 23 ro.observe(t1); |
| 24 } |
| 25 |
| 26 let testStarted = false; |
| 27 |
| 28 window.addEventListener('message', function(ev) { |
| 29 switch(ev.data) { |
| 30 case 'startTest': |
| 31 testStarted = true; |
| 32 test0(); |
| 33 break; |
| 34 } |
| 35 }); |
| 36 |
| 37 // How does parent know we've loaded problem is solved by |
| 38 // broadcasting readyToTest message. |
| 39 function broadcastReady() { |
| 40 if (!testStarted) { |
| 41 window.parent.postMessage('readyToTest', '*'); |
| 42 window.requestAnimationFrame(broadcastReady); |
| 43 } |
| 44 } |
| 45 |
| 46 broadcastReady(); |
| 47 </script> |
OLD | NEW |