1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<div id="container">
<p id="description"></p>
Manual steps:
<ol>
<li>Move middle of the first paragraph</li>
<li>Type Ctrl+Up</li>
<li>Caret should be start of paragrah</li>
<li>Type Ctrl+Down</li>
<li>Caret should be next paragrah</li>
<li>Do above step with Ctrl+Shift key to extend selection</li>
</ol>
Sample editable:
<div id="sample" contenteditable="true"><p>This is the first paragraph. Key binding of Ctrl+Up/Down are available only Windows.</p><p>This is second paragraph. Do you want to have these key bindings on other platforms?</p>
</div>
</div>
<script src="../../resources/js-test.js"></script>
<script>
description('Test Ctrl+Up/Down motion');
function $(id) { return document.getElementById(id); }
var sample = $('sample');
var selection = window.getSelection();
var range = document.createRange();
range.setStart(sample.firstChild.firstChild, 3);
selection.addRange(range);
sample.focus();
var paragraph1 = sample.firstChild.firstChild;
var paragraph2 = sample.childNodes[1].firstChild;
if (window.eventSender) {
eventSender.keyDown('upArrow', ['ctrlKey']);
shouldBeEqualToString('selection.type', 'Caret');
shouldBe('selection.focusNode', 'paragraph1');
shouldBe('selection.focusOffset', '0');
eventSender.keyDown('downArrow', ['ctrlKey']);
shouldBeEqualToString('selection.type', 'Caret');
shouldBe('selection.focusNode', 'paragraph2');
shouldBe('selection.focusOffset', '3');
eventSender.keyDown('downArrow', ['ctrlKey', 'shiftKey']);
shouldBeEqualToString('selection.type', 'Range');
shouldBe('selection.focusNode', 'paragraph2');
shouldBe('selection.focusOffset', '84');
eventSender.keyDown('upArrow', ['ctrlKey', 'shiftKey']);
shouldBeEqualToString('selection.type', 'Range');
shouldBe('selection.focusNode', 'paragraph1');
shouldBe('selection.focusOffset', '3');
}
if (window.testRunner)
$('container').outerHTML = '';
</script>
|