⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267476 in webkit


Ignore:
Timestamp:
Sep 23, 2020, 8:50:44 AM (6 years ago)
Author:
Darin Adler
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.

Location:
trunk/LayoutTests
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r267474 r267476  
     12020-09-23  Darin Adler  <darin@apple.com>
     2
     3        Selection API: Update more tests that depend on WebKit's legacy non-standard behavior to set up the selection
     4        https://bugs.webkit.org/show_bug.cgi?id=216844
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Discovered a batch of editing tests that accidentally rely on non-standard selection
     9        behavior to set up the tests. In many cases, the tests were clearly written wrong, like
     10        using character offsets but a container that is not a text node. These changes keep the
     11        tests testing the same things they are today.
     12
     13        * editing/deleting/delete-block-merge-contents-025.html: Use the actual number of child
     14        nodes rather than 2000000000.
     15        * editing/deleting/delete-blockquote-large-offsets.html: Ditto. The "large offsets" in
     16        the title of this bug might simply be something that can't actually be done in practice,
     17        setting an offset that is much higher than the actual number of children. The old code
     18        simply clamped the high value.
     19
     20        * editing/execCommand/format-block-typing-style.html: Use a 1 as an offset so we are
     21        past the child text element, rather than 5, which was presumably an attempt at setting
     22        an offset to a particular character, but using the wrong container node.
     23
     24        * editing/execCommand/insert-nested-lists-in-table.html: Use a computed offset instead
     25        of a hardcoded, and too high, value of 3.
     26
     27        * editing/execCommand/outdent-selection.html: Use a 1 instead of a 2 for an offset on
     28        a container node that has only one child.
     29        * editing/input/select-all-clear-input-method.html: Use a 3 instead of a 5 for an
     30        offset in a container that's a text node containing 3 characters.
     31
     32        * editing/inserting/insert-list-during-node-removal-crash.html: This one is a little
     33        different. The code selected the entire document and used the deleteFromDocument method.
     34        That function is specified to not do an end-user "editing" delete, but to literally
     35        delete all the nodes. That includes all the script nodes. To fix the test, just select
     36        the contents of the body of the document.
     37
     38        * editing/inserting/insert-list-in-table-assert.html: Use a 0 instead of a 1
     39        for an offset inside an empty style element.
     40        * editing/inserting/insert-list-in-table-cell-04.html: Use a 1 instead of a 2
     41        as the offest for the end of the element, given the element had only one child.
     42        * editing/inserting/insert-list-in-table-cell-08.html: Ditto.
     43        * editing/inserting/page-zoom-font-size.html: Ditto, 1 instead of 12.
     44
     45        * editing/inserting/replace-at-visible-boundary.html: Select the image by setting end
     46        points before and after it, rather than trying to set offsets inside the image with
     47        offsets of 0 and 1, since 1 is an illegal offset in an image with no children.
     48
     49        * editing/pasteboard/dataTransfer-setData-getData.html: Use a 1 instead of a 4
     50        for an offset inside the dragme element, which has one child, which was presumably
     51        an attempt at setting an offset to a particular character, but using the wrong
     52        container node.
     53        * editing/pasteboard/drag-drop-to-data-url.html: Ditto.
     54
     55        * editing/pasteboard/paste-blockquote-into-blockquote-2.html: Use an offset of 1
     56        instead of 3 inside the block element which has no children, which was presumably
     57        an attempt at setting an offset to a particular character, but using the wrong
     58        container node.
     59
     60        * editing/pasteboard/paste-blockquote-into-blockquote-3.html: Use a range to set
     61        the selection after the endContent <br> element rather than trying to use an
     62        offset of 1 inside that element, which has no children.
     63
     64        * editing/pasteboard/paste-blockquote-into-blockquote.html: Use an offset of 1
     65        instead of 3 inside the block element which has no children, which was presumably
     66        an attempt at setting an offset to a particular character, but using the wrong
     67        container node.
     68
     69        * editing/pasteboard/paste-table-cells.html: Use an offset of 1 instead of 3
     70        inside the table, so the selection is after the table body. Presumably the error
     71        is that someone thought that the table row elements were each children of the table.
     72
    1732020-09-23  Philippe Normand  <pnormand@igalia.com>
    274
  • trunk/LayoutTests/editing/deleting/delete-block-merge-contents-025.html

    r120173 r267476  
    1010<div contenteditable="true" id="div"><hkern><span contenteditable="false"><dl>000A0<script>
    1111var sel = window.getSelection();
    12 sel.setPosition(div, 2000000000);
     12sel.setPosition(div, div.childNodes.length);
    1313document.execCommand("Delete");
    1414</script>
  • trunk/LayoutTests/editing/deleting/delete-blockquote-large-offsets.html

    r120173 r267476  
    1010    testRunner.dumpAsText();
    1111
    12 window.getSelection().setPosition(document.getElementById('blockquote'), 2000000000);
     12window.getSelection().setPosition(document.getElementById('blockquote'), document.getElementById('blockquote').childNodes.length);
    1313document.execCommand("Delete");
    1414
  • trunk/LayoutTests/editing/execCommand/format-block-typing-style.html

    r74601 r267476  
    99
    1010var test = document.getElementById('test');
    11 window.getSelection().setPosition(test, 5);
     11window.getSelection().setPosition(test, 1);
    1212
    1313document.execCommand('Bold', false, null);
  • trunk/LayoutTests/editing/execCommand/insert-nested-lists-in-table.html

    r237976 r267476  
    3232Markup.dump("editor", "After inserting a nested list below the outer list");
    3333
    34 getSelection().setPosition(garply.childNodes[0], 3);
     34getSelection().setPosition(garply.childNodes[0], garply.childNodes[0].childNodes.length);
    3535document.execCommand("InsertNestedOrderedList");
    3636Markup.dump("editor", "After inserting another list under a table cell");
  • trunk/LayoutTests/editing/execCommand/outdent-selection.html

    r88699 r267476  
    2828var p2 = document.getElementById("item2");
    2929s.setPosition(p1, 0);
    30 s.setBaseAndExtent(p1, 0, p2, 2);
     30s.setBaseAndExtent(p1, 0, p2, 1);
    3131document.execCommand("Outdent", false, "");
    3232Markup.description("This test uses the execCommand to Outdent the text below.\n" +
  • trunk/LayoutTests/editing/input/select-all-clear-input-method.html

    r120173 r267476  
    1212    var container = document.getElementById('container');
    1313    container.firstChild.focus();
    14     getSelection().setPosition(container.firstChild.firstChild, 5);
     14    getSelection().setPosition(container.firstChild.firstChild, 3);
    1515    if (window.textInputController) {
    1616        Markup.description(document.getElementsByTagName('p')[0].textContent);
  • trunk/LayoutTests/editing/inserting/insert-list-during-node-removal-crash.html

    r259027 r267476  
    1717    window.onload = () => {
    1818        TD.addEventListener("DOMNodeRemovedFromDocument", DomNodeEventHandler);
    19         document.execCommand("selectAll", false);
    20         window.getSelection().deleteFromDocument();
     19        getSelection().setBaseAndExtent(document.body, 0, document.body, document.body.childNodes.length);
     20        getSelection().deleteFromDocument();
    2121    }
    2222</script>
  • trunk/LayoutTests/editing/inserting/insert-list-in-table-assert.html

    r259899 r267476  
    66
    77    window.onload = () => {
    8         window.getSelection().setBaseAndExtent(TH,1,STYLE,1);
     8        window.getSelection().setBaseAndExtent(TH,1,STYLE,0);
    99        document.execCommand("insertUnorderedList", false);
    1010       
  • trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-04.html

    r219914 r267476  
    77
    88    var e = document.getElementById("element");
    9     setSelectionCommand(e, 0, e, 2);
     9    setSelectionCommand(e, 0, e, 1);
    1010    Markup.dump('container', 'Before');
    1111
  • trunk/LayoutTests/editing/inserting/insert-list-in-table-cell-08.html

    r219914 r267476  
    77
    88    var e = document.getElementById("element");
    9     setSelectionCommand(e, 0, e, 2);
     9    setSelectionCommand(e, 0, e, 1);
    1010    Markup.dump('container', 'Before');
    1111
  • trunk/LayoutTests/editing/inserting/page-zoom-font-size.html

    r71252 r267476  
    1212    var target = document.getElementById("test");
    1313    var selection = window.getSelection();
    14     selection.setPosition(target, 12);
     14    selection.setPosition(target, 1);
    1515    document.execCommand("insertHTML", false, "<span style='font-size: 16px' class='Apple-style-span'>This font is size 16px.</span>");
    1616
  • trunk/LayoutTests/editing/inserting/replace-at-visible-boundary.html

    r120173 r267476  
    2424
    2525    // Now try inserting HTML over the image.
    26     execSetSelectionCommand(image, 0, image, 1);
     26    var imageRange = new Range;
     27    imageRange.selectNode(image);
     28    execSetSelectionCommand(imageRange.startContainer, imageRange.startOffset, imageRange.endContainer, imageRange.endOffset);
    2729    document.execCommand("inserthtml", false, "<span id='red' style='color:red'>red text</span>");
    2830
  • trunk/LayoutTests/editing/pasteboard/dataTransfer-setData-getData.html

    r223195 r267476  
    5757function dragOntoDragTarget() {
    5858    var e = document.getElementById("dragme");
    59     window.getSelection().setBaseAndExtent(e, 0, e, 4);
     59    window.getSelection().setBaseAndExtent(e, 0, e, 1);
    6060    x = e.offsetLeft + 10;
    6161    y = e.offsetTop + e.offsetHeight / 2;
  • trunk/LayoutTests/editing/pasteboard/drag-drop-to-data-url.html

    r120173 r267476  
    2828function dragDropIt() {
    2929    var e = document.getElementById("dragme");
    30     window.getSelection().setBaseAndExtent(e, 0, e, 4);
     30    window.getSelection().setBaseAndExtent(e, 0, e, 1);
    3131    x = e.offsetLeft + 10;
    3232    y = e.offsetTop + e.offsetHeight / 2;
  • trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-2.html

    r87775 r267476  
    2020var block = document.getElementById("block");
    2121
    22 sel.setPosition(block, 3);
     22sel.setPosition(block, 1);
    2323document.execCommand("InsertHTML", false, "<span><blockquote type='cite'><blockquote type='cite'><div>Two</div><div>Three</div></blockquote></blockquote></span>");
    2424Markup.description("This tests pasting a nested blockquote into a blockquote. "
  • trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote-3.html

    r86817 r267476  
    2424var sel = window.getSelection();
    2525var endContent = document.getElementById("endContent");
    26 sel.setPosition(endContent, 1);
     26var range = new Range;
     27range.selectNode(endContent);
     28sel.setPosition(range.endContainer, range.endOffset);
    2729document.execCommand("InsertHTML", false, "<blockquote type='cite'><div>two</div></blockquote>");
    2830
  • trunk/LayoutTests/editing/pasteboard/paste-blockquote-into-blockquote.html

    r92580 r267476  
    1818var block = document.getElementById("block");
    1919
    20 sel.setPosition(block, 3);
     20sel.setPosition(block, 1);
    2121document.execCommand("InsertHTML", false, "<span><blockquote type='cite'><div>Two</div><div>Three</div></blockquote></span>");
    2222
  • trunk/LayoutTests/editing/pasteboard/paste-table-cells.html

    r144956 r267476  
    2828    var t1 = document.getElementById("test1");
    2929    var t2 = document.getElementById("test2");
    30     setSelectionCommand(t1, 0, t2, 3);
     30    setSelectionCommand(t1, 0, t2, 1);
    3131    copyCommand();
    3232    Markup.dump('root', 'After copy');
Note: See TracChangeset for help on using the changeset viewer.