<!DOCTYPE html>
<table style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="1">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"></td>
<td style="vertical-align: top; text-align: center;"><a id="2" href="a">2</a></td>
<td style="vertical-align: top; text-align: center;"></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="4" href="a">4</a></td>
<td style="vertical-align: top; text-align: center;"><textarea id="start" rows="5" cols="2">abc d</textarea>
<td style="vertical-align: top; text-align: center;"><a id="6" href="a">6</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"></td>
<td style="vertical-align: top; text-align: center;"><a id="8" href="a">8</a></td>
<td style="vertical-align: top; text-align: center;"></td>
</tr>
</tbody>
</table>
<p>
This test ensures the correctness of Spatial Navigation (SNav) algorithm over textarea.<br>
* Navigation steps:<br>
1) Loads this page, focus goes to "start" automatically.<br>
2) Focus moves away from textarea in 4 different directions to neighbor nodes and back.<br>
</p>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Down", "start"],
["Down", "start"],
["Down", "8"],
["Up", "start"], // The caret is at the end of TEXTAREA.
["Up", "start"], // The caret is at the beginning of TEXTAREA.
["Up", "2"],
["Down", "start"],
["Right", "start"],
["Right", "start"],
["Right", "start"],
["Right", "start"],
["Right", "start"], // The caret is at the end of TEXTAREA.
["Right", "6"],
["Left", "start"], // The caret is at the end of TEXTAREA.
["Left", "start"],
["Left", "start"],
["Left", "start"],
["Left", "start"],
["Left", "start"], // The caret is at the beginning of TEXTAREA.
["Left", "4"],
["Right", "start"]
];
var textarea = document.getElementById("start");
textarea.value = "abc\nd";
// Start at a known place.
textarea.focus();
textarea.setSelectionRange(0, 0);
snav.assertFocusMoves(resultMap, true, postFocusMoveCheck);
function postFocusMoveCheck() {
document.getElementById("start").value = "";
var text = "A text containing a space\nand a new line";
for (var i = 0; i < text.length; ++i) {
var key = text.charAt(i);
if (key == "\n")
key = "Enter";
eventSender.keyDown(key);
}
assert_equals(document.getElementById("start").value, text);
}
</script>