Title: [267476] trunk/LayoutTests
Revision
267476
Author
[email protected]
Date
2020-09-23 08:50:44 -0700 (Wed, 23 Sep 2020)

Log Message

Selection API: Update more tests that depend on WebKit's legacy non-standard behavior to set up the selection
https://bugs.webkit.org/show_bug.cgi?id=216844

Reviewed by Ryosuke Niwa.

Discovered a batch of editing tests that accidentally rely on non-standard selection
behavior to set up the tests. In many cases, the tests were clearly written wrong, like
using character offsets but a container that is not a text node. These changes keep the
tests testing the same things they are today.

* editing/deleting/delete-block-merge-contents-025.html: Use the actual number of child
nodes rather than 2000000000.
* editing/deleting/delete-blockquote-large-offsets.html: Ditto. The "large offsets" in
the title of this bug might simply be something that can't actually be done in practice,
setting an offset that is much higher than the actual number of children. The old code
simply clamped the high value.

* editing/execCommand/format-block-typing-style.html: Use a 1 as an offset so we are
past the child text element, rather than 5, which was presumably an attempt at setting
an offset to a particular character, but using the wrong container node.

* editing/execCommand/insert-nested-lists-in-table.html: Use a computed offset instead
of a hardcoded, and too high, value of 3.

* editing/execCommand/outdent-selection.html: Use a 1 instead of a 2 for an offset on
a container node that has only one child.
* editing/input/select-all-clear-input-method.html: Use a 3 instead of a 5 for an
offset in a container that's a text node containing 3 characters.

* editing/inserting/insert-list-during-node-removal-crash.html: This one is a little
different. The code selected the entire document and used the deleteFromDocument method.
That function is specified to not do an end-user "editing" delete, but to literally
delete all the nodes. That includes all the script nodes. To fix the test, just select
the contents of the body of the document.

* editing/inserting/insert-list-in-table-assert.html: Use a 0 instead of a 1
for an offset inside an empty style element.
* editing/inserting/insert-list-in-table-cell-04.html: Use a 1 instead of a 2
as the offest for the end of the element, given the element had only one child.
* editing/inserting/insert-list-in-table-cell-08.html: Ditto.
* editing/inserting/page-zoom-font-size.html: Ditto, 1 instead of 12.

* editing/inserting/replace-at-visible-boundary.html: Select the image by setting end
points before and after it, rather than trying to set offsets inside the image with
offsets of 0 and 1, since 1 is an illegal offset in an image with no children.

* editing/pasteboard/dataTransfer-setData-getData.html: Use a 1 instead of a 4
for an offset inside the dragme element, which has one child, which was presumably
an attempt at setting an offset to a particular character, but using the wrong
container node.
* editing/pasteboard/drag-drop-to-data-url.html: Ditto.

* editing/pasteboard/paste-blockquote-into-blockquote-2.html: Use an offset of 1
instead of 3 inside the block element which has no children, which was presumably
an attempt at setting an offset to a particular character, but using the wrong
container node.

* editing/pasteboard/paste-blockquote-into-blockquote-3.html: Use a range to set
the selection after the endContent <br> element rather than trying to use an
offset of 1 inside that element, which has no children.

* editing/pasteboard/paste-blockquote-into-blockquote.html: Use an offset of 1
instead of 3 inside the block element which has no children, which was presumably
an attempt at setting an offset to a particular character, but using the wrong
container node.

* editing/pasteboard/paste-table-cells.html: Use an offset of 1 instead of 3
inside the table, so the selection is after the table body. Presumably the error
is that someone thought that the table row elements were each children of the table.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (267475 => 267476)


