Skip to content

Commit

Permalink
Add tentative WPT of handling line breaks in inline editing host
Browse files Browse the repository at this point in the history
Browsers shouldn't insert `<div>` and `<p>` elements into inline elements such
as `<span>` even when it's `display` value creates a block format context since
it's invalid structure from point of view of HTML.  However, some browsers do
it.  Therefore, this test should make them fail.

The reason why this patch touches `editor-test-utils.js` is, it scans the
following `<script>` element's text with a bug.  So the change makes it does
not scan outside the editing host.

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1777903
gecko-commit: e3fd1571e2b9e6968d5e7b8063700afc469c4186
gecko-reviewers: m_kato
  • Loading branch information
masayuki-nakano authored and moz-wptsync-bot committed Jul 11, 2022
1 parent e857282 commit 25ac31f
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 12 deletions.
14 changes: 2 additions & 12 deletions editing/data/insertparagraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1930,18 +1930,8 @@ var browserTests = [
"<div><br></div><div> abc</div>"],
[true,true],
{"insertparagraph":[false,false,"",false,false,""]}],
["<div contenteditable=false><span contenteditable>ab[]cd</span></div>",
[["defaultparagraphseparator","div"],["insertparagraph",""]],
["<div contenteditable=\"false\"><span contenteditable=\"\">ab<br>cd</span></div>",
"<div contenteditable=\"false\"><span contenteditable=\"\">ab<br>cd<br></span></div>"],
[true,true],
{"insertparagraph":[false,false,"",false,false,""]}],
["<p contenteditable=false><span contenteditable>ab[]cd</span></p>",
[["defaultparagraphseparator","div"],["insertparagraph",""]],
["<p contenteditable=\"false\"><span contenteditable=\"\">ab<br>cd</span></p>",
"<p contenteditable=\"false\"><span contenteditable=\"\">ab<br>cd<br></span></p>"],
[true,true],
{"insertparagraph":[false,false,"",false,false,""]}],

// TODO: Move the following tests into insertparagraph-or-insertlinebreak-in-inline-editing-host.tentative.html
["<h1 contenteditable=false><span contenteditable>ab[]cd</span></h1>",
[["defaultparagraphseparator","div"],["insertparagraph",""]],
["<h1 contenteditable=\"false\"><span contenteditable=\"\">ab<br>cd</span></h1>",
Expand Down
3 changes: 3 additions & 0 deletions editing/include/editor-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class EditorTestUtils {
if (node.hasChildNodes()) {
return inclusiveDeepestFirstChildNode(node);
}
if (node === this.editingHost) {
return null;
}
if (node.nextSibling) {
return inclusiveDeepestFirstChildNode(node.nextSibling);
}
Expand Down
Loading

0 comments on commit 25ac31f

Please sign in to comment.