OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <script> |
| 4 var newwindow; |
| 5 var imageWidthBeforeReload; |
| 6 var imageHeightBeforeReload; |
| 7 if (window.testRunner) { |
| 8 testRunner.dumpAsText(); |
| 9 testRunner.setCanOpenWindows(); |
| 10 testRunner.setPopupBlockingEnabled(false); |
| 11 testRunner.setCloseRemainingWindowsWhenComplete(true); |
| 12 testRunner.waitUntilDone(); |
| 13 } |
| 14 |
| 15 function log(message) |
| 16 { |
| 17 var console = document.getElementById("console"); |
| 18 console.appendChild(document.createTextNode(message)); |
| 19 } |
| 20 |
| 21 function loadImageInNewWindow() |
| 22 { |
| 23 newwindow = window.open("resources/image-distorted-aspect-ratios.jpg"); |
| 24 if (window.testRunner) { |
| 25 testRunner.useUnfortunateSynchronousResizeMode(); |
| 26 |
| 27 newwindow.onload = function() { |
| 28 newwindow.onresize = function() { |
| 29 var image = newwindow.document.querySelector("img"); |
| 30 if (image.clientWidth == 0) { |
| 31 // On GTK+, sometimes the resize callback fires before the GTK |
| 32 // window has finished resizing. If that happens, try to resize |
| 33 // again. |
| 34 setTimeout(function() { |
| 35 newwindow.resizeTo(360, 360); |
| 36 }, 0); |
| 37 return; |
| 38 } else { |
| 39 imageWidthBeforeReload = image.clientWidth; |
| 40 imageHeightBeforeReload = image.clientHeight; |
| 41 newwindow.location.reload(); |
| 42 setTimeout(function() { |
| 43 var image = newwindow.document.querySelector("img"); |
| 44 if (image.clientWidth == imageWidthBeforeReload && |
| 45 image.clientHeight == imageHeightBeforeReload && |
| 46 image.clientWidth < image.clientHeight) { |
| 47 log("Test passed! The image's aspect ratios is correct."); |
| 48 } else { |
| 49 log("Test failed! The image size before reload was " + |
| 50 imageWidthBeforeReload + "x" + imageHeightBeforeReload + |
| 51 ", and the image size after reload is " + |
| 52 image.clientWidth + "x" + image.clientHeight + |
| 53 ". The image width should be less than height."); |
| 54 } |
| 55 testRunner.notifyDone(); |
| 56 }, 1000); |
| 57 } |
| 58 }; |
| 59 newwindow.resizeTo(360, 360); |
| 60 }; |
| 61 } |
| 62 } |
| 63 </script> |
| 64 <body onload="loadImageInNewWindow()"> |
| 65 <pre id="console"></pre> |
| 66 </body> |
| 67 </html> |
OLD | NEW |