--- trunk/LayoutTests/ChangeLog	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/ChangeLog	2020-09-23 15:50:44 UTC (rev 267476)
@@ -1,3 +1,75 @@
+2020-09-23  Darin Adler  <[email protected]>
+
+        Selection API: Update more tests that depend on WebKit's legacy non-standard behavior to set up the selection
+        https://bugs.webkit.org/show_bug.cgi?id=216844
+
+        Reviewed by Ryosuke Niwa.
+
+        Discovered a batch of editing tests that accidentally rely on non-standard selection
+        behavior to set up the tests. In many cases, the tests were clearly written wrong, like
+        using character offsets but a container that is not a text node. These changes keep the
+        tests testing the same things they are today.
+
+        * editing/deleting/delete-block-merge-contents-025.html: Use the actual number of child
+        nodes rather than 2000000000.
+        * editing/deleting/delete-blockquote-large-offsets.html: Ditto. The "large offsets" in
+        the title of this bug might simply be something that can't actually be done in practice,
+        setting an offset that is much higher than the actual number of children. The old code
+        simply clamped the high value.
+
+        * editing/execCommand/format-block-typing-style.html: Use a 1 as an offset so we are
+        past the child text element, rather than 5, which was presumably an attempt at setting
+        an offset to a particular character, but using the wrong container node.
+
+        * editing/execCommand/insert-nested-lists-in-table.html: Use a computed offset instead
+        of a hardcoded, and too high, value of 3.
+
+        * editing/execCommand/outdent-selection.html: Use a 1 instead of a 2 for an offset on
+        a container node that has only one child.
+        * editing/input/select-all-clear-input-method.html: Use a 3 instead of a 5 for an
+        offset in a container that's a text node containing 3 characters.
+
+        * editing/inserting/insert-list-during-node-removal-crash.html: This one is a little
+        different. The code selected the entire document and used the deleteFromDocument method.
+        That function is specified to not do an end-user "editing" delete, but to literally
+        delete all the nodes. That includes all the script nodes. To fix the test, just select
+        the contents of the body of the document.
+
+        * editing/inserting/insert-list-in-table-assert.html: Use a 0 instead of a 1
+        for an offset inside an empty style element.
+        * editing/inserting/insert-list-in-table-cell-04.html: Use a 1 instead of a 2
+        as the offest for the end of the element, given the element had only one child.
+        * editing/inserting/insert-list-in-table-cell-08.html: Ditto.
+        * editing/inserting/page-zoom-font-size.html: Ditto, 1 instead of 12.
+
+        * editing/inserting/replace-at-visible-boundary.html: Select the image by setting end
+        points before and after it, rather than trying to set offsets inside the image with
+        offsets of 0 and 1, since 1 is an illegal offset in an image with no children.
+
+        * editing/pasteboard/dataTransfer-setData-getData.html: Use a 1 instead of a 4
+        for an offset inside the dragme element, which has one child, which was presumably
+        an attempt at setting an offset to a particular character, but using the wrong
+        container node.
+        * editing/pasteboard/drag-drop-to-data-url.html: Ditto.
+
+        * editing/pasteboard/paste-blockquote-into-blockquote-2.html: Use an offset of 1
+        instead of 3 inside the block element which has no children, which was presumably
+        an attempt at setting an offset to a particular character, but using the wrong
+        container node.
+
+        * editing/pasteboard/paste-blockquote-into-blockquote-3.html: Use a range to set
+        the selection after the endContent <br> element rather than trying to use an
+        offset of 1 inside that element, which has no children.
+
+        * editing/pasteboard/paste-blockquote-into-blockquote.html: Use an offset of 1
+        instead of 3 inside the block element which has no children, which was presumably
+        an attempt at setting an offset to a particular character, but using the wrong
+        container node.
+
+        * editing/pasteboard/paste-table-cells.html: Use an offset of 1 instead of 3
+        inside the table, so the selection is after the table body. Presumably the error
+        is that someone thought that the table row elements were each children of the table.
+
 2020-09-23  Philippe Normand  <[email protected]>
 
         media/can-play-av1.html is not spec compliant

Modified: trunk/LayoutTests/editing/deleting/delete-block-merge-contents-025.html (267475 => 267476)


--- trunk/LayoutTests/editing/deleting/delete-block-merge-contents-025.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/deleting/delete-block-merge-contents-025.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -9,6 +9,6 @@
 To pass this testcase it should not crash.
 <div contenteditable="true" id="div"><hkern><span contenteditable="false"><dl>000A0<script>
 var sel = window.getSelection();
-sel.setPosition(div, 2000000000);
+sel.setPosition(div, div.childNodes.length);
 document.execCommand("Delete");
 </script>

Modified: trunk/LayoutTests/editing/deleting/delete-blockquote-large-offsets.html (267475 => 267476)


--- trunk/LayoutTests/editing/deleting/delete-blockquote-large-offsets.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/deleting/delete-blockquote-large-offsets.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -9,7 +9,7 @@
 if (window.testRunner)
     testRunner.dumpAsText();
 
-window.getSelection().setPosition(document.getElementById('blockquote'), 2000000000);
+window.getSelection().setPosition(document.getElementById('blockquote'), document.getElementById('blockquote').childNodes.length);
 document.execCommand("Delete");
 
 var test = document.getElementById('test');

Modified: trunk/LayoutTests/editing/execCommand/format-block-typing-style.html (267475 => 267476)


--- trunk/LayoutTests/editing/execCommand/format-block-typing-style.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/execCommand/format-block-typing-style.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -8,7 +8,7 @@
 Markup.description("This tests ensures FormatBlock preserves the typing style.");
 
 var test = document.getElementById('test');
