Merge autoland to mozilla-central. a=merge FIREFOX_BETA_104_BASE
authorBogdan Szekely <bszekely@mozilla.com>
Mon, 25 Jul 2022 12:43:55 +0300
changeset 624997 00a40cdda673bdbe4f7831d1cf078909ad54182e
parent 624991 6f277f34e739fcbbb7d6d390c9bed6e026bbcac9 (current diff)
parent 624996 7e38dbf3b1c5f878b12a74713e717ad1d51bf53f (diff)
child 624998 12a49c2ff116e989330b81b275db85b2f606a5e6
child 625012 612b25d8862778e2502adcde0dc80af3cf218aa3
push id40028
push userbszekely@mozilla.com
push dateMon, 25 Jul 2022 09:49:20 +0000
treeherdermozilla-central@00a40cdda673 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone104.0a1
first release with
nightly linux32
00a40cdda673 / 104.0a1 / 20220725094920 / files
nightly linux64
00a40cdda673 / 104.0a1 / 20220725094920 / files
nightly mac
00a40cdda673 / 104.0a1 / 20220725094920 / files
nightly win32
00a40cdda673 / 104.0a1 / 20220725094920 / files
nightly win64
00a40cdda673 / 104.0a1 / 20220725094920 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge autoland to mozilla-central. a=merge
--- a/accessible/tests/browser/e10s/browser.ini
+++ b/accessible/tests/browser/e10s/browser.ini
@@ -12,17 +12,17 @@ support-files =
   !/accessible/tests/browser/*.jsm
   !/accessible/tests/mochitest/*.js
   !/accessible/tests/mochitest/letters.gif
   !/accessible/tests/mochitest/moz.png
 
 # Caching tests
 [browser_caching_actions.js]
 skip-if = 
-  (os == mac && !debug) #Bug 1779541
+  (apple_catalina || apple_silicon) && !debug # Bug 1779541
 [browser_caching_attributes.js]
 [browser_caching_description.js]
 [browser_caching_document_props.js]
 [browser_caching_name.js]
 skip-if = (os == "linux" && bits == 64) || (debug && os == "mac") || (debug && os == "win") #Bug 1388256
 [browser_caching_relations.js]
 [browser_caching_states.js]
 [browser_caching_table.js]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/editing/other/delete-in-child-of-head.tentative.html.ini
@@ -0,0 +1,114 @@
+[delete-in-child-of-head.tentative.html?designMode=off&method=backspace]
+  [delete in <div> elements in <head> should join them]
+    expected: FAIL
+
+  [delete around invisible <meta> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <title> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <style> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <script> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <link> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <base> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <template> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete at boundary of <title> and <div> in <head> should not join them]
+    expected: FAIL
+
+
+[delete-in-child-of-head.tentative.html?designMode=on&method=backspace]
+  [delete in <div> elements in <head> should join them]
+    expected: FAIL
+
+  [delete around invisible <meta> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <title> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <style> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <script> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <link> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <base> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete around invisible <template> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [delete at boundary of <title> and <div> in <head> should not join them]
+    expected: FAIL
+
+
+[delete-in-child-of-head.tentative.html?designMode=off&method=forwarddelete]
+  [forwarddelete in <div> elements in <head> should join them]
+    expected: FAIL
+
+  [forwarddelete around invisible <meta> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <title> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <style> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <script> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <link> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <base> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <template> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete at boundary of <title> and <div> in <head> should not join them]
+    expected: FAIL
+
+
+[delete-in-child-of-head.tentative.html?designMode=on&method=forwarddelete]
+  [forwarddelete in <div> elements in <head> should join them]
+    expected: FAIL
+
+  [forwarddelete around invisible <meta> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <title> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <style> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <script> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <link> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <base> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete around invisible <template> should not delete it at joining paragraphs]
+    expected: FAIL
+
+  [forwarddelete at boundary of <title> and <div> in <head> should not join them]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/editing/other/delete-in-child-of-html.tentative.html.ini
@@ -0,0 +1,114 @@
+[delete-in-child-of-html.tentative.html?designMode=off&method=backspace]
+  [delete in <div> elements after <body> should join them]
+    expected: FAIL
+
+  [delete should merge <div> after <body> into the <body>]
+    expected: FAIL
+
+  [delete should merge <div> after <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [delete should merge <div> after <body> into the empty <body>]
+    expected: FAIL
+
+  [delete should merge <div> before <body> into the <body>]
+    expected: FAIL
+
+  [delete should merge <div> before <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [delete should merge <div> before <body> into the empty <body>]
+    expected: FAIL
+
+  [delete from <div> around invisible <head> element should not delete the <head>]
+    expected: FAIL
+
+  [delete from <div> following visible <head> element should be merged with the <div> in the <head>]
+    expected: FAIL
+
+
+[delete-in-child-of-html.tentative.html?designMode=on&method=backspace]
+  [delete in <div> elements after <body> should join them]
+    expected: FAIL
+
+  [delete should merge <div> after <body> into the <body>]
+    expected: FAIL
+
+  [delete should merge <div> after <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [delete should merge <div> after <body> into the empty <body>]
+    expected: FAIL
+
+  [delete should merge <div> before <body> into the <body>]
+    expected: FAIL
+
+  [delete should merge <div> before <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [delete should merge <div> before <body> into the empty <body>]
+    expected: FAIL
+
+  [delete from <div> around invisible <head> element should not delete the <head>]
+    expected: FAIL
+
+  [delete from <div> following visible <head> element should be merged with the <div> in the <head>]
+    expected: FAIL
+
+
+[delete-in-child-of-html.tentative.html?designMode=on&method=forwarddelete]
+  [forwarddelete in <div> elements after <body> should join them]
+    expected: FAIL
+
+  [forwarddelete should merge <div> after <body> into the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> after <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> after <body> into the empty <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> before <body> into the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> before <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> before <body> into the empty <body>]
+    expected: FAIL
+
+  [forwarddelete from <div> around invisible <head> element should not delete the <head>]
+    expected: FAIL
+
+  [forwarddelete from <div> following visible <head> element should be merged with the <div> in the <head>]
+    expected: FAIL
+
+
+[delete-in-child-of-html.tentative.html?designMode=off&method=forwarddelete]
+  [forwarddelete in <div> elements after <body> should join them]
+    expected: FAIL
+
+  [forwarddelete should merge <div> after <body> into the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> after <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> after <body> into the empty <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> before <body> into the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> before <body> into the <div> in the <body>]
+    expected: FAIL
+
+  [forwarddelete should merge <div> before <body> into the empty <body>]
+    expected: FAIL
+
+  [forwarddelete from <div> around invisible <head> element should not delete the <head>]
+    expected: FAIL
+
+  [forwarddelete from <div> following visible <head> element should be merged with the <div> in the <head>]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/editing/other/insertparagraph-in-child-of-head.tentative.html.ini
@@ -0,0 +1,230 @@
+[insertparagraph-in-child-of-head.tentative.html?designMode=off&white-space=normal]
+  [insertParagraph in empty <title style="display:block;white-space:normal"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:normal"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:normal"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:normal"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:normal"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:normal"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:normal"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=on&white-space=normal]
+  [insertParagraph in empty <title style="display:block;white-space:normal"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:normal"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:normal"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:normal"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:normal"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:normal"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:normal"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=off&white-space=pre]
+  [insertParagraph in empty <title style="display:block;white-space:pre"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:pre"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:pre"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:pre"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:pre"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:pre"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=on&white-space=pre]
+  [insertParagraph in empty <title style="display:block;white-space:pre"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:pre"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:pre"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:pre"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:pre"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:pre"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=off&white-space=pre-wrap]
+  [insertParagraph in empty <title style="display:block;white-space:pre-wrap"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:pre-wrap"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:pre-wrap"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:pre-wrap"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:pre-wrap"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:pre-wrap"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-wrap"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=on&white-space=pre-wrap]
+  [insertParagraph in empty <title style="display:block;white-space:pre-wrap"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:pre-wrap"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:pre-wrap"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:pre-wrap"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:pre-wrap"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:pre-wrap"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-wrap"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=off&white-space=pre-line]
+  [insertParagraph in empty <title style="display:block;white-space:pre-line"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:pre-line"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:pre-line"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:pre-line"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:pre-line"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:pre-line"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-line"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-head.tentative.html?designMode=on&white-space=pre-line]
+  [insertParagraph in empty <title style="display:block;white-space:pre-line"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <title style="display:block;white-space:pre-line"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <style style="display:block;white-space:pre-line"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <style style="display:block;white-space:pre-line"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <script style="display:block;white-space:pre-line"> should not split it]
+    expected: FAIL
+
+  [insertParagraph in <script style="display:block;white-space:pre-line"> containing text should not split it]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-line"> in the <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) in the <head> should split the <div> element]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) in the <head> should split the <div> element]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/editing/other/insertparagraph-in-child-of-html.tentative.html.ini
@@ -0,0 +1,230 @@
+[insertparagraph-in-child-of-html.tentative.html?designMode=off&white-space=normal]
+  [insertParagraph in empty <div style="white-space:normal"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:normal"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:normal"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=on&white-space=normal]
+  [insertParagraph in empty <div style="white-space:normal"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:normal"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:normal"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:normal"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=off&white-space=pre]
+  [insertParagraph in empty <div style="white-space:pre"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=on&white-space=pre]
+  [insertParagraph in empty <div style="white-space:pre"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=off&white-space=pre-line]
+  [insertParagraph in empty <div style="white-space:pre-line"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-line"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-line"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=on&white-space=pre-line]
+  [insertParagraph in empty <div style="white-space:pre-line"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-line"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-line"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-line"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=off&white-space=pre-wrap]
+  [insertParagraph in empty <div style="white-space:pre-wrap"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-wrap"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-wrap"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) before <head> should split the <div>]
+    expected: FAIL
+
+
+[insertparagraph-in-child-of-html.tentative.html?designMode=on&white-space=pre-wrap]
+  [insertParagraph in empty <div style="white-space:pre-wrap"> after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) after <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) after <body> should not create another <div> element]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-wrap"> before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) before <body> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in empty <div style="white-space:pre-wrap"> before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing only a <br>) before <head> should split the <div>]
+    expected: FAIL
+
+  [insertParagraph in <div style="white-space:pre-wrap"> (containing text) before <head> should split the <div>]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/delete-in-child-of-head.tentative.html
@@ -0,0 +1,418 @@
+<!doctype html>
+<html>
+<head>
+<meta chareset="utf-8">
+<meta name="timeout" content="long">
+<meta name="variant" content="?designMode=off&method=backspace">
+<meta name="variant" content="?designMode=off&method=forwarddelete">
+<meta name="variant" content="?designMode=on&method=backspace">
+<meta name="variant" content="?designMode=on&method=forwarddelete">
+<title>Join paragraphs in the head element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+</head>
+<body>
+<iframe srcdoc=""></iframe>
+<script>
+"use strict";
+
+const searchParams = new URLSearchParams(document.location.search);
+const testingBackspace = searchParams.get("method") == "backspace";
+const commandName = testingBackspace ? "delete" : "forwarddelete";
+const testingDesignMode = searchParams.get("designMode") == "on";
+
+const iframe = document.querySelector("iframe");
+const minimumSrcDoc =
+  "<html>" +
+    '<head style="display:block">' +
+      "<title>iframe</title>" +
+      "<script src='/resources/testdriver.js'></" + "script>" +
+      "<script src='/resources/testdriver-vendor.js'></" + "script>" +
+      "<script src='/resources/testdriver-actions.js'></" + "script>" +
+    "</head>" +
+    "<body><br></body>" +
+  "</html>";
+
+async function initializeAndWaitForLoad(iframeElement, srcDocValue) {
+  const waitForLoad =
+    new Promise(
+      resolve => iframeElement.addEventListener("load", resolve, {once: true})
+    );
+  iframeElement.srcdoc = srcDocValue;
+  await waitForLoad;
+  if (testingDesignMode) {
+    iframeElement.contentDocument.designMode = "on";
+  } else {
+    iframeElement.contentDocument.documentElement.setAttribute("contenteditable", "");
+  }
+  iframeElement.contentWindow.focus();
+  iframeElement.contentDocument.execCommand("defaultParagraphSeparator", false, "div");
+}
+
+function removeResourceScriptElements(node) {
+  node.querySelectorAll("script").forEach(
+    element => {
+      if (element.getAttribute("src")?.startsWith("/resources")) {
+        element.remove()
+      }
+    }
+  );
+}
+
+// DO NOT USE multi-line comment in this file, then, you can comment out
+// unnecessary tests when you need to attach the browser with a debugger.
+
+// For backward compatibility, normal block elements in <head> should be
+// joined by deletion.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div1 = childDoc.createElement("div");
+  div1.innerHTML = "abc";
+  const div2 = childDoc.createElement("div");
+  div2.innerHTML = "def";
+  childDoc.head.appendChild(div1);
+  childDoc.head.appendChild(div2);
+  // Now: <head><title>...</title><div>abc</div><div>def</div></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? div2.firstChild : div1.firstChild,
+    testingBackspace ? 0 : div1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title><div>abcdef</div></head><body><br></body>',
+      '<head><title>iframe</title><div>abcdef<br></div></head><body><br></body>',
+    ],
+    "The <div> elements should be merged"
+  );
+  assert_equals(
+    div1.isConnected ^ div2.isConnected,
+    1,
+    "One <div> element should be removed, and the other should stay"
+  );
+}, `${commandName} in <div> elements in <head> should join them`);
+
+// The following void elements shouldn't be deleted for avoiding various
+// affection to the document.
+for (const tag of ["meta", "title", "style", "script", "link", "base", "template"]) {
+  promise_test(async () => {
+    await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+    const childDoc = iframe.contentDocument;
+    const utils = new EditorTestUtils(childDoc.documentElement);
+    const div1 = childDoc.createElement("div");
+    div1.innerHTML = "abc";
+    const div2 = childDoc.createElement("div");
+    div2.innerHTML = "def";
+    const element = childDoc.createElement(tag);
+    childDoc.head.appendChild(div1);
+    childDoc.head.appendChild(element);
+    childDoc.head.appendChild(div2);
+    // Now: <head><title>...</title><div>abc</div><tag/><div>def</div></head>...
+    childDoc.getSelection().collapse(
+      testingBackspace ? div2.firstChild : div1.firstChild,
+      testingBackspace ? 0 : div1.firstChild.length
+    );
+    await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+    removeResourceScriptElements(childDoc);
+    childDoc.head.removeAttribute("style");
+
+    if (["title", "style", "script", "template"].includes(tag)) {
+      assert_in_array(
+        childDoc.documentElement.innerHTML,
+        [
+          `<head><title>iframe</title><div>abcdef</div><${tag}></${tag}></head><body><br></body>`,
+          `<head><title>iframe</title><div>abcdef<br></div><${tag}></${tag}></head><body><br></body>`,
+          `<head><title>iframe</title><${tag}></${tag}><div>abcdef</div></head><body><br></body>`,
+          `<head><title>iframe</title><${tag}></${tag}><div>abcdef<br></div></head><body><br></body>`,
+        ],
+        `The <div> elements should be merged without deleting <${tag}>`
+      );
+    } else {
+      assert_in_array(
+        childDoc.documentElement.innerHTML,
+        [
+          `<head><title>iframe</title><div>abcdef</div><${tag}></head><body><br></body>`,
+          `<head><title>iframe</title><div>abcdef<br></div><${tag}></head><body><br></body>`,
+          `<head><title>iframe</title><${tag}><div>abcdef</div></head><body><br></body>`,
+          `<head><title>iframe</title><${tag}><div>abcdef<br></div></head><body><br></body>`,
+        ],
+        `The <div> elements should be merged without deleting <${tag}>`
+      );
+    }
+  }, `${commandName} around invisible <${tag}> should not delete it at joining paragraphs`);
+}
+
+// Visible <script>, <style>, <title> elements shouldn't be joined
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const script1 = childDoc.createElement("script");
+  script1.innerHTML = "// abc";
+  script1.setAttribute("style", "display:block");
+  const script2 = childDoc.createElement("script");
+  script2.innerHTML = "// def";
+  script2.setAttribute("style", "display:block");
+  childDoc.head.appendChild(script1);
+  childDoc.head.appendChild(script2);
+  // Now: <head><title>...</title><script>// abc</ script><script>// def</ script></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? script2.firstChild : script1.firstChild,
+    testingBackspace ? 0 : script1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  script1.removeAttribute("style");
+  script2.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><script>// abc</" + "script><script>// def</" + "script></head><body><br></body>",
+    "Visible <script> elements shouldn't be merged"
+  );
+}, `${commandName} in visible <script> elements in <head> should not join them`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const style1 = childDoc.createElement("style");
+  style1.innerHTML = "abc";
+  style1.setAttribute("style", "display:block");
+  const style2 = childDoc.createElement("style");
+  style2.innerHTML = "def";
+  style2.setAttribute("style", "display:block");
+  childDoc.head.appendChild(style1);
+  childDoc.head.appendChild(style2);
+  // Now: <head><title>...</title><style>abc</style><style>def</style></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? style2.firstChild : style1.firstChild,
+    testingBackspace ? 0 : style1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  style1.removeAttribute("style");
+  style2.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><style>abc</style><style>def</style></head><body><br></body>",
+    "Visible <style> elements shouldn't be merged"
+  );
+}, `${commandName} in visible <style> elements in <head> should not join them`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const title1 = childDoc.createElement("title");
+  title1.innerHTML = "abc";
+  title1.setAttribute("style", "display:block");
+  const title2 = childDoc.createElement("title");
+  title2.innerHTML = "def";
+  title2.setAttribute("style", "display:block");
+  childDoc.head.appendChild(title1);
+  childDoc.head.appendChild(title2);
+  // Now: <head><title>...</title><title>abc</title><title>def</title></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? title2.firstChild : title1.firstChild,
+    testingBackspace ? 0 : title1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  title1.removeAttribute("style");
+  title2.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><title>abc</title><title>def</title></head><body><br></body>",
+    "Visible <title> elements shouldn't be merged"
+  );
+}, `${commandName} in visible <title> elements in <head> should not join them`);
+
+// Visible <script>, <style>, <title> shouldn't be joined with following <div>
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const script = childDoc.createElement("script");
+  script.innerHTML = "// abc";
+  script.setAttribute("style", "display:block");
+  const div = childDoc.createElement("div");
+  div.innerHTML = "// def";
+  childDoc.head.appendChild(script);
+  childDoc.head.appendChild(div);
+  // Now: <head><title>...</title><script>// abc</ script><div>// def</div></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : script.firstChild,
+    testingBackspace ? 0 : script.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  script.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><script>// abc</" + "script><div>// def</div></head><body><br></body>",
+    "Visible <script> and <div> shouldn't be merged"
+  );
+}, `${commandName} at boundary of <script> and <div> in <head> should not join them`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const style = childDoc.createElement("style");
+  style.innerHTML = "abc";
+  style.setAttribute("style", "display:block");
+  const div = childDoc.createElement("div");
+  div.innerHTML = "def";
+  childDoc.head.appendChild(style);
+  childDoc.head.appendChild(div);
+  // Now: <head><title>...</title><style>abc</style><div>def</div></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : style.firstChild,
+    testingBackspace ? 0 : style.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  style.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><style>abc</style><div>def</div></head><body><br></body>",
+    "Visible <style> and <div> shouldn't be merged"
+  );
+}, `${commandName} at boundary of <style> and <div> in <head> should not join them`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const title = childDoc.createElement("title");
+  title.innerHTML = "abc";
+  title.setAttribute("title", "display:block");
+  const div = childDoc.createElement("div");
+  div.innerHTML = "def";
+  childDoc.head.appendChild(title);
+  childDoc.head.appendChild(div);
+  // Now: <head><title>...</title><title>abc</title><div>def</div></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : title.firstChild,
+    testingBackspace ? 0 : title.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  title.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><title>abc</title><div>def</div></head><body><br></body>",
+    "Visible <title> and <div> shouldn't be merged"
+  );
+}, `${commandName} at boundary of <title> and <div> in <head> should not join them`);
+
+// Visible <script>, <style>, <title> shouldn't be joined with preceding <div>
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div = childDoc.createElement("div");
+  div.innerHTML = "// abc";
+  const script = childDoc.createElement("script");
+  script.innerHTML = "// def";
+  script.setAttribute("style", "display:block");
+  childDoc.head.appendChild(div);
+  childDoc.head.appendChild(script);
+  // Now: <head><title>...</title><div>// abc</div><script>// def</ script></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? script.firstChild : div.firstChild,
+    testingBackspace ? 0 : div.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  script.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><div>// abc</div><script>// def</" + "script></head><body><br></body>",
+    "<div> and visible <script> shouldn't be merged"
+  );
+}, `${commandName} at boundary of <div> and <script> in <head> should not join them`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div = childDoc.createElement("div");
+  div.innerHTML = "abc";
+  const style = childDoc.createElement("style");
+  style.innerHTML = "def";
+  style.setAttribute("style", "display:block");
+  childDoc.head.appendChild(div);
+  childDoc.head.appendChild(style);
+  // Now: <head><title>...</title><div>abc</div><style>def</style></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? style.firstChild : div.firstChild,
+    testingBackspace ? 0 : div.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  style.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><div>abc</div><style>def</style></head><body><br></body>",
+    "<div> and visible <style> shouldn't be merged"
+  );
+}, `${commandName} at boundary of <div> and <style> in <head> should not join them`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div = childDoc.createElement("div");
+  div.innerHTML = "abc";
+  const title = childDoc.createElement("title");
+  title.innerHTML = "def";
+  title.setAttribute("style", "display:block");
+  childDoc.head.appendChild(div);
+  childDoc.head.appendChild(title);
+  // Now: <head><title>...</title><div>abc</div><title>def</title></head>...
+  childDoc.getSelection().collapse(
+    testingBackspace ? title.firstChild : div.firstChild,
+    testingBackspace ? 0 : div.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  title.removeAttribute("style");
+
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    "<head><title>iframe</title><div>abc</div><title>def</title></head><body><br></body>",
+    "<div> and visible <title> shouldn't be merged"
+  );
+}, `${commandName} at boundary of <div> and <title> in <head> should not join them`);
+
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/delete-in-child-of-html.tentative.html
@@ -0,0 +1,449 @@
+<!doctype html>
+<html>
+<head>
+<meta chareset="utf-8">
+<meta name="timeout" content="long">
+<meta name="variant" content="?designMode=off&method=backspace">
+<meta name="variant" content="?designMode=off&method=forwarddelete">
+<meta name="variant" content="?designMode=on&method=backspace">
+<meta name="variant" content="?designMode=on&method=forwarddelete">
+<title>Join paragraphs outside the body</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+</head>
+<body>
+<iframe srcdoc=""></iframe>
+<script>
+"use strict";
+
+const searchParams = new URLSearchParams(document.location.search);
+const testingBackspace = searchParams.get("method") == "backspace";
+const commandName = testingBackspace ? "delete" : "forwarddelete";
+const testingDesignMode = searchParams.get("designMode") == "on";
+
+const iframe = document.querySelector("iframe");
+const minimumSrcDoc =
+  "<html>" +
+    "<head>" +
+      "<title>iframe</title>" +
+      "<script src='/resources/testdriver.js'></" + "script>" +
+      "<script src='/resources/testdriver-vendor.js'></" + "script>" +
+      "<script src='/resources/testdriver-actions.js'></" + "script>" +
+    "</head>" +
+    "<body><br></body>" +
+  "</html>";
+
+async function initializeAndWaitForLoad(iframeElement, srcDocValue) {
+  const waitForLoad =
+    new Promise(
+      resolve => iframeElement.addEventListener("load", resolve, {once: true})
+    );
+  iframeElement.srcdoc = srcDocValue;
+  await waitForLoad;
+  if (testingDesignMode) {
+    iframeElement.contentDocument.designMode = "on";
+  } else {
+    iframeElement.contentDocument.documentElement.setAttribute("contenteditable", "");
+  }
+  iframeElement.contentWindow.focus();
+  iframeElement.contentDocument.execCommand("defaultParagraphSeparator", false, "div");
+}
+
+function removeResourceScriptElements(node) {
+  node.querySelectorAll("script").forEach(
+    element => {
+      if (element.getAttribute("src")?.startsWith("/resources")) {
+        element.remove()
+      }
+    }
+  );
+}
+
+// DO NOT USE multi-line comment in this file, then, you can comment out
+// unnecessary tests when you need to attach the browser with a debugger.
+
+// For backward compatibility, normal block elements outside <body> should be
+// joined by deletion.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div1 = childDoc.createElement("div");
+  div1.innerHTML = "abc";
+  const div2 = childDoc.createElement("div");
+  div2.innerHTML = "def";
+  childDoc.documentElement.appendChild(div1);
+  childDoc.documentElement.appendChild(div2);
+  // Now: </head><body><br></body><div>abc</div><div>def</div>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div2.firstChild : div1.firstChild,
+    testingBackspace ? 0 : div1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body><br></body><div>abcdef</div>',
+      '<head><title>iframe</title></head><body><br></body><div>abcdef<br></div>',
+    ],
+    "The <div> elements should be merged"
+  );
+  assert_equals(
+    div1.isConnected ^ div2.isConnected,
+    1,
+    "One <div> element should be removed, and the other should stay"
+  );
+}, `${commandName} in <div> elements after <body> should join them`);
+
+// Deleting around end of the <body> should merge the element after the
+// <body> into the <body>.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  childDoc.body.innerHTML = "abc";
+  const div = childDoc.createElement("div");
+  div.innerHTML = "def";
+  childDoc.documentElement.appendChild(div);
+  // Now: </head><body>abc</body><div>def</div>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : childDoc.body.firstChild,
+    testingBackspace ? 0 : childDoc.body.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body>abcdef</body>',
+      '<head><title>iframe</title></head><body>abcdef<br></body>',
+    ],
+    "The text should be merged"
+  );
+  assert_false(
+    div.isConnected,
+    "The <div> following <body> should be removed"
+  );
+}, `${commandName} should merge <div> after <body> into the <body>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div1 = childDoc.createElement("div");
+  div1.innerHTML = "abc";
+  const div2 = childDoc.createElement("div");
+  div2.innerHTML = "def";
+  childDoc.body.innerHTML = "";
+  childDoc.body.appendChild(div1);
+  childDoc.documentElement.appendChild(div2);
+  // Now: </head><body><div>abc</div></body><div>def</div>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div2.firstChild : div1.firstChild,
+    testingBackspace ? 0 : div1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body><div>abcdef</div></body>',
+      '<head><title>iframe</title></head><body><div>abcdef<br></div></body>',
+    ],
+    "The <div> elements should be merged"
+  );
+  assert_true(
+    !div2.isConnected || (div2.isConnected && div2.parentNode == childDoc.body),
+    "The <div> following <body> should be removed or moved into the <body>"
+  );
+}, `${commandName} should merge <div> after <body> into the <div> in the <body>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div = childDoc.createElement("div");
+  div.innerHTML = "abc";
+  childDoc.documentElement.appendChild(div);
+  // Now: </head><body><br></body><div>abc</div>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : childDoc.body,
+    0
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body>abc</body>',
+      '<head><title>iframe</title></head><body>abc<br></body>',
+    ],
+    "The <div> element should be merged into the <body>"
+  );
+  assert_false(
+    div.isConnected,
+    "The <div> element should be removed"
+  );
+}, `${commandName} should merge <div> after <body> into the empty <body>`);
+
+// Deleting around start of the <body> should merge the element before the
+// <body> into the <body>.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div = childDoc.createElement("div");
+  div.innerHTML = "abc";
+  childDoc.body.innerHTML = "def";
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  // Now: </head><div>abc</div><body>def</body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? childDoc.body.firstChild : div.firstChild,
+    testingBackspace ? 0 : div.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body>abcdef</body>',
+      '<head><title>iframe</title></head><body>abcdef<br></body>',
+    ],
+    "The text should be merged"
+  );
+  assert_false(
+    div.isConnected,
+    "The <div> following <body> should be removed"
+  );
+}, `${commandName} should merge <div> before <body> into the <body>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div1 = childDoc.createElement("div");
+  div1.innerHTML = "abc";
+  const div2 = childDoc.createElement("div");
+  div2.innerHTML = "def";
+  childDoc.documentElement.insertBefore(div1, childDoc.body);
+  childDoc.body.innerHTML = "";
+  childDoc.body.appendChild(div2);
+  // Now: </head><div>abc</div><body><div>def</div></body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div2.firstChild : div1.firstChild,
+    testingBackspace ? 0 : div1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body><div>abcdef</div></body>',
+      '<head><title>iframe</title></head><body><div>abcdef<br></div></body>',
+    ],
+    "The <div> elements should be merged"
+  );
+  assert_true(
+    !div2.isConnected || (div2.isConnected && div2.parentNode == childDoc.body),
+    "The <div> following <body> should be removed or moved into the <body>"
+  );
+}, `${commandName} should merge <div> before <body> into the <div> in the <body>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div = childDoc.createElement("div");
+  div.innerHTML = "abc";
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  // Now: </head><div>abc</div><body><br></body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? childDoc.body : div.firstChild,
+    testingBackspace ? 0: div.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title></head><body>abc</body>',
+      '<head><title>iframe</title></head><body>abc<br></body>',
+    ],
+    "The <div> element should be merged into the <body>"
+  );
+  assert_false(
+    div.isConnected,
+    "The <div> element should be removed"
+  );
+}, `${commandName} should merge <div> before <body> into the empty <body>`);
+
+// Deleting around end of the <head> should not delete the <head> element.
+if (testingBackspace) {
+  promise_test(async () => {
+    await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+    const childDoc = iframe.contentDocument;
+    const utils = new EditorTestUtils(childDoc.documentElement);
+    const div = childDoc.createElement("div");
+    div.innerHTML = "abc";
+    childDoc.body.innerHTML = "def";
+    childDoc.documentElement.insertBefore(div, childDoc.body);
+    // Now: </head><div>abc</div><body>def</body>
+    childDoc.getSelection().collapse(div.firstChild, 0);
+    await utils.sendBackspaceKey();
+    removeResourceScriptElements(childDoc);
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      '<head><title>iframe</title></head><div>abc</div><body>def</body>',
+      "The <div> element should be merged into the <body>"
+    );
+    assert_true(
+      div.isConnected,
+      "The <div> element should not be removed"
+    );
+  }, `delete from <div> following invisible <head> element shouldn't delete the <head> element`);
+}
+
+// Joining elements around <head> element should not delete the <head> element.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div1 = childDoc.createElement("div");
+  div1.innerHTML = "abc";
+  const div2 = childDoc.createElement("div");
+  div2.innerHTML = "def";
+  childDoc.documentElement.insertBefore(div1, childDoc.head);
+  childDoc.documentElement.insertBefore(div2, childDoc.body);
+  // Now: <div>abc</div><head>...</head><div>def</div><body><br></body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div2.firstChild : div1.firstChild,
+    testingBackspace ? 0 : div1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<div>abcdef</div><head><title>iframe</title></head><body><br></body>',
+      '<div>abcdef<br></div><head><title>iframe</title></head><body><br></body>',
+      '<head><title>iframe</title></head><div>abcdef</div><body><br></body>',
+      '<head><title>iframe</title></head><div>abcdef<br></div><body><br></body>',
+    ],
+    "The <div> element should be merged into the left <div> without deleting the <head>"
+  );
+  assert_true(
+    div1.isConnected ^ div2.isConnected,
+    "One <div> element should be removed, but the other should stay"
+  );
+}, `${commandName} from <div> around invisible <head> element should not delete the <head>`);
+
+
+// Same as <body> element boundary, allow joining across <head> elements if
+// and only if both elements are normal elements.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  childDoc.head.setAttribute("style", "display:block");
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const div1 = childDoc.createElement("div");
+  div1.innerHTML = "abc";
+  const div2 = childDoc.createElement("div");
+  div2.innerHTML = "def";
+  childDoc.head.appendChild(div1);
+  childDoc.documentElement.insertBefore(div2, childDoc.body);
+  // Now: <div>abc</div></head><div>def</div><body><br></body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div2.firstChild : div1.firstChild,
+    testingBackspace ? 0 : div1.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      '<head><title>iframe</title><div>abcdef</div></head><body><br></body>',
+      '<head><title>iframe</title><div>abcdef<br></div></head><body><br></body>',
+    ],
+    "The <div> element should be merged into the <div> in the <head>"
+  );
+  assert_false(
+    div2.isConnected,
+    "The <div> element should be removed"
+  );
+}, `${commandName} from <div> following visible <head> element should be merged with the <div> in the <head>`);
+
+// However, don't allow to join with <script> and <style> elements because
+// changing them may not be safe.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  childDoc.head.setAttribute("style", "display:block");
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const style = childDoc.createElement("style");
+  style.setAttribute("style", "display:block;white-space:pre");
+  style.innerHTML = "abc";
+  const div = childDoc.createElement("div");
+  div.innerHTML = "def";
+  childDoc.head.appendChild(style);
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  // Now: <style>abc</style></head><div>def</div><body><br></body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : style.firstChild,
+    testingBackspace ? 0 : style.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  style.removeAttribute("style");
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    '<head><title>iframe</title><style>abc</style></head><div>def</div><body><br></body>',
+    "The <div> element should not be merged with the <style> in the <head>"
+  );
+  assert_true(
+    div.isConnected,
+    "The <div> element should not be removed"
+  );
+}, `${commandName} from <div> following visible <head> element should be merged with the visible <style> in the <head>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  childDoc.head.setAttribute("style", "display:block");
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  const script = childDoc.createElement("script");
+  script.setAttribute("style", "display:block;white-space:pre");
+  script.innerHTML = "// abc";
+  const div = childDoc.createElement("div");
+  div.innerHTML = "def";
+  childDoc.head.appendChild(script);
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  // Now: <script>// abc</ script></head><div>def</div><body><br></body>
+  childDoc.getSelection().collapse(
+    testingBackspace ? div.firstChild : script.firstChild,
+    testingBackspace ? 0 : script.firstChild.length
+  );
+  await (testingBackspace ? utils.sendBackspaceKey() : utils.sendDeleteKey());
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+  script.removeAttribute("style");
+  assert_equals(
+    childDoc.documentElement.innerHTML,
+    '<head><title>iframe</title><script>// abc</' + 'script></head><div>def</div><body><br></body>',
+    "The <div> element should not be merged with the <script> in the <head>"
+  );
+  assert_true(
+    div.isConnected,
+    "The <div> element should not be removed"
+  );
+}, `${commandName} from <div> following visible <script> element should be merged with the visible <script> in the <head>`);
+
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/insertparagraph-in-child-of-head.tentative.html
@@ -0,0 +1,367 @@
+<!doctype html>
+<html>
+<head>
+<meta chareset="utf-8">
+<meta name="timeout" content="long">
+<meta name="variant" content="?designMode=off&white-space=normal">
+<meta name="variant" content="?designMode=off&white-space=pre">
+<meta name="variant" content="?designMode=off&white-space=pre-line">
+<meta name="variant" content="?designMode=off&white-space=pre-wrap">
+<meta name="variant" content="?designMode=on&white-space=normal">
+<meta name="variant" content="?designMode=on&white-space=pre">
+<meta name="variant" content="?designMode=on&white-space=pre-line">
+<meta name="variant" content="?designMode=on&white-space=pre-wrap">
+<title>Insert paragraph in a block element in the head element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+</head>
+<body>
+<iframe srcdoc=""></iframe>
+<script>
+"use strict";
+
+const searchParams = new URLSearchParams(document.location.search);
+const whiteSpace = searchParams.get("white-space");
+const testingDesignMode = searchParams.get("designMode") == "on";
+
+const isPreformatted =
+  whiteSpace == "pre" || whiteSpace == "pre-line" || whiteSpace == "pre-wrap";
+
+const iframe = document.querySelector("iframe");
+const minimumSrcDoc =
+  "<html>" +
+    "<head style='display:block'>" +
+      "<title>iframe</title>" +
+      "<script src='/resources/testdriver.js'></" + "script>" +
+      "<script src='/resources/testdriver-vendor.js'></" + "script>" +
+      "<script src='/resources/testdriver-actions.js'></" + "script>" +
+    "</head>" +
+    "<body><br></body>" +
+  "</html>";
+
+async function initializeAndWaitForLoad(iframeElement, srcDocValue) {
+  const waitForLoad =
+    new Promise(
+      resolve => iframeElement.addEventListener("load", resolve, {once: true})
+    );
+  iframeElement.srcdoc = srcDocValue;
+  await waitForLoad;
+  if (testingDesignMode) {
+    iframeElement.contentDocument.designMode = "on";
+  } else {
+    iframeElement.contentDocument.documentElement.setAttribute("contenteditable", "");
+  }
+  iframeElement.contentWindow.focus();
+  iframeElement.contentDocument.execCommand("defaultParagraphSeparator", false, "div");
+}
+
+function removeResourceScriptElements(node) {
+  node.querySelectorAll("script").forEach(
+    element => {
+      if (element.getAttribute("src")?.startsWith("/resources")) {
+        element.remove()
+      }
+    }
+  );
+}
+
+// DO NOT USE multi-line comment in this file, then, you can comment out
+// unnecessary tests when you need to attach the browser with a debugger.
+
+// <title>, <style> and <script> cannot have <br> element.  Therefore, it's
+// hard to think what is the best if linefeeds are not preformatted.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const title = childDoc.querySelector("title");
+  title.setAttribute("style", `display:block;white-space:${whiteSpace}`);
+  const utils = new EditorTestUtils(title);
+  utils.setupEditingHost("{}");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  title.removeAttribute("style");
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        "<head><title></title></head><body><br></body>",      // noop
+        "<head><title>\n</title></head><body><br></body>",    // (collapse white-space)
+        "<head><title>\n\n</title></head><body><br></body>",  // (collapse white-spaces)
+      ],
+      "0-2 collapsible linefeed(s) should be inserted"
+    );
+  } else {
+    // The second linefeed is required to make the last line visible
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      "<head><title>\n\n</title></head><body><br></body>",
+      "2 preformatted linefeeds should be inserted"
+    );
+  }
+}, `insertParagraph in empty <title style="display:block;white-space:${whiteSpace}"> should not split it`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const title = childDoc.querySelector("title");
+  title.setAttribute("style", `display:block;white-space:${whiteSpace}`);
+  const utils = new EditorTestUtils(title);
+  utils.setupEditingHost("ab[]cd");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  title.removeAttribute("style");
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        "<head><title>abcd</title></head><body><br></body>",    // noop
+        "<head><title>ab\ncd</title></head><body><br></body>",  // (collapsible white-space)
+      ],
+      "0-1 collapsible linefeed should be inserted"
+    );
+  } else {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      "<head><title>ab\ncd</title></head><body><br></body>",
+      "1 preformatted linefeed should be inserted"
+    );
+  }
+}, `insertParagraph in <title style="display:block;white-space:${whiteSpace}"> containing text should not split it`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const style = childDoc.createElement("style");
+  style.setAttribute("style", `display:block;white-space:${whiteSpace}`);
+  childDoc.head.appendChild(style);
+  const utils = new EditorTestUtils(style);
+  utils.setupEditingHost("{}");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  style.removeAttribute("style");
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        "<head><title>iframe</title><style></style></head><body><br></body>",      // noop
+        "<head><title>iframe</title><style>\n</style></head><body><br></body>",    // (collapsible white-space)
+        "<head><title>iframe</title><style>\n\n</style></head><body><br></body>",  // (collapsible white-spaces)
+      ],
+      "0-2 collapsible linefeeds should be inserted"
+    );
+  } else {
+    // The second linefeed is required to make the last line visible
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      "<head><title>iframe</title><style>\n\n</style></head><body><br></body>",
+      "2 preformatted linefeeds should be inserted"
+    );
+  }
+}, `insertParagraph in empty <style style="display:block;white-space:${whiteSpace}"> should not split it`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const style = childDoc.createElement("style");
+  style.setAttribute("style", `display:block;white-space:${whiteSpace}`);
+  childDoc.head.appendChild(style);
+  const utils = new EditorTestUtils(style);
+  utils.setupEditingHost("ab[]cd");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  style.removeAttribute("style");
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        "<head><title>iframe</title><style>abcd</style></head><body><br></body>",    // noop
+        "<head><title>iframe</title><style>ab\ncd</style></head><body><br></body>",  // (collapsible white-space)
+      ],
+      "0-1 collapsible linefeed should be inserted"
+    );
+  } else {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      "<head><title>iframe</title><style>ab\ncd</style></head><body><br></body>",
+      "1 preformatted linefeed should be inserted"
+    );
+  }
+}, `insertParagraph in <style style="display:block;white-space:${whiteSpace}"> containing text should not split it`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const script = childDoc.createElement("script");
+  script.setAttribute("style", `display:block;white-space:${whiteSpace}`);
+  childDoc.head.appendChild(script);
+  // Setting <script>.innerHTML causes throwing exception because it runs
+  // setting script, so we cannot use EditorTestUtils.setupEditingHost.
+  childDoc.getSelection().collapse(script, 0);
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  script.removeAttribute("style");
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        "<head><title>iframe</title><script></" + "script></head><body><br></body>",      // noop
+        "<head><title>iframe</title><script>\n</" + "script></head><body><br></body>",    // (collapsible white-space)
+        "<head><title>iframe</title><script>\n\n</" + "script></head><body><br></body>",  // (collapsible white-spaces)
+      ],
+      "0-2 collapsible linefeeds should be inserted"
+    );
+  } else {
+    // The second linefeed is required to make the last line visible
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      "<head><title>iframe</title><script>\n\n</" + "script></head><body><br></body>",
+      "2 preformatted linefeeds should be inserted"
+    );
+  }
+}, `insertParagraph in empty <script style="display:block;white-space:${whiteSpace}"> should not split it`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const script = childDoc.createElement("script");
+  script.setAttribute("style", `display:block;white-space:${whiteSpace}`);
+  childDoc.head.appendChild(script);
+  // Setting <script>.innerHTML causes throwing exception because it runs
+  // setting script, so we cannot use EditorTestUtils.setupEditingHost.
+  script.innerText = "// ab// cd";
+  childDoc.getSelection().collapse(script.firstChild, "// ab".length);
+  const utils = new EditorTestUtils(childDoc.documentElement);
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  script.removeAttribute("style");
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        "<head><title>iframe</title><script>// ab// cd</" + "script></head><body><br></body>",    // noop
+        "<head><title>iframe</title><script>// ab\n// cd</" + "script></head><body><br></body>",  // (collapsible white-space)
+      ],
+      "0-1 linefeed should be inserted"
+    );
+  } else {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      "<head><title>iframe</title><script>// ab\n// cd</" + "script></head><body><br></body>",
+      "1 preformatted linefeed should be inserted"
+    );
+  }
+}, `insertParagraph in <script style="display:block;white-space:${whiteSpace}"> containing text should not split it`);
+
+// <div> element in the <head> should be same behavior as the following result.
+//  See insertparagraph-in-child-of-html.tentative.html for the detail.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.head.appendChild(div);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<head><title>iframe</title><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div></head><body><br></body>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<head><title>iframe</title><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div></head><body><br></body>`,
+        `<head><title>iframe</title><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div></head><body><br></body>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in empty <div style="white-space:${
+  whiteSpace
+}"> in the <head> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.head.appendChild(div);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}<br>");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<head><title>iframe</title><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div></head><body><br></body>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<head><title>iframe</title><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div></head><body><br></body>`,
+        `<head><title>iframe</title><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}">\n</div></head><body><br></body>`,
+        `<head><title>iframe</title><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}"><br></div></head><body><br></body>`,
+        `<head><title>iframe</title><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div></head><body><br></body>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing only a <br>) in the <head> should split the <div> element`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.head.appendChild(div);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("ab[]cd");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+  childDoc.head.removeAttribute("style");
+
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      `<head><title>iframe</title><div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd</div></head><body><br></body>`,
+      `<head><title>iframe</title><div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd<br></div></head><body><br></body>`,
+      `<head><title>iframe</title><div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd</div></head><body><br></body>`,
+      `<head><title>iframe</title><div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd<br></div></head><body><br></body>`,
+    ],
+    "The <div> should be split"
+  );
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing text) in the <head> should split the <div> element`);
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/insertparagraph-in-child-of-html.tentative.html
@@ -0,0 +1,344 @@
+<!doctype html>
+<html><head>
+<meta chareset="utf-8">
+<meta name="timeout" content="long">
+<meta name="variant" content="?designMode=off&white-space=normal">
+<meta name="variant" content="?designMode=off&white-space=pre">
+<meta name="variant" content="?designMode=off&white-space=pre-line">
+<meta name="variant" content="?designMode=off&white-space=pre-wrap">
+<meta name="variant" content="?designMode=on&white-space=normal">
+<meta name="variant" content="?designMode=on&white-space=pre">
+<meta name="variant" content="?designMode=on&white-space=pre-line">
+<meta name="variant" content="?designMode=on&white-space=pre-wrap">
+<title>Insert paragraph in a child of the html element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+</head><body>
+<iframe srcdoc=""></iframe>
+<script>
+"use strict";
+
+const searchParams = new URLSearchParams(document.location.search);
+const whiteSpace = searchParams.get("white-space");
+const testingDesignMode = searchParams.get("designMode") == "on";
+
+const isPreformatted =
+  whiteSpace == "pre" || whiteSpace == "pre-line" || whiteSpace == "pre-wrap";
+
+const iframe = document.querySelector("iframe");
+const minimumSrcDoc =
+  "<html>" +
+    "<head>" +
+      "<title>iframe</title>" +
+      "<script src='/resources/testdriver.js'></" + "script>" +
+      "<script src='/resources/testdriver-vendor.js'></" + "script>" +
+      "<script src='/resources/testdriver-actions.js'></" + "script>" +
+    "</head>" +
+    "<body><br></body>" +
+  "</html>";
+
+async function initializeAndWaitForLoad(iframeElement, srcDocValue) {
+  const waitForLoad =
+    new Promise(
+      resolve => iframeElement.addEventListener("load", resolve, {once: true})
+    );
+  iframeElement.srcdoc = srcDocValue;
+  await waitForLoad;
+  if (testingDesignMode) {
+    iframeElement.contentDocument.designMode = "on";
+  } else {
+    iframeElement.contentDocument.documentElement.setAttribute("contenteditable", "");
+  }
+  iframeElement.contentWindow.focus();
+  iframeElement.contentDocument.execCommand("defaultParagraphSeparator", false, "div");
+}
+
+function removeResourceScriptElements(node) {
+  node.querySelectorAll("script").forEach(
+    element => {
+      if (element.getAttribute("src")?.startsWith("/resources")) {
+        element.remove()
+      }
+    }
+  );
+}
+
+// DO NOT USE multi-line comment in this file, then, you can comment out
+// unnecessary tests when you need to attach the browser with a debugger.
+
+// For backward compatibility, <div> elements outside <body> should be split
+// by insertParagraph.  However, should not unwrap existing <div> in any case
+// to avoid its child to become children of the <html>.
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.appendChild(div);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div>`,
+        `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in empty <div style="white-space:${
+  whiteSpace
+}"> after <body> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.appendChild(div);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}<br>");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div>`,
+        `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}">\n</div>`,
+        `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}"><br></div>`,
+        `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing only a <br>) after <body> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.appendChild(div);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("ab[]cd");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd</div>`,
+      `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd</div>`,
+      `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd<br></div>`,
+      `<head><title>iframe</title></head><body><br></body><div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd<br></div>`,
+    ],
+    "The <div> should be split"
+  );
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing text) after <body> should not create another <div> element`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<head><title>iframe</title></head><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><body><br></body>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div><body><br></body>`,
+        `<head><title>iframe</title></head><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><body><br></body>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in empty <div style="white-space:${
+  whiteSpace
+}"> before <body> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}<br>");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<head><title>iframe</title></head><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><body><br></body>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div><body><br></body>`,
+        `<head><title>iframe</title></head><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}">\n</div><body><br></body>`,
+        `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}"><br></div><body><br></body>`,
+        `<head><title>iframe</title></head><div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><body><br></body>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing only a <br>) before <body> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.insertBefore(div, childDoc.body);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("ab[]cd");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd</div><body><br></body>`,
+      `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd</div><body><br></body>`,
+      `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd<br></div><body><br></body>`,
+      `<head><title>iframe</title></head><div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd<br></div><body><br></body>`,
+    ],
+    "The <div> should be split"
+  );
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing text) before <body> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = document.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.insertBefore(div, childDoc.head);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><head><title>iframe</title></head><body><br></body>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div><head><title>iframe</title></head><body><br></body>`,
+        `<div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><head><title>iframe</title></head><body><br></body>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in empty <div style="white-space:${
+  whiteSpace
+}"> before <head> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.insertBefore(div, childDoc.head);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("{}<br>");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  if (!isPreformatted) {
+    assert_equals(
+      childDoc.documentElement.innerHTML,
+      `<div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><head><title>iframe</title></head><body><br></body>`,
+      "The <div> should be split"
+    );
+  } else {
+    assert_in_array(
+      childDoc.documentElement.innerHTML,
+      [
+        `<div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}">\n</div><head><title>iframe</title></head><body><br></body>`,
+        `<div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}">\n</div><head><title>iframe</title></head><body><br></body>`,
+        `<div style="white-space:${whiteSpace}">\n</div><div style="white-space:${whiteSpace}"><br></div><head><title>iframe</title></head><body><br></body>`,
+        `<div style="white-space:${whiteSpace}"><br></div><div style="white-space:${whiteSpace}"><br></div><head><title>iframe</title></head><body><br></body>`,
+      ],
+      "The <div> should be split"
+    );
+  }
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing only a <br>) before <head> should split the <div>`);
+
+promise_test(async () => {
+  await initializeAndWaitForLoad(iframe, minimumSrcDoc);
+  const childDoc = iframe.contentDocument;
+  const div = childDoc.createElement("div");
+  div.setAttribute("style", `white-space:${whiteSpace}`);
+  childDoc.documentElement.insertBefore(div, childDoc.head);
+  const utils = new EditorTestUtils(div);
+  utils.setupEditingHost("ab[]cd");
+  await utils.sendEnterKey();
+  removeResourceScriptElements(childDoc);
+
+  assert_in_array(
+    childDoc.documentElement.innerHTML,
+    [
+      `<div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd</div><head><title>iframe</title></head><body><br></body>`,
+      `<div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd</div><head><title>iframe</title></head><body><br></body>`,
+      `<div style="white-space:${whiteSpace}">ab</div><div style="white-space:${whiteSpace}">cd<br></div><head><title>iframe</title></head><body><br></body>`,
+      `<div style="white-space:${whiteSpace}">ab<br></div><div style="white-space:${whiteSpace}">cd<br></div><head><title>iframe</title></head><body><br></body>`,
+    ],
+    "The <div> should be split"
+  );
+}, `insertParagraph in <div style="white-space:${
+  whiteSpace
+}"> (containing text) before <head> should split the <div>`);
+
+</script>
+</body></html>
--- a/toolkit/components/passwordmgr/LoginManagerParent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerParent.jsm
@@ -126,17 +126,17 @@ let gGeneratedPasswordObserver = {
         generatedPW.storageGUID = null;
       }
     }
   },
 };
 
 Services.ppmm.addMessageListener("PasswordManager:findRecipes", message => {
   let formHost = new URL(message.data.formOrigin).host;
-  return gRecipeManager.getRecipesForHost(formHost);
+  return gRecipeManager?.getRecipesForHost(formHost) ?? [];
 });
 
 /**
  * Lazily create a Map of origins to array of browsers with importable logins.
  *
  * @param {origin} formOrigin
  * @returns {Object?} containing array of migration browsers and experiment state.
  */