2010-03-19 04:49:34 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 477700</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
|
2014-02-06 11:32:05 -08:00
|
|
|
<textarea id="textarea" style="-moz-appearance: none; border: 2px solid black; padding: 3px; box-sizing: border-box; min-width: 15px; min-height: 15px;">Text</textarea>
|
2010-03-19 04:49:34 -07:00
|
|
|
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for textbox resizing **/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addLoadEvent(function() SimpleTest.executeSoon(doTheTest));
|
|
|
|
|
2012-07-27 15:01:13 -07:00
|
|
|
// -1 means use the default value which is 'both', then test explicitly
|
2010-03-19 04:49:34 -07:00
|
|
|
// setting each possible value.
|
2012-07-27 15:01:13 -07:00
|
|
|
var currentResize = -1;
|
2010-03-23 11:52:56 -07:00
|
|
|
var currentBoxSizing = 0;
|
2012-07-27 15:01:13 -07:00
|
|
|
var currentPointer = 0;
|
2010-03-19 04:49:34 -07:00
|
|
|
var resizeTypes = [ "horizontal", "vertical", "none", "inherit", "both" ];
|
2010-03-23 11:52:56 -07:00
|
|
|
var boxSizingTypes = [ "", "border-box", "padding-box" ];
|
2012-07-27 15:01:13 -07:00
|
|
|
var pointerTypes = [ synthesizeMouse, synthesizeTouch]
|
2010-03-19 04:49:34 -07:00
|
|
|
|
|
|
|
function doTheTest() {
|
2012-07-27 15:01:13 -07:00
|
|
|
runTest(pointerTypes[currentPointer]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest(aPointerFunc) {
|
2010-03-23 11:52:56 -07:00
|
|
|
var boxSizingText = " with box sizing " + (currentBoxSizing ? boxSizingTypes[currentBoxSizing] : "content-box");
|
|
|
|
|
2010-03-19 04:49:34 -07:00
|
|
|
var textarea = $("textarea");
|
|
|
|
var rect = textarea.getBoundingClientRect();
|
2012-07-27 15:01:13 -07:00
|
|
|
var touch = aPointerFunc.name.match(/Touch/);
|
|
|
|
// -1 means use the default value of resize, i.e. "both"
|
|
|
|
var type = (currentResize == -1) ? "both" : resizeTypes[currentResize];
|
2010-03-19 04:49:34 -07:00
|
|
|
// assume that the resizer is in the lower right corner
|
2010-03-23 11:52:56 -07:00
|
|
|
|
2012-07-27 15:01:13 -07:00
|
|
|
aPointerFunc(textarea, rect.width - 10, rect.height - 10, { type: touch ? "touchstart" : "mousedown" });
|
|
|
|
aPointerFunc(textarea, rect.width + 40, rect.height + 40, { type: touch ? "touchmove" : "mousemove" });
|
2010-03-19 04:49:34 -07:00
|
|
|
|
|
|
|
var newrect = textarea.getBoundingClientRect();
|
2012-07-27 15:01:13 -07:00
|
|
|
var hchange = (type == "both" || type == "horizontal");
|
|
|
|
var vchange = (type == "both" || type == "vertical");
|
2010-03-19 04:49:34 -07:00
|
|
|
|
2010-03-23 11:52:56 -07:00
|
|
|
is(Math.round(newrect.width), Math.round(rect.width + (hchange ? 50 : 0)),
|
2012-07-27 15:01:13 -07:00
|
|
|
type + " width has increased" + boxSizingText + " using " + aPointerFunc.name);
|
2010-03-23 11:52:56 -07:00
|
|
|
is(Math.round(newrect.height), Math.round(rect.height + (vchange ? 50 : 0)),
|
2012-07-27 15:01:13 -07:00
|
|
|
type + " height has increased" + boxSizingText + " using " + aPointerFunc.name);
|
2010-03-19 04:49:34 -07:00
|
|
|
|
2012-07-27 15:01:13 -07:00
|
|
|
aPointerFunc(textarea, rect.width - 20, rect.height - 20, { type: touch ? "touchmove" : "mousemove" });
|
2010-03-19 04:49:34 -07:00
|
|
|
|
|
|
|
newrect = textarea.getBoundingClientRect();
|
2010-03-23 11:52:56 -07:00
|
|
|
|
|
|
|
is(Math.round(newrect.width), Math.round(rect.width - (hchange ? 10 : 0)),
|
2012-07-27 15:01:13 -07:00
|
|
|
type + " width has decreased" + boxSizingText + " using " + aPointerFunc.name);
|
2010-03-23 11:52:56 -07:00
|
|
|
is(Math.round(newrect.height), Math.round(rect.height - (vchange ? 10 : 0)),
|
2012-07-27 15:01:13 -07:00
|
|
|
type + " height has decreased" + boxSizingText + " using " + aPointerFunc.name);
|
2010-03-19 04:49:34 -07:00
|
|
|
|
2012-07-27 15:01:13 -07:00
|
|
|
aPointerFunc(textarea, rect.width - 220, rect.height - 220, { type: touch ? "touchmove" : "mousemove" });
|
2010-03-19 04:49:34 -07:00
|
|
|
|
|
|
|
newrect = textarea.getBoundingClientRect();
|
|
|
|
ok(hchange ? newrect.width >= 15 : Math.round(newrect.width) == Math.round(rect.width),
|
2012-07-27 15:01:13 -07:00
|
|
|
type + " width decreased below minimum" + boxSizingText + " using " + newrect.width);
|
2010-03-19 04:49:34 -07:00
|
|
|
ok(vchange ? newrect.height >= 15 : Math.round(newrect.height) == Math.round(rect.height),
|
2012-07-27 15:01:13 -07:00
|
|
|
type + " height decreased below minimum" + boxSizingText + " using " + aPointerFunc.name);
|
2010-03-19 04:49:34 -07:00
|
|
|
|
2012-07-27 15:01:13 -07:00
|
|
|
aPointerFunc(textarea, rect.width - 8, rect.height - 8, { type: touch ? "touchend" : "mouseup" });
|
2010-03-19 04:49:34 -07:00
|
|
|
|
2010-03-23 11:52:56 -07:00
|
|
|
textarea.style.width = "auto";
|
|
|
|
textarea.style.height = "auto";
|
|
|
|
|
|
|
|
if (currentBoxSizing++ <= boxSizingTypes.length) {
|
|
|
|
textarea.style.MozBoxSizing = boxSizingTypes[currentBoxSizing];
|
2010-03-19 04:49:34 -07:00
|
|
|
SimpleTest.executeSoon(doTheTest);
|
2012-07-27 15:01:13 -07:00
|
|
|
} else {
|
2010-03-23 11:52:56 -07:00
|
|
|
currentBoxSizing = 0;
|
2012-07-27 15:01:13 -07:00
|
|
|
if (++currentResize < resizeTypes.length) {
|
|
|
|
textarea.style.resize = resizeTypes[currentResize];
|
2010-03-23 11:52:56 -07:00
|
|
|
SimpleTest.executeSoon(doTheTest);
|
2012-07-27 15:01:13 -07:00
|
|
|
} else {
|
|
|
|
currentResize = -1;
|
|
|
|
textarea.style.resize = "";
|
|
|
|
if (++currentPointer < pointerTypes.length) {
|
|
|
|
SimpleTest.executeSoon(doTheTest);
|
|
|
|
} else {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
2010-03-23 11:52:56 -07:00
|
|
|
}
|
2010-03-19 04:49:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|