1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/html/document/test/test_bug369370.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,105 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=369370 1.8 +--> 1.9 +<head> 1.10 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 1.11 + <title>Test for Bug 369370</title> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.14 +</head> 1.15 +<body> 1.16 + <script type="text/javascript"> 1.17 + /* 1.18 + * Test strategy: 1.19 + */ 1.20 + function makeClickFor(x, y) { 1.21 + var event = kidDoc.createEvent("mouseevent"); 1.22 + event.initMouseEvent("click", 1.23 + true, true, kidWin, 1, // bubbles, cancelable, view, single-click 1.24 + x, y, x, y, // screen X/Y, client X/Y 1.25 + false, false, false, false, // no key modifiers 1.26 + 0, null); // left click, not relatedTarget 1.27 + return event; 1.28 + } 1.29 + 1.30 + function childLoaded() { 1.31 + kidDoc = kidWin.document; 1.32 + ok(true, "Child window loaded"); 1.33 + 1.34 + var elements = kidDoc.getElementsByTagName("img"); 1.35 + is(elements.length, 1, "looking for imagedoc img"); 1.36 + var img = elements[0]; 1.37 + 1.38 + // Need to use innerWidth/innerHeight of the window 1.39 + // since the containing image is absolutely positioned, 1.40 + // causing clientHeight to be zero. 1.41 + is(kidWin.innerWidth, 400, "Checking doc width"); 1.42 + is(kidWin.innerHeight, 300, "Checking doc height"); 1.43 + 1.44 + // Image just loaded and is scaled to window size. 1.45 + is(img.width, 400, "image width"); 1.46 + is(img.height, 300, "image height"); 1.47 + is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft"); 1.48 + is(kidDoc.body.scrollTop, 0, "Checking scrollTop"); 1.49 + 1.50 + // ========== test 1 ========== 1.51 + // Click in the upper left to zoom in 1.52 + var event = makeClickFor(25,25); 1.53 + img.dispatchEvent(event); 1.54 + ok(true, "----- click 1 -----"); 1.55 + 1.56 + is(img.width, 800, "image width"); 1.57 + is(img.height, 600, "image height"); 1.58 + is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft"); 1.59 + is(kidDoc.body.scrollTop, 0, "Checking scrollTop"); 1.60 + 1.61 + // ========== test 2 ========== 1.62 + // Click there again to zoom out 1.63 + event = makeClickFor(25,25); 1.64 + img.dispatchEvent(event); 1.65 + ok(true, "----- click 2 -----"); 1.66 + 1.67 + is(img.width, 400, "image width"); 1.68 + is(img.height, 300, "image height"); 1.69 + is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft"); 1.70 + is(kidDoc.body.scrollTop, 0, "Checking scrollTop"); 1.71 + 1.72 + // ========== test 3 ========== 1.73 + // Click in the lower right to zoom in 1.74 + event = makeClickFor(350, 250); 1.75 + img.dispatchEvent(event); 1.76 + ok(true, "----- click 3 -----"); 1.77 + 1.78 + is(img.width, 800, "image width"); 1.79 + is(img.height, 600, "image height"); 1.80 + is(kidDoc.body.scrollLeft, 400, "Checking scrollLeft"); 1.81 + is(kidDoc.body.scrollTop, 300, "Checking scrollTop"); 1.82 + 1.83 + // ========== test 4 ========== 1.84 + // Click there again to zoom out 1.85 + event = makeClickFor(350, 250); 1.86 + img.dispatchEvent(event); 1.87 + ok(true, "----- click 4 -----"); 1.88 + 1.89 + is(img.width, 400, "image width"); 1.90 + is(img.height, 300, "image height"); 1.91 + is(kidDoc.body.scrollLeft, 0, "Checking scrollLeft"); 1.92 + is(kidDoc.body.scrollTop, 0, "Checking scrollTop"); 1.93 + 1.94 + kidWin.close(); 1.95 + SpecialPowers.clearUserPref("browser.enable_automatic_image_resizing"); 1.96 + SimpleTest.finish(); 1.97 + } 1.98 + 1.99 + SimpleTest.waitForExplicitFinish(); 1.100 + SpecialPowers.setBoolPref("browser.enable_automatic_image_resizing", true); 1.101 + 1.102 + var kidWin = window.open("bug369370-popup.png", "bug369370", "width=400,height=300"); 1.103 + var kidDoc; // will init onload 1.104 + ok(kidWin, "opened child window"); 1.105 + kidWin.onload = childLoaded; 1.106 + </script> 1.107 +</body> 1.108 +</html>