Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE html>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=369370
5 -->
6 <head>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8 <title>Test for Bug 369370</title>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <script type="text/javascript">
14 /*
15 * Test strategy:
16 */
17 function makeClickFor(x, y) {
18 var event = kidDoc.createEvent("mouseevent");
19 event.initMouseEvent("click",
20 true, true, kidWin, 1, // bubbles, cancelable, view, single-click
21 x, y, x, y, // screen X/Y, client X/Y
22 false, false, false, false, // no key modifiers
23 0, null); // left click, not relatedTarget
24 return event;
25 }
27 function childLoaded() {
28 kidDoc = kidWin.document;
29 ok(true, "Child window loaded");
31 var elements = kidDoc.getElementsByTagName("img");
32 is(elements.length, 1, "looking for imagedoc img");
33 var img = elements[0];
35 // Need to use innerWidth/innerHeight of the window
36 // since the containing image is absolutely positioned,
37 // causing clientHeight to be zero.
38 is(kidWin.innerWidth, 400, "Checking doc width");
39 is(kidWin.innerHeight, 300, "Checking doc height");
41 // Image just loaded and is scaled to window size.
42 is(img.width, 400, "image width");
43 is(img.height, 300, "image height");
44 is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft");
45 is(kidDoc.body.scrollTop, 0, "Checking scrollTop");
47 // ========== test 1 ==========
48 // Click in the upper left to zoom in
49 var event = makeClickFor(25,25);
50 img.dispatchEvent(event);
51 ok(true, "----- click 1 -----");
53 is(img.width, 800, "image width");
54 is(img.height, 600, "image height");
55 is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft");
56 is(kidDoc.body.scrollTop, 0, "Checking scrollTop");
58 // ========== test 2 ==========
59 // Click there again to zoom out
60 event = makeClickFor(25,25);
61 img.dispatchEvent(event);
62 ok(true, "----- click 2 -----");
64 is(img.width, 400, "image width");
65 is(img.height, 300, "image height");
66 is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft");
67 is(kidDoc.body.scrollTop, 0, "Checking scrollTop");
69 // ========== test 3 ==========
70 // Click in the lower right to zoom in
71 event = makeClickFor(350, 250);
72 img.dispatchEvent(event);
73 ok(true, "----- click 3 -----");
75 is(img.width, 800, "image width");
76 is(img.height, 600, "image height");
77 is(kidDoc.body.scrollLeft, 400, "Checking scrollLeft");
78 is(kidDoc.body.scrollTop, 300, "Checking scrollTop");
80 // ========== test 4 ==========
81 // Click there again to zoom out
82 event = makeClickFor(350, 250);
83 img.dispatchEvent(event);
84 ok(true, "----- click 4 -----");
86 is(img.width, 400, "image width");
87 is(img.height, 300, "image height");
88 is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft");
89 is(kidDoc.body.scrollTop, 0, "Checking scrollTop");
91 kidWin.close();
92 SpecialPowers.clearUserPref("browser.enable_automatic_image_resizing");
93 SimpleTest.finish();
94 }
96 SimpleTest.waitForExplicitFinish();
97 SpecialPowers.setBoolPref("browser.enable_automatic_image_resizing", true);
99 var kidWin = window.open("bug369370-popup.png", "bug369370", "width=400,height=300");
100 var kidDoc; // will init onload
101 ok(kidWin, "opened child window");
102 kidWin.onload = childLoaded;
103 </script>
104 </body>
105 </html>