blob: 363120cc1f4132a6ca6ea56f46e6d58c5d4dc547 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<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>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that keys navigation through a paragraph work as expected when in caret mode, also with shift and ctrl modifiers.");
if (window.testRunner && window.internals) {
internals.settings.setCaretBrowsingEnabled(true);
testRunner.dumpAsText();
internals.settings.setEditingBehavior('mac');
var target = document.getElementById("target");
target.focus();
window.getSelection().setPosition(target.childNodes.item(0), 15);
// check left/right arrows
shouldBe("getSelection().baseOffset", "15");
eventSender.keyDown("rightArrow");
shouldBe("getSelection().baseOffset", "16");
eventSender.keyDown("leftArrow");
shouldBe("getSelection().baseOffset", "15");
// check left/right arrows + Shift
eventSender.keyDown("rightArrow", ["shiftKey"]);
eventSender.keyDown("rightArrow", ["shiftKey"]);
eventSender.keyDown("rightArrow", ["shiftKey"]);
shouldBe("getSelection().baseOffset", "15");
shouldBe("getSelection().extentOffset", "18");
eventSender.keyDown("leftArrow", ["shiftKey"]);
shouldBe("getSelection().baseOffset", "15");
shouldBe("getSelection().extentOffset", "17");
// check left/right arrows + Ctrl/Option
var modifierForWordGranularity = navigator.platform == "MacIntel" ? "altKey" : "ctrlKey";
eventSender.keyDown("rightArrow", [modifierForWordGranularity]);
shouldBe("getSelection().baseOffset", "21");
eventSender.keyDown("leftArrow", [modifierForWordGranularity]);
shouldBe("getSelection().baseOffset", "16");
// check left/right arrows + Ctrl/Option + Shift
eventSender.keyDown("rightArrow", [modifierForWordGranularity, "shiftKey"]);
eventSender.keyDown("rightArrow", [modifierForWordGranularity, "shiftKey"]);
shouldBe("getSelection().baseOffset", "16");
shouldBe("getSelection().extentOffset", "26");
eventSender.keyDown("leftArrow", [modifierForWordGranularity]);
shouldBe("getSelection().baseOffset", "22");
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>