1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/embedding/test/test_window_open_position_constraint.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for Bug 978847</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.10 +</head> 1.11 +<body> 1.12 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=978847">Mozilla Bug 978847</a> 1.13 +<p id="display"></p> 1.14 +</div> 1.15 +<pre id="test"> 1.16 +<script class="testbody" type="text/javascript"> 1.17 +SimpleTest.waitForExplicitFinish(); 1.18 + 1.19 +SimpleTest.waitForFocus(function() { 1.20 + var x; 1.21 + var y; 1.22 + 1.23 + // window should be constrained to the screen rect, 1.24 + // which we assume is less than 10000px square 1.25 + var w1 = window.open("about:blank", "", "left=16000,top=16000,width=100,height=100"); 1.26 + SimpleTest.waitForFocus(function() { 1.27 + ok(w1.screenX < 10000 && w1.screenY < 10000, 1.28 + "window should not be opened off-screen: got location " + 1.29 + w1.screenX + "," + w1.screenY); 1.30 + x = w1.screenX; 1.31 + y = w1.screenY; 1.32 + w1.close(); 1.33 + 1.34 + // larger window dimensions should result in a shift of the constrained location 1.35 + var w2 = window.open("about:blank", "", "left=16000,top=16000,width=150,height=150"); 1.36 + SimpleTest.waitForFocus(function() { 1.37 + ok(w2.screenX == x - 50 && w2.screenY == y - 50, 1.38 + "constrained window position did not depend on size as expected: got " + 1.39 + w2.screenX + "," + w2.screenY + ", expected " + (x - 50) + "," + (y - 50)); 1.40 + w2.close(); 1.41 + 1.42 + // now try with coordinates that are close to MAXINT, 1.43 + // so adding width/height risks 32-bit integer overflow 1.44 + var w3 = window.open("about:blank", "", "left=2147483600,top=2147483600,width=100,height=100"); 1.45 + SimpleTest.waitForFocus(function() { 1.46 + ok(w3.screenX < 10000 && w3.screenY < 10000, 1.47 + "window should not be opened off-screen: got location " + 1.48 + w3.screenX + "," + w3.screenY); 1.49 + w3.close(); 1.50 + SimpleTest.finish(); 1.51 + }, w3, true); 1.52 + }, w2, true); 1.53 + }, w1, true); 1.54 +}, window, false); 1.55 + 1.56 +</script> 1.57 +</pre> 1.58 +</body> 1.59 +</html>