OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script> |
| 4 var logWin = window.parent.opener; |
| 5 logWin.log('Iframe is being loaded.'); |
| 6 |
| 7 var xhr = new XMLHttpRequest(); |
| 8 xhr.onreadystatechange = function() { |
| 9 logWin.log('xhr onreadystatechange state:' + xhr.readyState); |
| 10 if (xhr.readyState == 4) { |
| 11 var text = xhr.responseText; |
| 12 // Report that the test is finished. |
| 13 logWin.finish(); |
| 14 } |
| 15 } |
| 16 |
| 17 xhr.onerror = function() { |
| 18 logWin.log('xhr onerror:' + xhr.readyState); |
| 19 } |
| 20 |
| 21 // Timeout explanation: |
| 22 // To reproduce the issue, I need the XHR to start but not finish until the |
| 23 // iframe transfer is complete. If I just navigate to some file, the load |
| 24 // actually happens before the iframe is transferred and all the |
| 25 // onreadystatechange notifications are already queued and just fire in the new |
| 26 // page. |
| 27 // The bug, however, deals with XHR being still in progress in the browser |
| 28 // process, so when it is done and comes back with the routing_id of the closed |
| 29 // window, it has no way of finding the original iframe and firing |
| 30 // onreadystatechange. Because of this timeout the test can occasionally produce |
| 31 // false positive (if the reparenting takes longer then 1 second for example), |
| 32 // however this is very unlikely, and it won't make test flakey |
| 33 // (which is usually a false negative). |
| 34 xhr.open('GET', '/slow?1', true); |
| 35 xhr.send(); |
| 36 window.parent.transferIframeAndCloseWindow(); |
| 37 </script> |
| 38 </head> |
| 39 <body> |
| 40 </body> |
| 41 </html> |
OLD | NEW |