-window.getSelection().setPosition(test, 5);
+window.getSelection().setPosition(test, 1);
 
 document.execCommand('Bold', false, null);
 document.execCommand('FormatBlock', false, '');

Modified: trunk/LayoutTests/editing/execCommand/insert-nested-lists-in-table.html (267475 => 267476)


--- trunk/LayoutTests/editing/execCommand/insert-nested-lists-in-table.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/execCommand/insert-nested-lists-in-table.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -31,7 +31,7 @@
 document.execCommand("InsertNestedUnorderedList");
 Markup.dump("editor", "After inserting a nested list below the outer list");
 
-getSelection().setPosition(garply.childNodes[0], 3);
+getSelection().setPosition(garply.childNodes[0], garply.childNodes[0].childNodes.length);
 document.execCommand("InsertNestedOrderedList");
 Markup.dump("editor", "After inserting another list under a table cell");
 </script>

Modified: trunk/LayoutTests/editing/execCommand/outdent-selection.html (267475 => 267476)


--- trunk/LayoutTests/editing/execCommand/outdent-selection.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/execCommand/outdent-selection.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -27,7 +27,7 @@
 var p1 = document.getElementById("item1");
 var p2 = document.getElementById("item2");
 s.setPosition(p1, 0);
-s.setBaseAndExtent(p1, 0, p2, 2);
+s.setBaseAndExtent(p1, 0, p2, 1);
 document.execCommand("Outdent", false, "");
 Markup.description("This test uses the execCommand to Outdent the text below.\n" +
     "This demonstrates a bug: the content in the blockquote that's not in a list is pulled out of position.");

Modified: trunk/LayoutTests/editing/input/select-all-clear-input-method.html (267475 => 267476)


