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

Unified Diff: LayoutTests/fast/images/image-click-scale-restore-zoomed-image.html

Issue 262053005: Allow zoom/restore in a zoomed document. It is a regression from an earlier fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased code Created 6 years, 6 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
« no previous file with comments | « no previous file | LayoutTests/fast/images/image-click-scale-restore-zoomed-image-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/images/image-click-scale-restore-zoomed-image.html
diff --git a/LayoutTests/fast/images/image-click-scale-restore-zoomed-image.html b/LayoutTests/fast/images/image-click-scale-restore-zoomed-image.html
new file mode 100644
index 0000000000000000000000000000000000000000..ae5b8899e099fbad5e2838986e9ed83aa82310d7
--- /dev/null
+++ b/LayoutTests/fast/images/image-click-scale-restore-zoomed-image.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+
+<script>
+var clicked = false;
+var count = 0;
+var requestId = 0;
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows();
+ testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+ var console = document.getElementById("console");
+ console.appendChild(document.createTextNode(message + "\n"));
+}
+
+function click(newwindow, image)
+{
+ var e = newwindow.document.createEvent("MouseEvent");
+ e.initMouseEvent("click", true, true, newwindow, 1, 1, 1, 1, 1, false, false, false, false, 0, newwindow.document);
+ image.dispatchEvent(e);
+}
+
+window.onload = function()
+{
+ var newwindow = window.open("resources/flowchart.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.
+ requestId = newWindow.requestAnimationFrame(function() {
+ newwindow.resizeTo(100, 100);
+ if (requestId)
+ newwindow.cancelAnimationFrame(requestId);
+ requestId = 0;
+ });
+ return;
+ }
+
+ if (window.eventSender) {
+ if (!clicked) {
+ // Zoom in level 1
+ eventSender.zoomPageIn();
+ var w = Math.round(image.clientWidth);
+ var h = Math.round(image.clientHeight);
+ log("Size at zoomed in level : " + w + " x " + h);
+ clicked = true;
+ count++;
+ click(newwindow, image);
+ } else {
+ var w = Math.round(image.clientWidth);
+ var h = Math.round(image.clientHeight);
+ log("Size at zoomed level after scale up click " + count + " : " + w + " x " + h);
+ if (count == 3)
+ testRunner.notifyDone();
+
+ // Restore the image size
+ click(newwindow, image);
+ count++;
+ // Brings to normal zoom
+ eventSender.zoomPageOut();
+ // Zoom out level 1
+ eventSender.zoomPageOut();
+ // Restore the image size
+ var w = Math.round(image.clientWidth);
+ var h = Math.round(image.clientHeight);
+ log("Size at zoomed out level after click " + count + " (Image restored): " + w + " x " + h);
+ count++;
+ click(newwindow, image);
+ }
+ }
+ };
+
+ newwindow.resizeTo(100, 100);
+ };
+}
+</script>
+<p>This tests that on a zoomed page, click to scale up / down works fine. This test requires testRunner to run. To test manually, open <a href="resources/dice.png">this image</a> in a browser window, resize the window to 100px tall and zoom out and click on the image to scale it up.</p>
+<pre id="console"></pre>
« no previous file with comments | « no previous file | LayoutTests/fast/images/image-click-scale-restore-zoomed-image-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698