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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/Range.h" 5 #include "core/dom/Range.h"
6 6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/NodeList.h" 9 #include "core/dom/NodeList.h"
10 #include "core/dom/Text.h" 10 #include "core/dom/Text.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 Document* anotherDocument = Document::create(); 149 Document* anotherDocument = Document::create();
150 anotherDocument->appendChild(foo); 150 anotherDocument->appendChild(foo);
151 151
152 EXPECT_EQ(bar, range->startContainer()); 152 EXPECT_EQ(bar, range->startContainer());
153 EXPECT_EQ(0, range->startOffset()); 153 EXPECT_EQ(0, range->startOffset());
154 EXPECT_EQ(foo, range->endContainer()); 154 EXPECT_EQ(foo, range->endContainer());
155 EXPECT_EQ(1, range->endOffset()); 155 EXPECT_EQ(1, range->endOffset());
156 } 156 }
157 157
158 // Regression test for crbug.com/639184
159 TEST_F(RangeTest, NotMarkedValidByIrrelevantTextInsert)
160 {
161 document().body()->setInnerHTML("<div><span id=span1>foo</span>bar<span id=s pan2>baz</span></div>", ASSERT_NO_EXCEPTION);
162
163 Element* div = document().querySelector("div");
164 Element* span1 = document().getElementById("span1");
165 Element* span2 = document().getElementById("span2");
166 Text* text = toText(div->childNodes()->item(1));
167
168 Range* range = Range::create(document(), span2, 0, div, 3);
169
170 div->removeChild(span1, ASSERT_NO_EXCEPTION);
171 text->insertData(0, "bar", ASSERT_NO_EXCEPTION);
172
173 EXPECT_TRUE(range->boundaryPointsValid());
174 EXPECT_EQ(span2, range->startContainer());
175 EXPECT_EQ(0, range->startOffset());
176 EXPECT_EQ(div, range->endContainer());
177 EXPECT_EQ(2, range->endOffset());
178 }
179
180 // Regression test for crbug.com/639184
181 TEST_F(RangeTest, NotMarkedValidByIrrelevantTextRemove)
182 {
183 document().body()->setInnerHTML("<div><span id=span1>foofoo</span>bar<span i d=span2>baz</span></div>", ASSERT_NO_EXCEPTION);
184
185 Element* div = document().querySelector("div");
186 Element* span1 = document().getElementById("span1");
187 Element* span2 = document().getElementById("span2");
188 Text* text = toText(div->childNodes()->item(1));
189
190 Range* range = Range::create(document(), span2, 0, div, 3);
191
192 div->removeChild(span1, ASSERT_NO_EXCEPTION);
193 text->deleteData(0, 3, ASSERT_NO_EXCEPTION);
194
195 EXPECT_TRUE(range->boundaryPointsValid());
196 EXPECT_EQ(span2, range->startContainer());
197 EXPECT_EQ(0, range->startOffset());
198 EXPECT_EQ(div, range->endContainer());
199 EXPECT_EQ(2, range->endOffset());
200 }
201
158 } // namespace blink 202 } // namespace blink
OLDNEW
« 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