embedding/test/test_window_open_position_constraint.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 <head>
michael@0 4 <title>Test for Bug 978847</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 7 </head>
michael@0 8 <body>
michael@0 9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=978847">Mozilla Bug 978847</a>
michael@0 10 <p id="display"></p>
michael@0 11 </div>
michael@0 12 <pre id="test">
michael@0 13 <script class="testbody" type="text/javascript">
michael@0 14 SimpleTest.waitForExplicitFinish();
michael@0 15
michael@0 16 SimpleTest.waitForFocus(function() {
michael@0 17 var x;
michael@0 18 var y;
michael@0 19
michael@0 20 // window should be constrained to the screen rect,
michael@0 21 // which we assume is less than 10000px square
michael@0 22 var w1 = window.open("about:blank", "", "left=16000,top=16000,width=100,height=100");
michael@0 23 SimpleTest.waitForFocus(function() {
michael@0 24 ok(w1.screenX < 10000 && w1.screenY < 10000,
michael@0 25 "window should not be opened off-screen: got location " +
michael@0 26 w1.screenX + "," + w1.screenY);
michael@0 27 x = w1.screenX;
michael@0 28 y = w1.screenY;
michael@0 29 w1.close();
michael@0 30
michael@0 31 // larger window dimensions should result in a shift of the constrained location
michael@0 32 var w2 = window.open("about:blank", "", "left=16000,top=16000,width=150,height=150");
michael@0 33 SimpleTest.waitForFocus(function() {
michael@0 34 ok(w2.screenX == x - 50 && w2.screenY == y - 50,
michael@0 35 "constrained window position did not depend on size as expected: got " +
michael@0 36 w2.screenX + "," + w2.screenY + ", expected " + (x - 50) + "," + (y - 50));
michael@0 37 w2.close();
michael@0 38
michael@0 39 // now try with coordinates that are close to MAXINT,
michael@0 40 // so adding width/height risks 32-bit integer overflow
michael@0 41 var w3 = window.open("about:blank", "", "left=2147483600,top=2147483600,width=100,height=100");
michael@0 42 SimpleTest.waitForFocus(function() {
michael@0 43 ok(w3.screenX < 10000 && w3.screenY < 10000,
michael@0 44 "window should not be opened off-screen: got location " +
michael@0 45 w3.screenX + "," + w3.screenY);
michael@0 46 w3.close();
michael@0 47 SimpleTest.finish();
michael@0 48 }, w3, true);
michael@0 49 }, w2, true);
michael@0 50 }, w1, true);
michael@0 51 }, window, false);
michael@0 52
michael@0 53 </script>
michael@0 54 </pre>
michael@0 55 </body>
michael@0 56 </html>

mercurial