Debug assert in DOMSelection::containsNode when node belongs to a different tree
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Mar 2019 21:23:49 +0000 (21:23 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Mar 2019 21:23:49 +0000 (21:23 +0000)
commitcc2974b5040070f884065d83d11a5ec8da0d7343
tree56fc048453e9e7629ae823037fff1e4e4f56e326
parent7e7d78d8b420ed764ad82fcbe0f7a59c4cf9f8b7
Debug assert in DOMSelection::containsNode when node belongs to a different tree
https://bugs.webkit.org/show_bug.cgi?id=196342

Reviewed by Antti Koivisto.

Source/WebCore:

The assertion was wrong. It's possible for Range::compareBoundaryPoints to return WRONG_DOCUMENT_ERR
when the node and the start container belong to two different trees.

Return false in such a case for now since it's unclear (unspecified) what these methods on Selection
should do with respect to shadow trees, preserving the current behavior of release builds.

Test: editing/selection/containsNode-with-no-common-ancestor.html

* page/DOMSelection.cpp:
(WebCore::DOMSelection::containsNode const):

LayoutTests:

Added a regression test to catch the debug assertion failure. The test always passed in release builds.

* editing/selection/containsNode-with-no-common-ancestor-expected.txt: Added.
* editing/selection/containsNode-with-no-common-ancestor.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/selection/containsNode-with-no-common-ancestor-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/containsNode-with-no-common-ancestor.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/DOMSelection.cpp