Bug 659338, move resizer test to chrome, but leave content-specific test as a content test
authorNeil Deakin <neil@mozilla.com>
Thu, 29 Sep 2011 16:05:10 -0400
changeset 77879 77b3b28682690a9a0d35d719a4ff09715d2319aa
parent 77878 df24b0cffd01c94f421de270b93fec010b6b4fb8
child 77880 071c48a989bb43092da6db95f2f4358ef6e16b97
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs659338
milestone10.0a1
Bug 659338, move resizer test to chrome, but leave content-specific test as a content test
layout/xul/base/test/Makefile.in
layout/xul/base/test/test_resizer.xul
layout/xul/base/test/test_resizer_incontent.xul
layout/xul/base/test/window_resizer.xul
layout/xul/base/test/window_resizer_element.xul
--- a/layout/xul/base/test/Makefile.in
+++ b/layout/xul/base/test/Makefile.in
@@ -50,17 +50,19 @@ include $(topsrcdir)/config/rules.mk
 
 _CHROME_FILES =	test_bug381167.xhtml \
 		test_bug393970.xul \
 		test_bug477754.xul \
 		test_stack.xul \
 		$(NULL)
 
 ifneq (mobile,$(MOZ_BUILD_APP))
-_TEST_FILES +=	test_resizer.xul \
+_TEST_FILES = 	test_resizer_incontent.xul
+
+_CHROME_FILES +=	test_resizer.xul \
 		window_resizer.xul \
 		window_resizer_element.xul \
 		$(NULL)
 endif
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
 
--- a/layout/xul/base/test/test_resizer.xul
+++ b/layout/xul/base/test/test_resizer.xul
@@ -1,19 +1,18 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
-<?xml-stylesheet href="data:text/css,description {min-width: 1px; padding: 2px;}" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 XUL <resizer> tests
 -->
 <window title="XUL resizer tests"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <!-- test results are displayed in the html:body -->
   <body xmlns="http://www.w3.org/1999/xhtml">
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     SimpleTest.waitForExplicitFinish();
@@ -63,39 +62,28 @@ XUL <resizer> tests
     function doResizerWindowTests() {
       step++;
       if (step == 1) {
         openPopup();
         return;
       }
 
       if (/Mac/.test(navigator.platform)) {
-        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
         window.open("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
       }
       else {
         // Skip window_resizer.xul tests.
         todo(false, "We can't test GTK and Windows native drag resizing implementations.");
         // Run window_resizer_element.xul test only.
         lastResizerTest();
       }
     }
 
-    function nextResizerTest()
-    {
-      // try opening the test again as a chrome window
-      if (step++ == 2)
-        window.open("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300");
-      else
-        lastResizerTest();
-    }
-
     function lastResizerTest()
     {
-      netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
       window.open("window_resizer_element.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
     }
 
     SimpleTest.waitForFocus(openPopup);
    ]]></script>
 
 <panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="doResizerWindowTests()">
   <resizer id="resizer" dir="bottomend" width="16" height="16"/>
