1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
<html>
<head>
<script>
var w;
function Open(sFeatures)
{
if (w && !w.closed)
w.close();
w = window.open("resources/popup200x200.html", "popup", sFeatures);
}
function test1()
{
Open("width=200, height=200, left = 0, top = 0, scrollbars, resizable");
setConsole(document.getElementById('console1'));
clearConsole();
shouldBe("w.innerHeight", 200);
shouldBe("w.innerWidth", 200);
shouldBe("w.outerWidth", 200);
shouldBe("w.screenLeft", 0);
shouldBe("w.screenTop", 22); // empirical result of low dpi testing
shouldBe("w.outerHeight", 223); // empirical result of low dpi testing
}
function test2()
{
console = document.getElementById('console2');
Open("width=200, height=200, left = 0, top = 0, scrollbars, menubar, status, toolbar, resizable");
setConsole(document.getElementById('console2'));
clearConsole();
shouldBe("w.innerHeight", 200);
shouldBe("w.innerWidth", 200);
shouldBe("w.outerWidth", 200);
shouldBe("w.screenLeft", 0);
shouldBe("w.screenTop", 22); // empirical result of low dpi testing
shouldBe("w.outerHeight", 313); // empirical result of low dpi testing
}
function test3()
{
Open("width=200,height=200,left=" + (screen.width - 200) + ",screenY=0, resizable");
w.moveBy(0, screen.height - w.screenTop - w.outerHeight);
// should be no-ops
w.moveTo(w.screenLeft - 100, w.screenTop + 100);
w.moveBy(100, -100);
w.resizeTo(w.outerWidth - 100 , w.outerHeight - 100);
w.resizeBy(100, 100);
setConsole(document.getElementById('console3'));
clearConsole();
shouldBe("w.innerHeight", 200);
shouldBe("w.innerWidth", 200);
shouldBe("w.outerWidth", 200);
shouldBe("w.screenLeft", screen.width - 200);
shouldBe("w.screenTop", screen.height - w.outerHeight);
shouldBe("w.outerHeight", 223); // empirical result of low dpi testing
}
var console;
function print(message, color)
{
var paragraph = document.createElement("div");
paragraph.appendChild(document.createTextNode(message));
paragraph.style.fontFamily = "monospace";
if (color)
paragraph.style.color = color;
console.appendChild(paragraph);
}
function clearConsole()
{
console.innerHTML = "";
}
function setConsole(c)
{
console = c;
}
function shouldBe(a, b)
{
var evalA = eval(a);
if (evalA == b)
print("PASS: " + a + " should be " + b + " and is.", "green");
else
print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
}
</script>
</head>
<body>
<p>This test checks our support for window sizing and positioning.</p>
<p>To test: Click each button below. Check to make sure that the window it opens has the specified attributes.
Also check for a series of 'PASS' messages below the button.</p>
<p style="color:red">NOTE: Make sure to test at magnified resolutions.</p>
<p>To test @ 2X resolution:</p>
<ol>
<li>Open Quartz Debug (/Developer/Applications/Performance Tools).</li>
<li>Select Tools -> Show User Interface Resolution.</li>
<li>Set the resolution to 2.0.</li>
<li>Restart Safari.</li>
</ol>
<hr>
<p>Window size (no toolbars): You should see a red 1 pixel border along every edge of this page, and no scrollbars.</p>
<input type="button" value="open it!" onclick="test1()">
<div id='console1'></div>
<hr>
<p>Window size (all toolbars): You should see a red 1 pixel border along every edge of this page, and no scrollbars.</p>
<input type="button" value="open it!" onclick="test2()">
<div id='console2'></div>
<hr>
<p>Window positioning: This window should be aligned exactly to the bottom right corner of the screen.</p>
<input type="button" value="open it!" onclick="test3()">
<div id='console3'></div>
<hr>
</body>
</html>
|