forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubrange-with-trailing-collapsed-whitespace.html
59 lines (47 loc) · 1.8 KB
/
subrange-with-trailing-collapsed-whitespace.html
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
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="test" style="width: 100px">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
<div id="console"></div>
<script>
if (!window.internals)
testFailed("This test requires internals object");
debug("");
let container = document.getElementById("test");
function test(description, rangeToSelect) {
let selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(rangeToSelect);
debug(description);
[
[ ],
[ "IgnoresWhiteSpaceAtEndOfRun" ],
].forEach((behaviors) => {
debug(" " + (behaviors.join("|") || "Default behavior"));
for (let {text, range} of internals.statesOfTextIterator(rangeToSelect, behaviors))
debug(` '${text}' (location ${internals.locationFromRange(container, range, behaviors)} length ${internals.lengthFromRange(container, range, behaviors)})`);
});
debug("");
}
let rangeOfFirstLine = document.createRange();
rangeOfFirstLine.setStart(container.firstChild, 0);
rangeOfFirstLine.setEnd(container.firstChild, 12);
test("Testing first line...", rangeOfFirstLine);
let rangeOfSecondLine = document.createRange();
rangeOfSecondLine.setStart(container.firstChild, 12);
rangeOfSecondLine.setEnd(container.firstChild, 28);
test("Testing second line...", rangeOfSecondLine);
let rangeOfThirdLine = document.createRange();
rangeOfThirdLine.setStart(container.firstChild, 28);
rangeOfThirdLine.setEnd(container.firstChild, 40);
test("Testing third line...", rangeOfThirdLine);
let rangeOfFourthLine = document.createRange();
rangeOfFourthLine.setStart(container.firstChild, 40);
rangeOfFourthLine.setEnd(container.firstChild, 56);
test("Testing fourth line...", rangeOfFourthLine);
</script>
</body>
</html>