Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: third_party/WebKit/Source/core/dom/RangeTest.cpp

Issue 2254423002: boundaryTextInserted/Removed() should not call markValid() for irrelavent changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove useless includes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/RangeTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/RangeTest.cpp b/third_party/WebKit/Source/core/dom/RangeTest.cpp
index 7ae205521ee296e463e1b17d26021359b859acb5..3cd933cff638058129bcd9a9e08e8fe067917060 100644
--- a/third_party/WebKit/Source/core/dom/RangeTest.cpp
+++ b/third_party/WebKit/Source/core/dom/RangeTest.cpp
@@ -155,4 +155,48 @@ TEST_F(RangeTest, updateOwnerDocumentIfNeeded)
EXPECT_EQ(1, range->endOffset());
}
+// Regression test for crbug.com/639184
+TEST_F(RangeTest, NotMarkedValidByIrrelevantTextInsert)
+{
+ document().body()->setInnerHTML("<div><span id=span1>foo</span>bar<span id=span2>baz</span></div>", ASSERT_NO_EXCEPTION);
+
+ Element* div = document().querySelector("div");
+ Element* span1 = document().getElementById("span1");
+ Element* span2 = document().getElementById("span2");
+ Text* text = toText(div->childNodes()->item(1));
+
+ Range* range = Range::create(document(), span2, 0, div, 3);
+
+ div->removeChild(span1, ASSERT_NO_EXCEPTION);
+ text->insertData(0, "bar", ASSERT_NO_EXCEPTION);
+
+ EXPECT_TRUE(range->boundaryPointsValid());
+ EXPECT_EQ(span2, range->startContainer());
+ EXPECT_EQ(0, range->startOffset());
+ EXPECT_EQ(div, range->endContainer());
+ EXPECT_EQ(2, range->endOffset());
+}
+
+// Regression test for crbug.com/639184
+TEST_F(RangeTest, NotMarkedValidByIrrelevantTextRemove)
+{
+ document().body()->setInnerHTML("<div><span id=span1>foofoo</span>bar<span id=span2>baz</span></div>", ASSERT_NO_EXCEPTION);
+
+ Element* div = document().querySelector("div");
+ Element* span1 = document().getElementById("span1");
+ Element* span2 = document().getElementById("span2");
+ Text* text = toText(div->childNodes()->item(1));
+
+ Range* range = Range::create(document(), span2, 0, div, 3);
+
+ div->removeChild(span1, ASSERT_NO_EXCEPTION);
+ text->deleteData(0, 3, ASSERT_NO_EXCEPTION);
+
+ EXPECT_TRUE(range->boundaryPointsValid());
+ EXPECT_EQ(span2, range->startContainer());
+ EXPECT_EQ(0, range->startOffset());
+ EXPECT_EQ(div, range->endContainer());
+ EXPECT_EQ(2, range->endOffset());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698