Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / caret-mode-paragraph-keys-navigation.html
blob4a8a0ccb557b7de537f83181a0f73d10de09aa0e
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="target">This tests that arrow keys navigate through a paragraph as expected when in caret browsing mode, also with shift and ctrl modifiers.</p>
8 <p id="description"></p>
9 <div id="console"></div>
10 <script>
11 description("This tests that keys navigation through a paragraph work as expected when in caret mode, also with shift and ctrl modifiers.");
13 if (window.testRunner && window.internals) {
14 testRunner.overridePreference("WebKitEnableCaretBrowsing", true);
15 testRunner.dumpAsText();
16 internals.settings.setEditingBehavior('mac');
18 var target = document.getElementById("target");
19 target.focus();
20 window.getSelection().collapse(target.childNodes.item(0), 15);
22 // check left/right arrows
23 shouldBe("getSelection().baseOffset", "15");
24 eventSender.keyDown("rightArrow");
25 shouldBe("getSelection().baseOffset", "16");
26 eventSender.keyDown("leftArrow");
27 shouldBe("getSelection().baseOffset", "15");
29 // check left/right arrows + Shift
30 eventSender.keyDown("rightArrow", ["shiftKey"]);
31 eventSender.keyDown("rightArrow", ["shiftKey"]);
32 eventSender.keyDown("rightArrow", ["shiftKey"]);
33 shouldBe("getSelection().baseOffset", "15");
34 shouldBe("getSelection().extentOffset", "18");
35 eventSender.keyDown("leftArrow", ["shiftKey"]);
36 shouldBe("getSelection().baseOffset", "15");
37 shouldBe("getSelection().extentOffset", "17");
39 // check left/right arrows + Ctrl/Option
40 var modifierForWordGranularity = navigator.platform == "MacIntel" ? "altKey" : "ctrlKey";
41 eventSender.keyDown("rightArrow", [modifierForWordGranularity]);
42 shouldBe("getSelection().baseOffset", "21");
43 eventSender.keyDown("leftArrow", [modifierForWordGranularity]);
44 shouldBe("getSelection().baseOffset", "16");
46 // check left/right arrows + Ctrl/Option + Shift
47 eventSender.keyDown("rightArrow", [modifierForWordGranularity, "shiftKey"]);
48 eventSender.keyDown("rightArrow", [modifierForWordGranularity, "shiftKey"]);
49 shouldBe("getSelection().baseOffset", "16");
50 shouldBe("getSelection().extentOffset", "26");
51 eventSender.keyDown("leftArrow", [modifierForWordGranularity]);
52 shouldBe("getSelection().baseOffset", "22");
55 </script>
56 </body>
57 </html>