HTMLEditor` shouldn't strip `<html>` element nor `<body>` elements

The new editor utility method does not stop scanning editable elements even if
it reaches the document root nor the (primary) `<body>` element.  Of course,
they should stop there if scanning editable block.  And
`ScanEmptyBlockInclusiveAncestor()` shouldn't store the removable empty block
element to them.

Differential Revision: https://phabricator.services.mozilla.com/D123316

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1727008
gecko-commit: 2139b35435875e1b58686491a583a2142d9c024d
gecko-reviewers: m_kato
diff --git a/editing/other/body-should-not-deleted-even-if-empty.html b/editing/other/body-should-not-deleted-even-if-empty.html
new file mode 100644
index 0000000..050e780
--- /dev/null
+++ b/editing/other/body-should-not-deleted-even-if-empty.html
@@ -0,0 +1,51 @@
+<html><head>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+</head><body><script>
+"use strict"
+
+document.designMode = "on";
+
+test(() => {
+  document.querySelector("script")?.remove();
+  document.head?.remove();
+  document.body.firstChild?.remove();
+  document.body.appendChild(document.createElement("p"));
+  getSelection().collapse(document.querySelector("p"), 0);
+  document.querySelector("p").firstChild?.remove();
+  document.execCommand("delete");
+  assert_in_array(
+    document.documentElement?.outerHTML.replace(/\n/g, ""),
+    [
+      "<html><body></body></html>",
+      "<html><body><br></body></html>",
+      "<html><body><p></p></body></html>",
+      "<html><body><p><br></p></body></html>"
+    ],
+    "Body element shouldn't be deleted even if it becomes empty"
+  );
+}, "Delete in empty paragraph shouldn't delete parent body and html elements even if they become empty by Backspace");
+
+test(() => {
+  document.querySelector("script")?.remove();
+  document.head?.remove();
+  document.body.firstChild?.remove();
+  document.body.appendChild(document.createElement("p"));
+  getSelection().collapse(document.querySelector("p"), 0);
+  document.querySelector("p").firstChild?.remove();
+  document.execCommand("delete");
+  assert_in_array(
+    document.documentElement?.outerHTML.replace(/\n/g, ""),
+    [
+      "<html><body></body></html>",
+      "<html><body><br></body></html>",
+      "<html><body><p></p></body></html>",
+      "<html><body><p><br></p></body></html>"
+    ],
+    "Body element shouldn't be deleted even if it becomes empty"
+  );
+
+  document.designMode = "off";
+}, "Delete in empty paragraph shouldn't delete parent body and html elements even if they become empty by Delete");
+
+</script></body></html>
\ No newline at end of file