mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
If selection navigation happens through an editing host, we should enforce that for collapsed navigations (i.e. moving the caret) it can only happen if the focus node of the selection is editable.
46 lines
1.6 KiB
HTML
46 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<div>foo bar baz</div>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
function reportSelection() {
|
|
const range = getSelection().getRangeAt(0);
|
|
println(`${range.startContainer.nodeName} ${range.startOffset} - ${range.endContainer.nodeName} ${range.endOffset}`);
|
|
}
|
|
|
|
const divElm = document.querySelector('div');
|
|
getSelection().setBaseAndExtent(divElm.childNodes[0], 0, divElm.childNodes[0], 3);
|
|
reportSelection();
|
|
|
|
const modAlt = 1 << 0;
|
|
const modControl = 1 << 1;
|
|
const modShift = 1 << 2;
|
|
const modWordJump = modAlt | modControl; // macOS uses Mod_Alt, we should probably select just one modifier here.
|
|
|
|
println('--- Left/Right key should not modify a selection on uneditable contents ---');
|
|
internals.sendKey(divElm, 'Right');
|
|
reportSelection();
|
|
internals.sendKey(divElm, 'Left');
|
|
reportSelection();
|
|
|
|
println('--- Neither should WordJump + Left/Right ---');
|
|
internals.sendKey(divElm, 'Right', modWordJump);
|
|
reportSelection();
|
|
internals.sendKey(divElm, 'Left', modWordJump);
|
|
reportSelection();
|
|
|
|
println('--- Shift + Left/Right key however, should modify the selection ---');
|
|
internals.sendKey(divElm, 'Right', modShift);
|
|
reportSelection();
|
|
internals.sendKey(divElm, 'Left', modShift);
|
|
reportSelection();
|
|
|
|
println('--- Shift + WordJump + Left/Right as well ---');
|
|
internals.sendKey(divElm, 'Right', modWordJump | modShift);
|
|
reportSelection();
|
|
internals.sendKey(divElm, 'Right', modWordJump | modShift);
|
|
reportSelection();
|
|
internals.sendKey(divElm, 'Left', modWordJump | modShift);
|
|
reportSelection();
|
|
});
|
|
</script>
|