content/html/document/test/test_bug369370.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial