Bug 659338, move resizer test to chrome, but leave content-specific test as a content test

This commit is contained in:
Neil Deakin 2011-09-29 16:05:10 -04:00
Родитель 2e296597cb
Коммит 54cf8feac0
5 изменённых файлов: 62 добавлений и 37 удалений

Просмотреть файл

@ -55,7 +55,9 @@ _CHROME_FILES = test_bug381167.xhtml \
$(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)

Просмотреть файл

@ -1,14 +1,13 @@
<?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">
@ -68,7 +67,6 @@ XUL <resizer> tests
}
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 {
@ -79,18 +77,8 @@ XUL <resizer> tests
}
}
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");
}

Просмотреть файл

@ -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>

Просмотреть файл

@ -2,7 +2,7 @@
<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;
@ -46,22 +46,14 @@ function doTest() {
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),
@ -98,7 +90,7 @@ function doTest() {
});
window.close();
window.opener.nextResizerTest();
window.opener.lastResizerTest();
}
]]></script>
<hbox id="container" flex="1">

Просмотреть файл

@ -1,7 +1,7 @@
<?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;
@ -43,15 +43,16 @@ function testResizer(resizerid, noShrink, hResize, vResize, testid)
" " + 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");
}
}
}