mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-31 23:42:52 +00:00
Previously Selection.extend() used only the relative node order to decide which direction to extend the selection. This leads to incorrect behaviour if both the existing and new boundary points are within the same DOM node and the selection direction is reversed. This change fixes all the failing subtests in the WPT extend-* test suites.
22 lines
678 B
HTML
22 lines
678 B
HTML
<script src="include.js"></script>
|
|
<p id="p1">Well hello</p>
|
|
<p id="p2">friends</p>
|
|
|
|
<script>
|
|
test(() => {
|
|
var selection = window.getSelection();
|
|
selection.setBaseAndExtent(p1.firstChild, 0, p1.firstChild, 0);
|
|
selection.extend(p2.firstChild, 4);
|
|
if (selection.anchorNode !== p1.firstChild
|
|
|| selection.anchorOffset !== 0) {
|
|
println('FAIL: anchor has moved');
|
|
return;
|
|
}
|
|
if (selection.focusNode !== p2.firstChild
|
|
|| selection.focusOffset !== 4) {
|
|
println('FAIL: focus is not where we expected');
|
|
return;
|
|
}
|
|
println('PASS');
|
|
})
|
|
</script>
|