body-should-not-deleted-even-if-empty.html (1780B)
1 <html><head> 2 <script src=/resources/testharness.js></script> 3 <script src=/resources/testharnessreport.js></script> 4 </head><body><script> 5 "use strict" 6 7 document.designMode = "on"; 8 9 test(() => { 10 document.querySelector("script")?.remove(); 11 document.head?.remove(); 12 document.body.firstChild?.remove(); 13 document.body.appendChild(document.createElement("p")); 14 getSelection().collapse(document.querySelector("p"), 0); 15 document.querySelector("p").firstChild?.remove(); 16 document.execCommand("delete"); 17 assert_in_array( 18 document.documentElement?.outerHTML.replace(/\n/g, ""), 19 [ 20 "<html><body></body></html>", 21 "<html><body><br></body></html>", 22 "<html><body><p></p></body></html>", 23 "<html><body><p><br></p></body></html>" 24 ], 25 "Body element shouldn't be deleted even if it becomes empty" 26 ); 27 }, "Delete in empty paragraph shouldn't delete parent body and html elements even if they become empty by Backspace"); 28 29 test(() => { 30 document.querySelector("script")?.remove(); 31 document.head?.remove(); 32 document.body.firstChild?.remove(); 33 document.body.appendChild(document.createElement("p")); 34 getSelection().collapse(document.querySelector("p"), 0); 35 document.querySelector("p").firstChild?.remove(); 36 document.execCommand("delete"); 37 assert_in_array( 38 document.documentElement?.outerHTML.replace(/\n/g, ""), 39 [ 40 "<html><body></body></html>", 41 "<html><body><br></body></html>", 42 "<html><body><p></p></body></html>", 43 "<html><body><p><br></p></body></html>" 44 ], 45 "Body element shouldn't be deleted even if it becomes empty" 46 ); 47 48 document.designMode = "off"; 49 }, "Delete in empty paragraph shouldn't delete parent body and html elements even if they become empty by Delete"); 50 51 </script></body></html>