bug 978847 - test for window opened at extreme off-screen coordinates. r=roc
authorJonathan Kew <jkew@mozilla.com>
Thu, 20 Mar 2014 09:46:43 +0000
changeset 174431 9456eb36466e46e21568d20856680f87524878aa
parent 174430 39957fc8a90461bac888a58c2d756a19b4cb6974
child 174432 bb274bf64633389f55a64a9ae6e3825e84041f75
push id41288
push userjkew@mozilla.com
push dateThu, 20 Mar 2014 09:47:15 +0000
treeherdermozilla-inbound@9456eb36466e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs978847
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 978847 - test for window opened at extreme off-screen coordinates. r=roc
embedding/test/mochitest.ini
embedding/test/test_window_open_position_constraint.html
--- a/embedding/test/mochitest.ini
+++ b/embedding/test/mochitest.ini
@@ -6,10 +6,12 @@ support-files =
   bug449141_page.html
 
 [test_bug293834.html]
 [test_bug449141.html]
 skip-if = toolkit == 'android'
 [test_bug499115.html]
 [test_nsFind.html]
 [test_private_window_from_content.html]
+[test_window_open_position_constraint.html]
+skip-if = toolkit == 'android'
 [test_window_open_units.html]
 skip-if = toolkit == 'android' || e10s
new file mode 100644
--- /dev/null
+++ b/embedding/test/test_window_open_position_constraint.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug 978847</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=978847">Mozilla Bug 978847</a>
+<p id="display"></p>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+SimpleTest.waitForFocus(function() {
+  var x;
+  var y;
+
+  // window should be constrained to the screen rect,
+  // which we assume is less than 10000px square
+  var w1 = window.open("about:blank", "", "left=16000,top=16000,width=100,height=100");
+  SimpleTest.waitForFocus(function() {
+    ok(w1.screenX < 10000 && w1.screenY < 10000,
+       "window should not be opened off-screen: got location " +
+       w1.screenX + "," + w1.screenY);
+    x = w1.screenX;
+    y = w1.screenY;
+    w1.close();
+  }, w1, true);
+
+  // larger window dimensions should result in a shift of the constrained location
+  var w2 = window.open("about:blank", "", "left=16000,top=16000,width=150,height=150");
+  SimpleTest.waitForFocus(function() {
+    ok(w2.screenX == x - 50 && w2.screenY == y - 50,
+       "constrained window position did not depend on size as expected: got " +
+       w2.screenX + "," + w2.screenY + ", expected " + (x - 50) + "," + (y - 50));
+    w2.close();
+  }, w2, true);
+
+  // now try with coordinates that are close to MAXINT,
+  // so adding width/height risks 32-bit integer overflow
+  var w3 = window.open("about:blank", "", "left=2147483600,top=2147483600,width=100,height=100");
+  SimpleTest.waitForFocus(function() {
+    ok(w3.screenX < 10000 && w3.screenY < 10000,
+       "window should not be opened off-screen: got location " +
+       w3.screenX + "," + w3.screenY);
+    w3.close();
+    SimpleTest.finish();
+  }, w3, true);
+
+}, window, false);
+
+</script>
+</pre>
+</body>
+</html>