<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="resources/extend-selection.css" />
<style>
test_move_by_word {display: none;}
</style>
<script src="resources/move-by-word-visually.js"></script>
<script>

onload = function() {
    try {
        runTest();
    } finally {
        flushLog();
    }
};

if (window.testRunner && window.internals) {
    testRunner.dumpAsText();
    internals.settings.setEditingBehavior('windows');
}
</script>
</head>
<body>
<div id="testMoveByWord">
<!-- 
Title saves the word breaks.
The format of title is "xxx|xxxx".

The sequence on the left of "|" is word boundaries when moving caret from left to right.
The sequence on the right of "|" is word boundaries when moving caret from right to left.

If there is a single node in the line, the sequence are offsets.
If there are multiple nodes in the line, the sequence is array of [anchor_node_id, offset, child_node_index], 
where child_node_index is optional, default is the first child of the anchor node.
-->
<!-- pure English -->
<div dir=ltr class="test_move_by_word" title="0 4 8 12 16 19|19 16 12 8 4 0" contenteditable>abc def hij opq rst</div>
<div dir=rtl class="test_move_by_word" title="19 3 7 11 15 0|0 15 11 7 3 19" contenteditable>abc def hij opq rst</div>

<!-- pure Hebrew -->
<div dir=ltr class="test_move_by_word" title="0 15 11 7 3 19|19 3 7 11 15 0" contenteditable>ששש נננ בבב גגג קקק</div>
<div dir=rtl class="test_move_by_word" title="19 16 12 8 4 0|0 4 8 12 16 19" contenteditable>ששש נננ בבב גגג קקק</div>

<!-- bidi text -->
<!-- English Hebrew English -->
<div dir=ltr class="test_move_by_word" title="0 4 8 12 19 15 24 28 32 35|35 32 28 24 15 19 12 8 4 0" contenteditable>abc def hij אאא בבב צצצ opr uvw xyz</div>
<div dir=rtl class="test_move_by_word" title="35 27 31 24 20 16 12 3 7 0|0 7 3 12 16 20 24 31 27 35" contenteditable>abc def hij אאא בבב צצצ opr uvw xyz</div>

<div dir=ltr class="test_move_by_word" title="0 4 8 11 16 20 23|23 20 16 11 8 4 0" contenteditable>abc def שנב סטז uvw xyz</div>
<div dir=rtl class="test_move_by_word" title="23 19 16 12 8 3 0|0 3 8 12 16 19 23" contenteditable>abc def שנב סטז uvw xyz</div>

<div dir=ltr class="test_move_by_word" title="0 4 8 11|11 8 4 0" contenteditable>aaa אאא bbb</div>
<div dir=rtl class="test_move_by_word" title="11 8 4 0|0 4 8 11" contenteditable>aaa אאא bbb</div>

<!-- Hebrew English Hebrew -->
<div dir=ltr class="test_move_by_word" title="0 7 3 12 16 20 24 31 27 35|35 27 31 24 20 16 12 3 7 0" contenteditable>אאא בבב צצצ aaa bbb ccc דדד עעע פפפ</div>
<div dir=rtl class="test_move_by_word" title="35 32 28 24 15 19 12 8 4 0|0 4 8 12 19 15 24 28 32 35" contenteditable>אאא בבב צצצ aaa bbb ccc דדד עעע פפפ</div>

<div dir=ltr class="test_move_by_word" title="0 3 8 12 16 19 23|23 19 16 12 8 3 0" contenteditable>אאא בבב aaa bbb צצצ דדד</div>
<div dir=rtl class="test_move_by_word" title="23 20 16 11 8 4 0|0 4 8 11 16 20 23" contenteditable>אאא בבב aaa bbb צצצ דדד</div>

<div dir=ltr class="test_move_by_word" title="0 4 8 11|11 8 4 0" contenteditable>שנב abc סטז</div>
<div dir=rtl class="test_move_by_word" title="11 8 4 0|0 4 8 11" contenteditable>שנב abc סטז</div>

<!-- Test with Bidi control characters -->
<div dir=ltr class="test_move_by_word" id="notReachablePosition" title="0 9 8 14 17|17 14 8 9 0" contenteditable>abc &#x202b;באד def&#x202c; xyz</div>

<!-- Test with image -- non-inline-text-box -->
<div id="d_1" dir=ltr class="test_move_by_word" contenteditable title="[d_1, 0, 1][d_1, 4, 1][d_1, 8, 1][d_1, 1, 3][d_1, 5, 3][d_1, 8, 3]|[d_1, 8, 3][d_1, 5, 3][d_1, 1, 3][d_1, 8, 1][d_1, 4, 1][d_1, 0, 1]">abc def hij <img src=../../accessibility/resources/cake.png> opq rst </div>

<div id="d_2" dir=ltr class="test_move_by_word" contenteditable title="[d_2, 0, 1][d_2, 4, 1][d_2, 8, 1][d_2, 4, 5][d_2, 8, 5][d_2, 11, 5]|[d_2, 11, 5][d_2, 8, 5][d_2, 4, 5][d_2, 8, 1][d_2, 4, 1][d_2, 0, 1]">abc def this<span>is</span><span>one</span><span>word</span>end opq rst </div>

<!-- empty div -->
<div dir=ltr class="test_move_by_word" title="0|0" contenteditable></div>

</div>
<pre id="console"></pre>
</body>
</html>