--- trunk/LayoutTests/editing/input/select-all-clear-input-method.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/input/select-all-clear-input-method.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -11,7 +11,7 @@
 if (window.testRunner) {
     var container = document.getElementById('container');
     container.firstChild.focus();
-    getSelection().setPosition(container.firstChild.firstChild, 5);
+    getSelection().setPosition(container.firstChild.firstChild, 3);
     if (window.textInputController) {
         Markup.description(document.getElementsByTagName('p')[0].textContent);
 

Modified: trunk/LayoutTests/editing/inserting/insert-list-during-node-removal-crash.html (267475 => 267476)


--- trunk/LayoutTests/editing/inserting/insert-list-during-node-removal-crash.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/inserting/insert-list-during-node-removal-crash.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -16,8 +16,8 @@
 
     window._onload_ = () => {
         TD.addEventListener("DOMNodeRemovedFromDocument", DomNodeEventHandler);
-        document.execCommand("selectAll", false);
-        window.getSelection().deleteFromDocument();
+        getSelection().setBaseAndExtent(document.body, 0, document.body, document.body.childNodes.length);
+        getSelection().deleteFromDocument();
     }
 </script>
 <body contenteditable="true"><table><td id=TD></td></table><li contenteditable="false"></li><div>a</div>

Modified: trunk/LayoutTests/editing/inserting/insert-list-in-table-assert.html (267475 => 267476)


--- trunk/LayoutTests/editing/inserting/insert-list-in-table-assert.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/inserting/insert-list-in-table-assert.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -5,7 +5,7 @@
     }
 
     window._onload_ = () => {
-        window.getSelection().setBaseAndExtent(TH,1,STYLE,1);
+        window.getSelection().setBaseAndExtent(TH,1,STYLE,0);
         document.execCommand("insertUnorderedList", false);
         
         requestAnimationFrame(function () {

Modified: trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-04.html (267475 => 267476)


--- trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-04.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-04.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -6,7 +6,7 @@
     Markup.description('Insert a list item in a table:');
 
     var e = document.getElementById("element");
-    setSelectionCommand(e, 0, e, 2);
+    setSelectionCommand(e, 0, e, 1);
     Markup.dump('container', 'Before');
 
     document.execCommand("insertOrderedList");

Modified: trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-08.html (267475 => 267476)


--- trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-08.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-08.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -6,7 +6,7 @@
     Markup.description('Exec insertOrderedList twice in a table removes the previously inserted list item:');
 
     var e = document.getElementById("element");
-    setSelectionCommand(e, 0, e, 2);
+    setSelectionCommand(e, 0, e, 1);
     Markup.dump('container', 'Before');
 
     document.execCommand("insertOrderedList");

Modified: trunk/LayoutTests/editing/inserting/page-zoom-font-size.html (267475 => 267476)


--- trunk/LayoutTests/editing/inserting/page-zoom-font-size.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/inserting/page-zoom-font-size.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -11,7 +11,7 @@
 {
     var target = document.getElementById("test");
     var selection = window.getSelection();
-    selection.setPosition(target, 12);
+    selection.setPosition(target, 1);
     document.execCommand("insertHTML", false, "<span style='font-size: 16px' class='Apple-style-span'>This font is size 16px.</span>");
 
     var results = document.getElementById("results");

Modified: trunk/LayoutTests/editing/inserting/replace-at-visible-boundary.html (267475 => 267476)


--- trunk/LayoutTests/editing/inserting/replace-at-visible-boundary.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/inserting/replace-at-visible-boundary.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -23,7 +23,9 @@
         fail("Image should be adjacent to the bold node.");
 
     // Now try inserting HTML over the image.
-    execSetSelectionCommand(image, 0, image, 1);
+    var imageRange = new Range;
+    imageRange.selectNode(image);
+    execSetSelectionCommand(imageRange.startContainer, imageRange.startOffset, imageRange.endContainer, imageRange.endOffset);
     document.execCommand("inserthtml", false, "<span id='red' style='color:red'>red text</span>");
 
     // Verify that the red text isn't in the bold tag.

Modified: trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData.html (267475 => 267476)


--- trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -56,7 +56,7 @@
 
 function dragOntoDragTarget() {
     var e = document.getElementById("dragme");
-    window.getSelection().setBaseAndExtent(e, 0, e, 4); 
+    window.getSelection().setBaseAndExtent(e, 0, e, 1);
     x = e.offsetLeft + 10;
     y = e.offsetTop + e.offsetHeight / 2;
     eventSender.mouseMoveTo(x, y);

Modified: trunk/LayoutTests/editing/pasteboard/drag-drop-to-data-url.html (267475 => 267476)


--- trunk/LayoutTests/editing/pasteboard/drag-drop-to-data-url.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/pasteboard/drag-drop-to-data-url.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -27,7 +27,7 @@
 
 function dragDropIt() {
     var e = document.getElementById("dragme");
-    window.getSelection().setBaseAndExtent(e, 0, e, 4); 
+    window.getSelection().setBaseAndExtent(e, 0, e, 1); 
     x = e.offsetLeft + 10;
     y = e.offsetTop + e.offsetHeight / 2;
     eventSender.mouseMoveTo(x, y);

Modified: trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-2.html (267475 => 267476)


--- trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-2.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-2.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -19,7 +19,7 @@
 var sel = window.getSelection();
 var block = document.getElementById("block");
 
-sel.setPosition(block, 3);
+sel.setPosition(block, 1);
 document.execCommand("InsertHTML", false, "<span><blockquote type='cite'><blockquote type='cite'><div>Two</div><div>Three</div></blockquote></blockquote></span>");
 Markup.description("This tests pasting a nested blockquote into a blockquote. "
     + "The text \"One\" should be singly-blockquoted, and the text \"Two Three\" should be doubly-blockquoted. "

Modified: trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-3.html (267475 => 267476)


--- trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-3.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-3.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -23,7 +23,9 @@
 
 var sel = window.getSelection();
 var endContent = document.getElementById("endContent");
-sel.setPosition(endContent, 1);
+var range = new Range;
+range.selectNode(endContent);
+sel.setPosition(range.endContainer, range.endOffset);
 document.execCommand("InsertHTML", false, "<blockquote type='cite'><div>two</div></blockquote>");
 
 Markup.description(document.getElementsByTagName('p')[0].innerText);

Modified: trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote.html (267475 => 267476)


--- trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -17,7 +17,7 @@
 var sel = window.getSelection();
 var block = document.getElementById("block");
 
-sel.setPosition(block, 3);
+sel.setPosition(block, 1);
 document.execCommand("InsertHTML", false, "<span><blockquote type='cite'><div>Two</div><div>Three</div></blockquote></span>");
 
 Markup.description(document.getElementById('description').textContent);

Modified: trunk/LayoutTests/editing/pasteboard/paste-table-cells.html (267475 => 267476)


--- trunk/LayoutTests/editing/pasteboard/paste-table-cells.html	2020-09-23 15:20:07 UTC (rev 267475)
+++ trunk/LayoutTests/editing/pasteboard/paste-table-cells.html	2020-09-23 15:50:44 UTC (rev 267476)
@@ -27,7 +27,7 @@
 function editingTest() {
     var t1 = document.getElementById("test1");
     var t2 = document.getElementById("test2");
-    setSelectionCommand(t1, 0, t2, 3);
+    setSelectionCommand(t1, 0, t2, 1);
     copyCommand();
     Markup.dump('root', 'After copy');
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to