tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 53fc4593a8adcdf13322a58c253637b28d19597e
parent b18ae5cfbc41945ea622878c33cb9eb215ab14d9
Author: Masayuki Nakano <masayuki@d-toybox.com>
Date:   Wed, 24 Dec 2025 02:05:50 +0000

Bug 2007052 - part 1: Port the first test of `test_bug430392.html` to WPT r=m_kato

I don't think we need to check the another default paragraph mode since
it's too tricky case.

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

Diffstat:
Meditor/libeditor/tests/test_bug430392.html | 47-----------------------------------------------
Mtesting/web-platform/meta/editing/run/delete.html.ini | 6++++++
Mtesting/web-platform/tests/editing/data/delete.js | 25+++++++++++++++++++++++++
Mtesting/web-platform/tests/editing/data/insertparagraph.js | 20++++++++++++++++++++
4 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/editor/libeditor/tests/test_bug430392.html b/editor/libeditor/tests/test_bug430392.html @@ -35,53 +35,6 @@ function test() { // nor expectedValue. let tests = [ [ - "adding returns", - () => { - getSelection().collapse(edit.firstChild, 0); // [] <span contenteditable=false>A</span> ; <span - synthesizeKey("KEY_ArrowRight"); // <span contenteditable=false>A</span>[] ; <span - synthesizeKey("KEY_Enter"); - info(`1st Enter: "${edit.innerHTML}"`); - // " <div><span contenteditable="false">A</span></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> " - synthesizeKey("KEY_Enter"); - info(`2nd Enter: "${edit.innerHTML}"`); - // " <div><span contenteditable="false">A</span></div><div><br></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> " - synthesizeKey("KEY_Backspace"); - info(`1st Backspace: "${edit.innerHTML}"`); - // " <div><span contenteditable="false">A</span></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> " - synthesizeKey("KEY_Backspace"); - info(`2nd Backspace: "${edit.innerHTML}"`); - // " &nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span><div><span contenteditable="false">A</span></div> " - }, [ - "insertParagraph", - "insertParagraph", - "deleteContentBackward", - "deleteContentBackward", - ], - [ - "insertParagraph", - "insertParagraph", - "deleteContentBackward", - "deleteContentBackward", - ], - aSeparator => { - switch (aSeparator) { - case "div": - case "p": - // The following white-space of "A" should be converted to an - // NBSP when it's wrapped in a new paragraph. Then, it'll stay - // the start of the `Text` after `Backspace`es. Therefore, it - // won't be back to an ASCII white-space. - return " &nbsp;; B ; CA "; - case "br": - // After insertLineBreak, the first white-space should be replaced - // with &nbsp; and it should not be reconverted at Backspace. - // Therefore, the actual expected result is " A&nbsp;; B ; C ". - return " A\u00A0; B ; C "; - } - throw new Error("handle all cases!"); - }, - ], - [ "adding shift-returns", () => { getSelection().collapse(edit.firstChild, 0); // [] <span contenteditable=false>A</span> ; <span diff --git a/testing/web-platform/meta/editing/run/delete.html.ini b/testing/web-platform/meta/editing/run/delete.html.ini @@ -663,3 +663,9 @@ [[["delete",""\]\] "abc<input type=hidden>[\]def" compare innerHTML] expected: FAIL + + [[["delete",""\]\] " <div><span contenteditable=\\"false\\">A</span></div><div>[\]&nbsp;; <span contenteditable=\\"false\\">B</span> ; <span contenteditable=\\"false\\">C</span></div> " compare innerHTML] + expected: FAIL + + [[["delete",""\]\] " <span contenteditable=\\"false\\">A</span><div>[\]&nbsp;; <span contenteditable=\\"false\\">B</span> ; <span contenteditable=\\"false\\">C</span></div> " compare innerHTML] + expected: FAIL diff --git a/testing/web-platform/tests/editing/data/delete.js b/testing/web-platform/tests/editing/data/delete.js @@ -3506,4 +3506,29 @@ var browserTests = [ "<p>abc</p>", [true], {}], + +// The following tests are ported by Mozilla from their old test and the +// expectations are based on Chrome's behavior unless the behavior does not +// make sense. +[' <div><span contenteditable="false">A</span></div><div><br></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [["delete",""]], + ' <div><span contenteditable="false">A</span></div><div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [true], + {}], +[' <div><span contenteditable="false">A</span></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [["delete",""]], + ' <div><span contenteditable="false">A</span>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [true], + {}], +[' <span contenteditable="false">A</span><div><br></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [["delete",""]], + ' <span contenteditable="false">A</span><div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [true], + {}], +[' <span contenteditable="false">A</span><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [["delete",""]], + // The preceding line of the <div> is only the non-editable node. So, the editor should delete it. + '<div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [true], + {}], ] diff --git a/testing/web-platform/tests/editing/data/insertparagraph.js b/testing/web-platform/tests/editing/data/insertparagraph.js @@ -2703,4 +2703,24 @@ var browserTests = [ "<div style=\"display:inline-grid\"><span>abc</span><span><br></span></div>", [true,true], {}], + +// The following tests are ported by Mozilla from their old test and the +// expectations are based on Chrome's behavior unless the behavior does not +// make sense. +[' <span contenteditable="false">A</span>[] ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> ', + [["defaultparagraphseparator","div"],["insertparagraph",""]], + [' <div><span contenteditable="false">A</span></div><div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + ' <span contenteditable="false">A</span><div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> '], + [true,true], + {}], +[' <div><span contenteditable="false">A</span></div><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [["insertparagraph",""]], + ' <div><span contenteditable="false">A</span></div><div><br></div><div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [true], + {}], +[' <span contenteditable="false">A</span><div>[]&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [["insertparagraph",""]], + ' <span contenteditable="false">A</span><div><br></div><div>&nbsp;; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div> ', + [true], + {}], ]