| OLD | NEW |
| 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/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/NodeList.h" | 10 #include "core/dom/NodeList.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 namespace blink { | 27 namespace blink { |
| 28 | 28 |
| 29 class RangeTest : public EditingTestBase {}; | 29 class RangeTest : public EditingTestBase {}; |
| 30 | 30 |
| 31 TEST_F(RangeTest, createAdjustedToTreeScopeWithPositionInShadowTree) { | 31 TEST_F(RangeTest, createAdjustedToTreeScopeWithPositionInShadowTree) { |
| 32 GetDocument().body()->setInnerHTML("<div><select><option>012</option></div>"); | 32 GetDocument().body()->setInnerHTML("<div><select><option>012</option></div>"); |
| 33 Element* const select_element = GetDocument().QuerySelector("select"); | 33 Element* const select_element = GetDocument().QuerySelector("select"); |
| 34 const Position& position = | 34 const Position& position = |
| 35 Position::AfterNode(select_element->UserAgentShadowRoot()); | 35 Position::AfterNode(*select_element->UserAgentShadowRoot()); |
| 36 Range* const range = | 36 Range* const range = |
| 37 Range::CreateAdjustedToTreeScope(GetDocument(), position); | 37 Range::CreateAdjustedToTreeScope(GetDocument(), position); |
| 38 EXPECT_EQ(range->startContainer(), select_element->parentNode()); | 38 EXPECT_EQ(range->startContainer(), select_element->parentNode()); |
| 39 EXPECT_EQ(static_cast<unsigned>(range->startOffset()), | 39 EXPECT_EQ(static_cast<unsigned>(range->startOffset()), |
| 40 select_element->NodeIndex()); | 40 select_element->NodeIndex()); |
| 41 EXPECT_TRUE(range->collapsed()); | 41 EXPECT_TRUE(range->collapsed()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 TEST_F(RangeTest, extractContentsWithDOMMutationEvent) { | 44 TEST_F(RangeTest, extractContentsWithDOMMutationEvent) { |
| 45 GetDocument().body()->setInnerHTML("<span><b>abc</b>def</span>"); | 45 GetDocument().body()->setInnerHTML("<span><b>abc</b>def</span>"); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 TEST_F(RangeTest, ToPosition) { | 248 TEST_F(RangeTest, ToPosition) { |
| 249 Node& textarea = *HTMLTextAreaElement::Create(GetDocument()); | 249 Node& textarea = *HTMLTextAreaElement::Create(GetDocument()); |
| 250 Range& range = *Range::Create(GetDocument()); | 250 Range& range = *Range::Create(GetDocument()); |
| 251 const Position position = Position(&textarea, 0); | 251 const Position position = Position(&textarea, 0); |
| 252 range.setStart(position, ASSERT_NO_EXCEPTION); | 252 range.setStart(position, ASSERT_NO_EXCEPTION); |
| 253 EXPECT_EQ(position, range.StartPosition()); | 253 EXPECT_EQ(position, range.StartPosition()); |
| 254 EXPECT_EQ(position, range.EndPosition()); | 254 EXPECT_EQ(position, range.EndPosition()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace blink | 257 } // namespace blink |
| OLD | NEW |