test_bug1316302.html (2182B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1316302 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1316302</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 </head> 13 <body> 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1316302">Mozilla Bug 1316302</a> 15 <div contenteditable> 16 <blockquote><p>abc</p></blockquote> 17 </div> 18 <script type="application/javascript"> 19 /** Test for Bug 1316302 */ 20 SimpleTest.waitForExplicitFinish(); 21 SimpleTest.waitForFocus(() => { 22 var editor = document.getElementsByTagName("div")[0]; 23 var blockquote = document.getElementsByTagName("blockquote")[0]; 24 var selection = window.getSelection(); 25 26 editor.focus(); 27 28 // Try to remove the last character from the end of the <blockquote> 29 selection.collapse(blockquote, blockquote.childNodes.length); 30 var range = selection.getRangeAt(0); 31 ok(range.collapsed, "range should be collapsed at the end of <blockquote>"); 32 is(range.startContainer, blockquote, "range should be collapsed in the <blockquote>"); 33 is(range.startOffset, blockquote.childNodes.length, "range should be collapsed at the end"); 34 synthesizeKey("KEY_Backspace"); 35 is(blockquote.innerHTML, "<p>ab</p>", "Pressing Backspace key at the end of <blockquote> should remove the last character in the <p>"); 36 37 // Try to remove the first character from the start of the <blockquote> 38 selection.collapse(blockquote, 0); 39 range = selection.getRangeAt(0); 40 ok(range.collapsed, "range should be collapsed at the start of <blockquote>"); 41 is(range.startContainer, blockquote, "range should be collapsed in the <blockquote>"); 42 is(range.startOffset, 0, "range should be collapsed at the start"); 43 synthesizeKey("KEY_Delete"); 44 // FIXME: Chrome does not unwrap <p> if and only if the deleting range starts 45 // immediately after a block boundary. 46 is(blockquote.innerHTML, "b", "Pressing Delete key at the start of <blockquote> should remove the first character in the <p>"); 47 48 SimpleTest.finish(); 49 }); 50 </script> 51 </body> 52 </html>