Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="variant" content="?granularity=character&editable=false">
<meta name="variant" content="?granularity=word&editable=false">
<meta name="variant" content="?granularity=line&editable=false">
<meta name="variant" content="?granularity=character&editable=true">
<meta name="variant" content="?granularity=word&editable=true">
<meta name="variant" content="?granularity=line&editable=true">
<title>Caret should not be locked in the table</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
const params = new URLSearchParams(document.location.search);
const granularity = params.get("granularity");
const editable = params.get("editable") == "true";
addEventListener("load", () => {
if (editable) {
document.body.setAttribute("contenteditable", "true");
}
test(() => {
const firstP = document.querySelector("p");
getSelection().collapse(firstP.firstChild, firstP.firstChild.length);
const secondP = document.querySelector("p + table + p");
for (let i = 0; i < 15; i++) {
getSelection().modify("move", "forward", granularity);
if (secondP.contains(getSelection().focusNode)) {
assert_true(true);
return;
}
}
assert_false(true);
}, `modify("move", "forward", "${granularity}") should be reachable outside the table`);
test(() => {
const secondP = document.querySelector("p + table + p");
getSelection().collapse(secondP.firstChild, 0);
const firstP = document.querySelector("p");
for (let i = 0; i < 15; i++) {
getSelection().modify("move", "backward", granularity);
if (firstP.contains(getSelection().focusNode)) {
assert_true(true);
return;
}
}
assert_false(true);
}, `modify("move", "backward", "${granularity}") should be reachable outside the table`);
}, {once: true});
</script>
<body>
<p>preceding paragraph1</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<tr><td>cell1</td><td>cell2</td></tr>
</table>
<p>preceding paragraph2</p>
</body>
</html>