new file mode 100644
--- /dev/null
+++ b/layout/xul/base/test/test_resizer_incontent.xul
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+This test ensures that a resizer in content doesn't resize the window.
+-->
+<window title="XUL resizer in content test"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  </body>
+
+  <!-- test code goes here -->
+  <script type="application/javascript"><![CDATA[
+    SimpleTest.waitForExplicitFinish();
+
+    function testResizer()
+    { 
+      var oldScreenX = window.screenX;
+      var oldScreenY = window.screenY;
+      var oldWidth = window.outerWidth;
+      var oldHeight = window.outerHeight;
+      var resizer = document.getElementById("resizer");
+      synthesizeMouseAtCenter(resizer, { type:"mousedown" });
+      synthesizeMouse(resizer, 32, 32, { type:"mousemove" });
+      synthesizeMouse(resizer, 32, 32, { type:"mouseup" });
+      is(window.screenX, oldScreenX, "window not moved for non-chrome window screenX");
+      is(window.screenY, oldScreenY, "window not moved for non-chrome window screenY");
+      is(window.outerWidth, oldWidth, "window not moved for non-chrome window outerWidth");
+      is(window.outerHeight, oldHeight, "window not moved for non-chrome window outerHeight");
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForFocus(testResizer);
+   ]]></script>
+
+  <resizer id="resizer" dir="bottomend" width="16" height="16"/>
+
+</window>
--- a/layout/xul/base/test/window_resizer.xul
+++ b/layout/xul/base/test/window_resizer.xul
@@ -1,13 +1,13 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     screenX="200" screenY="200" width="300" height="300"
 	onload="setTimeout(doTest, 0)">
-<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 <script><![CDATA[
 var is = window.opener.SimpleTest.is;
 
 function doTest() {
   // from test_resizer.xul
   var expectX = 200;
   var expectY = 200;
   var expectXMost = 500;
@@ -41,32 +41,24 @@ function doTest() {
         if (dy < 0) {
           newExpectY += mouseY*scale;
         } else if (dy > 0) {
           newExpectYMost += mouseY*scale;
         }
 
         synthesizeMouse(root, offsetX, offsetY, { type:"mousedown" });
         synthesizeMouse(root, offsetX + mouseX*scale, offsetY + mouseY*scale, { type:"mousemove" });
-        if (window instanceof Components.interfaces.nsIDOMChromeWindow) {
-          is(window.screenX*screenScale, newExpectX,
-             "Bad x for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
-          is(window.screenY*screenScale, newExpectY,
-             "Bad y for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
-          is(window.outerWidth, newExpectXMost - newExpectX,
-             "Bad width for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
-          is(window.outerHeight, newExpectYMost - newExpectY,
-             "Bad height for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
-        }
-        else {
-          is(window.screenX, oldScreenX, "window not moved for non-chrome window screenX");
-          is(window.screenY, oldScreenY, "window not moved for non-chrome window screenY");
-          is(window.outerWidth, oldWidth, "window not moved for non-chrome window outerWidth");
-          is(window.outerHeight, oldHeight, "window not moved for non-chrome window outerHeight");
-        }
+        is(window.screenX*screenScale, newExpectX,
+           "Bad x for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+        is(window.screenY*screenScale, newExpectY,
+           "Bad y for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+        is(window.outerWidth, newExpectXMost - newExpectX,
+           "Bad width for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
+        is(window.outerHeight, newExpectYMost - newExpectY,
+           "Bad height for " + dx + "," + dy + " moving " + mouseX + "," + mouseY);
 
         // move it back before we release! Adjust for any window movement
         synthesizeMouse(root, offsetX - (newExpectX - expectX),
                               offsetY - (newExpectY - expectY), { type:"mousemove" });
         synthesizeMouse(root, offsetX, offsetY, { type:"mouseup" });
       }
     }
   }
@@ -93,17 +85,17 @@ function doTest() {
   Array.forEach(resizers, function (element) {
     is(getComputedStyle(element, "").cursor,
        element.dir == "bottomend" ? "sw-resize" :
          element.getAttribute("expectedcursor"),
        "cursor for " + element.dir);
   });
 
   window.close();
-  window.opener.nextResizerTest();
+  window.opener.lastResizerTest();
 }
 ]]></script>
 	<hbox id="container" flex="1">
 		<vbox flex="1">
 			<resizer dir="topleft" expectedcursor="nw-resize" flex="1"/>
 			<resizer dir="left" expectedcursor="ew-resize" flex="1"/>
 			<resizer dir="bottomleft" expectedcursor="sw-resize" flex="1"/>
 		</vbox>
--- a/layout/xul/base/test/window_resizer_element.xul
+++ b/layout/xul/base/test/window_resizer_element.xul
@@ -1,12 +1,12 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         align="start">
-<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 <script><![CDATA[
 var is = window.opener.SimpleTest.is;
 
 const anchorPositions =
   [ "before_start", "before_end", "after_start", "after_end",
     "start_before", "start_after", "end_before", "end_after", "overlap", "screen"];
 var currentPosition;
 
@@ -38,25 +38,26 @@ function testResizer(resizerid, noShrink
 
       var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
       is(Math.round(newrect.width), Math.round(expectedWidth), "resize element " + resizerid +
          " " + testid + " width moving " + mouseX + "," + mouseY + ",,," + hResize);
       is(Math.round(newrect.height), Math.round(expectedHeight), "resize element " + resizerid +
          " " + testid + " height moving " + mouseX + "," + mouseY);
       // release
       synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
-                      originalY + 5 + mouseY * scale, { type:"mouseup" });    }
+                      originalY + 5 + mouseY * scale, { type:"mouseup" });
       // return to the original size
       synthesizeMouse(document.documentElement, originalX + 5 + mouseX * scale,
-                      originalY + 5 + mouseY * scale, { type:"dblclick" });    }
+                      originalY + 5 + mouseY * scale, { type:"dblclick" });
       var newrect = document.getElementById(resizerid + "-container").getBoundingClientRect();
       is(Math.round(newrect.width), Math.round(rect.width), "resize element " + resizerid +
          " " + testid + " doubleclicking to restore original size");
       is(Math.round(newrect.height), Math.round(rect.height), "resize element " + resizerid +
          " " + testid + " doubleclicking to restore original size");
+    }
   }
 }
 
 function doTest() {
   // first, check if a resizer with a element attribute set to an element that
   // does not exist does not cause a problem
   var resizer = document.getElementById("notfound");
   synthesizeMouse(resizer, 5, 5, { type:"mousedown" });