Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: LayoutTests/fast/images/image-distorted-aspect-ratios.html

Issue 136823005: Fix distorted image issue when open some images in a new browser window. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: create renderer to get correct size Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/images/image-distorted-aspect-ratios.html
diff --git a/LayoutTests/fast/images/image-distorted-aspect-ratios.html b/LayoutTests/fast/images/image-distorted-aspect-ratios.html
new file mode 100644
index 0000000000000000000000000000000000000000..3bc62c0f84ff5a9903be7a52cb7ea6acab6c734a
--- /dev/null
+++ b/LayoutTests/fast/images/image-distorted-aspect-ratios.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
esprehn 2014/02/19 02:13:02 We often leave off the <html>, <body> and <head> e
+<script>
+var newwindow;
+var imageWidthBeforeReload;
+var imageHeightBeforeReload;
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.setPopupBlockingEnabled(false);
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+ testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+ var console = document.getElementById("console");
+ console.appendChild(document.createTextNode(message));
+}
+
+function loadImageInNewWindow()
esprehn 2014/02/19 02:13:02 onload = function() {
+{
+ newwindow = window.open("resources/image-distorted-aspect-ratios.jpg");
+ if (window.testRunner) {
+ testRunner.useUnfortunateSynchronousResizeMode();
+
+ newwindow.onload = function() {
+ newwindow.onresize = function() {
+ var image = newwindow.document.querySelector("img");
+ if (image.clientWidth == 0) {
+ // On GTK+, sometimes the resize callback fires before the GTK
+ // window has finished resizing. If that happens, try to resize
+ // again.
+ setTimeout(function() {
+ newwindow.resizeTo(360, 360);
+ }, 0);
+ return;
+ } else {
+ imageWidthBeforeReload = image.clientWidth;
+ imageHeightBeforeReload = image.clientHeight;
+ newwindow.location.reload();
+ setTimeout(function() {
+ var image = newwindow.document.querySelector("img");
+ if (image.clientWidth == imageWidthBeforeReload &&
+ image.clientHeight == imageHeightBeforeReload &&
+ image.clientWidth < image.clientHeight) {
+ log("Test passed! The image's aspect ratios is correct.");
+ } else {
+ log("Test failed! The image size before reload was " +
+ imageWidthBeforeReload + "x" + imageHeightBeforeReload +
+ ", and the image size after reload is " +
+ image.clientWidth + "x" + image.clientHeight +
+ ". The image width should be less than height.");
esprehn 2014/02/19 02:13:02 This test could probably be better written with js
+ }
+ testRunner.notifyDone();
+ }, 1000);
+ }
+ };
+ newwindow.resizeTo(360, 360);
+ };
+ }
+}
+</script>
+<body onload="loadImageInNewWindow()">
+<pre id="console"></pre>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/images/image-distorted-aspect-ratios-expected.txt » ('j') | Source/core/html/ImageDocument.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698