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