helper_wide_crossorigin_iframe_child.html (1925B)
1 <!DOCTYPE html> 2 <html id="helper_wide_crossorigin_iframe_child_docelement"> 3 <meta charset=utf-8> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <script src="apz_test_utils.js"></script> 6 <script src="apz_test_native_event_utils.js"></script> 7 <style> 8 html { 9 border: 5px solid lime; 10 background: yellow; 11 box-sizing: border-box; 12 overflow-y: scroll; 13 } 14 </style> 15 <script> 16 // negative means keep sending forever 17 // we flip this to 10 when we hit onload, so that we send several 18 // before load and some after. 19 let numMoreTimesToSend = -1; 20 function sendDpToParent() { 21 if (numMoreTimesToSend > 0) { 22 numMoreTimesToSend--; 23 } 24 if (numMoreTimesToSend == 0) { 25 clearInterval(intervalId); 26 parent.postMessage("wereDone", "*"); 27 return; 28 } 29 let dp = getLastContentDisplayportFor( 30 "helper_wide_crossorigin_iframe_child_docelement", 31 { expectPainted: false } 32 ); 33 if (dp != null) { 34 info("result " + dp.x + " " + dp.y + " " + dp.width + " " + dp.height); 35 36 parent.postMessage(dp, "*"); 37 } else { 38 info("no dp yet"); 39 } 40 } 41 42 sendDpToParent(); 43 setTimeout(sendDpToParent,0); 44 45 let intervalId = setInterval(sendDpToParent, 100); 46 47 addEventListener("MozAfterPaint", sendAndSetTimeout); 48 function sendAndSetTimeout() { 49 sendDpToParent(); 50 setTimeout(sendDpToParent,0); 51 } 52 53 window.requestAnimationFrame(checkAndSendRaf); 54 function checkAndSendRaf() { 55 if (numMoreTimesToSend != 0) { 56 window.requestAnimationFrame(checkAndSendRaf); 57 } 58 sendDpToParent(); 59 setTimeout(sendDpToParent,0); 60 } 61 62 window.onload = onloaded; 63 window.onDOMContentLoaded = sendDpToParent; 64 document.onreadystatechange = sendDpToParent; 65 document.onvisibilitychange = sendDpToParent; 66 function onloaded() { 67 numMoreTimesToSend = 10; 68 sendDpToParent(); 69 } 70 71 </script> 72 <div style="background: blue; height: 400vh;"></div>