Bug 956162 - Tests - Implement @flip="none" for popups to allow them to appear off-screen without flipping or resizing. r=Enn
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 22 Jan 2014 20:09:03 +0000
changeset 164992 822ce3170f0f8f457888c0ca8e9e47bce9ce4c9b
parent 164991 e61a79610e6894b0f9b4515f9a2b6bea4766f756
child 164993 7d6daa084033cf2afb3fa8c37e4cd75db37cd6ac
push id38871
push usercbook@mozilla.com
push dateFri, 24 Jan 2014 08:28:29 +0000
treeherdermozilla-inbound@8be30d3b0b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs956162
milestone29.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 956162 - Tests - Implement @flip="none" for popups to allow them to appear off-screen without flipping or resizing. r=Enn [Australis]
toolkit/content/tests/chrome/window_panel.xul
--- a/toolkit/content/tests/chrome/window_panel.xul
+++ b/toolkit/content/tests/chrome/window_panel.xul
@@ -249,17 +249,64 @@ var tests = [
         synthesizeMouse(backdragspot, 5, 5, { type: "mousedown" });
         synthesizeMouse(backdragspot, 15, 20, { type: "mousemove" });
         synthesizeMouse(backdragspot, 15, 20, { type: "mouseup" });
 
         is(panel.getOuterScreenRect().left, 210, testname + "left");
         is(panel.getOuterScreenRect().top, 245, testname + "top");
       }
     }
-  }
+  },
+  {
+    // The panel should be allowed to appear and remain offscreen
+    testname: "normal panel with flip='none' off-screen",
+    attrs: { "flip": "none" },
+    test: function(panel) {
+      panel.openPopup(document.documentElement, "", -100 - mozInnerScreenX, -100 - mozInnerScreenY, false, false, null);
+    },
+    result: function(testname, panel) {
+      var panelrect = panel.getBoundingClientRect();
+      is(panelrect.left, -100 - mozInnerScreenX, testname + "left");
+      is(panelrect.top, -100 - mozInnerScreenY, testname + "top");
+      is(panelrect.width, 120, testname + "width");
+      is(panelrect.height, 40, testname + "height");
+
+      var screenRect = panel.getOuterScreenRect();
+      is(screenRect.left, -100, testname + " screen left");
+      is(screenRect.top, -100, testname + " screen top");
+      is(screenRect.width, 120, testname + " screen width");
+      is(screenRect.height, 40, testname + " screen height");
+    }
+  },
+  {
+    // The panel should be allowed to remain offscreen after moving and it should follow the anchor
+    testname: "normal panel with flip='none' moved off-screen",
+    attrs: { "flip": "none" },
+    test: function(panel) {
+      panel.openPopup(document.documentElement, "", -100 - mozInnerScreenX, -100 - mozInnerScreenY, false, false, null);
+      window.moveBy(-50, -50);
+    },
+    result: function(testname, panel) {
+      if (navigator.platform.indexOf("Linux") >= 0) {
+        // The window position doesn't get updated immediately on Linux.
+        return;
+      }
+      var panelrect = panel.getBoundingClientRect();
+      is(panelrect.left, -150 - mozInnerScreenX, testname + "left");
+      is(panelrect.top, -150 - mozInnerScreenY, testname + "top");
+      is(panelrect.width, 120, testname + "width");
+      is(panelrect.height, 40, testname + "height");
+
+      var screenRect = panel.getOuterScreenRect();
+      is(screenRect.left, -150, testname + " screen left");
+      is(screenRect.top, -150, testname + " screen top");
+      is(screenRect.width, 120, testname + " screen width");
+      is(screenRect.height, 40, testname + " screen height");
+    }
+  },
 ];
 
 window.opener.wrappedJSObject.SimpleTest.waitForFocus(test_panels, window);
 
 ]]>
 </script>
 
 </window>