tor-browser

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

commit 390c996054a11e711f474205c42f58175e115c2e
parent 672423bb04aa4500c15d536956fee8ab523b2be1
Author: Masayuki Nakano <masayuki@d-toybox.com>
Date:   Wed, 24 Dec 2025 02:05:51 +0000

Bug 2007052 - part 3: Port the block level editing command tests of `test_bug430392.html` to WPT r=m_kato

Note that the `inputType` values are tested in
`input-events/input-events-exec-command.html`.

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

Diffstat:
Meditor/libeditor/tests/test_bug430392.html | 18------------------
Mtesting/web-platform/meta/editing/run/indent.html.ini | 6++++++
Mtesting/web-platform/tests/editing/data/formatblock.js | 15+++++++++++++++
Mtesting/web-platform/tests/editing/data/indent.js | 23+++++++++++++++++++++++
Mtesting/web-platform/tests/editing/data/insertorderedlist.js | 8++++++++
Mtesting/web-platform/tests/editing/data/insertunorderedlist.js | 8++++++++
6 files changed, 60 insertions(+), 18 deletions(-)

diff --git a/editor/libeditor/tests/test_bug430392.html b/editor/libeditor/tests/test_bug430392.html @@ -34,19 +34,6 @@ function test() { // to expectedValue, and an unexpected fail if it's neither the original value // nor expectedValue. let tests = []; - [ - ["insertorderedlist", "insertOrderedList"], - ["insertunorderedlist", "insertUnorderedList"], - ["formatblock", "", "p"], - ].forEach(item => { - let cmd = item[0]; - let param = item[2]; - let inputType = item[1]; - tests.push([cmd, () => { document.execCommand(cmd, false, param); }, - [/* execCommand shouldn't cause beforeinput event */], - [inputType]]); - }); - // These are all TODO -- they don't move the non-editable elements [ ["bold", "formatBold"], @@ -73,11 +60,6 @@ function test() { " A ; ; BC "]); }); - tests.push(["indent", () => { document.execCommand("indent"); }, - [/* execCommand shouldn't cause beforeinput event */], - ["formatIndent"], - " ; ; ABC"]); - let beforeinputTypes = []; let inputTypes = []; edit.addEventListener("beforeinput", event => { beforeinputTypes.push(event.inputType); }); diff --git a/testing/web-platform/meta/editing/run/indent.html.ini b/testing/web-platform/meta/editing/run/indent.html.ini @@ -153,3 +153,9 @@ [[["indent",""\]\] "<ul><li>a<br>{<br>}</li><li>b</li></ul>" compare innerHTML] expected: FAIL + + [[["stylewithcss","true"\],["indent",""\]\] "{ <span contenteditable=\\"false\\">A</span> ; <span contenteditable=\\"false\\">B</span> ; <span contenteditable=\\"false\\">C</span> }" compare innerHTML] + expected: FAIL + + [[["stylewithcss","false"\],["indent",""\]\] "{ <span contenteditable=\\"false\\">A</span> ; <span contenteditable=\\"false\\">B</span> ; <span contenteditable=\\"false\\">C</span> }" compare innerHTML] + expected: FAIL diff --git a/testing/web-platform/tests/editing/data/formatblock.js b/testing/web-platform/tests/editing/data/formatblock.js @@ -1892,4 +1892,19 @@ var browserTests = [ "<span style=\"display:block\">abc</span><div><span style=\"display:block\">def</span></div><span style=\"display:block\">ghi</span>", [true], {"formatblock":[false,false,"",false,false,"div"]}], + +// Chrome put the new <p> at start of the selection first. Then, does not move +// anything. Safari just deletes editable nodes in the range. +// For here, the following test expects that browsers wrap all selected things +// into the new <p> since non-editable nodes are removable, so, they should be +// movable too and Firefox and Chrome behave so for "insertOrderedList" and +// "insertUnorderedList". +['{ <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> }', + [["formatblock","p"]], + ['<p> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </p>', + // It's fine to ignore or delete the invisible whitespaces. + ' <p><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></p> ', + '<p><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></p>'], + [true], + {}], ] diff --git a/testing/web-platform/tests/editing/data/indent.js b/testing/web-platform/tests/editing/data/indent.js @@ -816,4 +816,27 @@ var browserTests = [ "<div contenteditable=\"false\"><div contenteditable=\"\"><blockquote style=\"margin:0 0 0 40px; border:none; padding:0px\">abc</blockquote></div></div>"], [true,true], {"indent":[false,false,"",false,false,""]}], + +// Firefox and Chrome put the new <div> or <blockquote> at start of the selection first. +// Then, Firefox moves all editable nodes in the range into the new block. However, +// Chrome does not move anything. Safari just deletes editable nodes in the range. +// For here, these test expects that browsers wrap all selected things into the new +// block since non-editable nodes are removable, so, they should be movable too and +// Firefox and Chrome behave so for "insertOrderedList" and "insertUnorderedList". +['{ <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> }', + [["stylewithcss","true"],["indent",""]], + ['<div style=\"margin-left:40px\"> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </div>', + '<div style=\"margin-left:40px\"><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></div>', + '<blockquote style="margin:0 0 0 40px; border:none; padding:0px"> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </blockquote>', + '<blockquote style="margin:0 0 0 40px; border:none; padding:0px"><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></blockquote>'], + [true,true], + {}], +['{ <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> }', + [["stylewithcss","false"],["indent",""]], + ['<blockquote> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </blockquote>', + '<blockquote><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></blockquote>', + '<blockquote style="margin:0 0 0 40px; border:none; padding:0px"> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </blockquote>', + '<blockquote style="margin:0 0 0 40px; border:none; padding:0px"><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></blockquote>'], + [true,true], + {}], ] diff --git a/testing/web-platform/tests/editing/data/insertorderedlist.js b/testing/web-platform/tests/editing/data/insertorderedlist.js @@ -764,4 +764,12 @@ var browserTests = [ "<ol><li title=\"a\">abc</li><li title=\"b\">def</li></ol>"], [true], {}], + +['{ <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> }', + [["insertorderedlist",""]], + ['<ol><li> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </li></ol>', + // It's fine to delete the invisible whitespaces. + '<ol><li><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></li></ol>'], + [true], + {}], ] diff --git a/testing/web-platform/tests/editing/data/insertunorderedlist.js b/testing/web-platform/tests/editing/data/insertunorderedlist.js @@ -856,4 +856,12 @@ var browserTests = [ "<ul><li title=\"a\">abc</li><li title=\"b\">def</li></ul>"], [true], {}], + +['{ <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> }', + [["insertunorderedlist",""]], + ['<ul><li> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </li></ul>', + // It's fine to delete the invisible whitespaces. + '<ul><li><span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span></li></ul>'], + [true], + {}], ]