bug583889_inner1.html (1367B)
1 <html> 2 <body> 3 <iframe id="inner" style="height: 10px; width: 10px"></iframe> 4 <div style="width: 1000px; height: 1000px"></div> 5 <script type="application/javascript"> 6 function grabEventAndGo(event) { 7 gen.next(event); 8 } 9 10 function waitAsync() { 11 setTimeout(function() { gen.next() }, 0); 12 } 13 14 function postPos() { 15 parent.postMessage(JSON.stringify({ top: document.body.scrollTop, 16 left: document.body.scrollLeft }), 17 "*"); 18 } 19 20 function* runTest() { 21 var inner = document.getElementById("inner"); 22 window.onload = grabEventAndGo; 23 // Wait for onLoad event. 24 yield; 25 26 document.body.scrollTop = 300; 27 document.body.scrollLeft = 300; 28 29 postPos(); 30 31 inner.src = "bug583889_inner2.html#id1"; 32 inner.onload = grabEventAndGo; 33 // Let parent process sent message. 34 // Wait for onLoad event from 'inner' iframe. 35 yield; 36 37 postPos(); 38 39 inner.onload = null; 40 dump("hi\n"); 41 inner.contentWindow.location = "bug583889_inner2.html#id2" 42 waitAsync(); 43 // Let parent process sent message. 44 // Let 'inner' iframe update itself. 45 yield; 46 47 postPos(); 48 49 inner.contentWindow.location.hash = "#id3" 50 waitAsync(); 51 // Let parent process sent message. 52 // Let 'inner' iframe update itself. 53 yield; 54 55 postPos(); 56 57 parent.postMessage("done", "*"); 58 } 59 60 var gen = runTest(); 61 gen.next(); 62 </script> 63 </body> 64 </html>