mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-15 07:32: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.
21 lines
642 B
HTML
21 lines
642 B
HTML
<script src="include.js"></script>
|
|
<p id="a">Uno</p>
|
|
|
|
<script>
|
|
test(() => {
|
|
var selection = window.getSelection();
|
|
selection.setBaseAndExtent(a.firstChild, 3, a.firstChild, 3);
|
|
selection.extend(a.firstChild, 0);
|
|
if (selection.anchorNode !== a.firstChild
|
|
|| selection.anchorOffset !== 3) {
|
|
println('FAIL: anchor has moved');
|
|
return;
|
|
}
|
|
if (selection.focusNode !== a.firstChild
|
|
|| selection.focusOffset !== 0) {
|
|
println('FAIL: focus is not where we expected');
|
|
return;
|
|
}
|
|
println('PASS');
|
|
})
|
|
</script>
|