gecko/layout/html/tests/table/other/move_row.html

51 lines
1.1 KiB
HTML
Raw Normal View History

<html>
<script>
function moveRow(from, to)
{
if (from == -1 && to == -1)
{
var fromE = document.getElementsByTagName("INPUT")[0];
from = parseInt(fromE.value);
var toE = document.getElementsByTagName("INPUT")[1];
to = parseInt(toE.value);
}
var row = document.getElementsByTagName("TR")[from];
row.rowIndex = to;
}
function runTests()
{
// Test fails if final ordering differs from initial ordering
//
// Starting with order 0,1,2,3,4,5 shift through the rows and
// end up back where we started.
moveRow(0, 5);
moveRow(1, 4);
moveRow(2, 3);
moveRow(3, 2);
moveRow(4, 1);
moveRow(5, 0);
// Throw 2 out-of-bounds tests at the end and still get back to the starting point.
moveRow(5, -1);
moveRow(0, 6);
}
function delay()
{
setTimeout("runTests()", 9);
}
</script>
<body bgcolor=white onload="delay()">
<table>
<tr><td>Row 0</td></tr>
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
<tr><td>Row 4</td></tr>
<tr><td>Row 5</td></tr>
</table>
<input type=text name=from value=2 size=1>
<input type=text name=to value=4 size=1>
<input type=button name=go value=go onclick="moveRow(-1,-1);">
</body>
</html>