editor/libeditor/crashtests/1666556.html
author Masayuki Nakano <masayuki@d-toybox.com>
Thu, 22 Sep 2022 06:27:37 +0000
changeset 636050 9b15baab6f77d09eca2956276f66fee97555e4a1
parent 555303 bbdf569661715a17a19e78417c85c59487679b2b
child 636763 561d75b5153b0a7b7c8a4dfb064ffcd477da2b1d
permissions -rw-r--r--
Bug 1789967 - part 3: Make `HTMLEditor::CollapseSelectionToEndOfLastLeafNodeOfDocument` and `HTMLEditor::InitEditorContentAndSelection` do nothing if the document is partially editable r=m_kato 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

<script>
function onError() {
  document.querySelector("details").appendChild(
    document.querySelector("p")
  );
  document.execCommand("indent");
}

function onLoadOfStyle() {
  document.execCommand("delete");
  document.querySelector("details").contentEditable = "true";
  // For emulating the traditional behavior, collapse Selection to end of the
  // <style>.
  getSelection().collapse(
    document.querySelector("style"),
    document.querySelector("style").childNodes.length
  );
  document.querySelector("input").select();
}
</script>
<video focus="false">
<source onerror="onError()">
</video>
<details open>
<p>
<input contenteditable="false">
<style onload="onLoadOfStyle()">
<!-- x -->