mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00

They and their callees work with the result of `GetRoot()` which is the document element or the body element. If the body is not editable, `Selection` should not be updated in non-editable region nor `<br>` elements should not be inserted in both non-focused editable elements and non-editable elements. Therefore, they should run only when the document element or the `<body>` element is editable. To keep testing crashtests as reported, this patch makes tests which have `contenteditable` except `<html>` and `<body>` initialize `Selection` as what we've done. And clean up the tests for helping to port them to WPT in the future (bug 1725850). Differential Revision: https://phabricator.services.mozilla.com/D157408
19 lines
625 B
HTML
19 lines
625 B
HTML
<script>
|
|
window.onload = () => {
|
|
// For emulating the traditional behavior, collapse Selection to end of the
|
|
// <body> (at the text node after the <input>).
|
|
getSelection().collapse(document.body, document.body.childNodes.length);
|
|
document.execCommand("insertHorizontalRule");
|
|
getSelection().collapse(
|
|
document.querySelector("b")
|
|
);
|
|
document.execCommand("forwardDelete");
|
|
}
|
|
function onFocusChangeOfInput() {
|
|
document.getSelection().setPosition(document.querySelector("pre"));
|
|
}
|
|
</script>
|
|
<pre>
|
|
<time contenteditable>a|</t>
|
|
<input onfocus="onFocusChangeOfInput()" autofocus onblur="onFocusChangeOfInput()">
|