| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 TEST_F(TextIteratorTest, EnteringTextControlsWithOptionComplex) | 153 TEST_F(TextIteratorTest, EnteringTextControlsWithOptionComplex) |
| 154 { | 154 { |
| 155 static const char* input = "<input type='text' value='Beginning of range'><d
iv><div><input type='text' value='Under DOM nodes'></div></div><input type='text
' value='End of range'>"; | 155 static const char* input = "<input type='text' value='Beginning of range'><d
iv><div><input type='text' value='Under DOM nodes'></div></div><input type='text
' value='End of range'>"; |
| 156 setBodyContent(input); | 156 setBodyContent(input); |
| 157 EXPECT_EQ("[\n][Beginning of range][\n][Under DOM nodes][\n][End of range]",
iterate<DOMTree>(TextIteratorEntersTextControls)); | 157 EXPECT_EQ("[\n][Beginning of range][\n][Under DOM nodes][\n][End of range]",
iterate<DOMTree>(TextIteratorEntersTextControls)); |
| 158 EXPECT_EQ("[][\n][Beginning of range][\n][][\n][Under DOM nodes][\n][][\n][E
nd of range]", iterate<FlatTree>(TextIteratorEntersTextControls)); | 158 EXPECT_EQ("[][\n][Beginning of range][\n][][\n][Under DOM nodes][\n][][\n][E
nd of range]", iterate<FlatTree>(TextIteratorEntersTextControls)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST_F(TextIteratorTest, NotEnteringTextControlHostingShadowTreeEvenWithOption) | |
| 162 { | |
| 163 static const char* bodyContent = "<div>Hello, <input type='text' value='inpu
t' id='input'> iterator.</div>"; | |
| 164 static const char* shadowContent = "<span>shadow</span>"; | |
| 165 // TextIterator doesn't emit "input" nor "shadow" since (1) the layoutObject
for <input> is not created; and | |
| 166 // (2) we don't (yet) recurse into shadow trees. | |
| 167 setBodyContent(bodyContent); | |
| 168 createShadowRootForElementWithIDAndSetInnerHTML(document(), "input", shadowC
ontent); | |
| 169 // FIXME: Why is an empty string emitted here? | |
| 170 EXPECT_EQ("[Hello, ][][ iterator.]", iterate<DOMTree>()); | |
| 171 EXPECT_EQ("[Hello, ][][shadow][ iterator.]", iterate<FlatTree>()); | |
| 172 } | |
| 173 | |
| 174 TEST_F(TextIteratorTest, NotEnteringShadowTree) | 161 TEST_F(TextIteratorTest, NotEnteringShadowTree) |
| 175 { | 162 { |
| 176 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 163 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
| 177 static const char* shadowContent = "<span>shadow</span>"; | 164 static const char* shadowContent = "<span>shadow</span>"; |
| 178 setBodyContent(bodyContent); | 165 setBodyContent(bodyContent); |
| 179 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 166 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
| 180 // TextIterator doesn't emit "text" since its layoutObject is not created. T
he shadow tree is ignored. | 167 // TextIterator doesn't emit "text" since its layoutObject is not created. T
he shadow tree is ignored. |
| 181 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); | 168 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); |
| 182 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<FlatTree>()); | 169 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<FlatTree>()); |
| 183 } | 170 } |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 EXPECT_EQ(2, iter.copyTextTo(&buffer, 0, 1)) << "Should emit 2 UChars for 'U
+13000'."; | 491 EXPECT_EQ(2, iter.copyTextTo(&buffer, 0, 1)) << "Should emit 2 UChars for 'U
+13000'."; |
| 505 EXPECT_EQ(4, iter.copyTextTo(&buffer, 2, 3)) << "Should emit 4 UChars for 'U
+13001U+13002'."; | 492 EXPECT_EQ(4, iter.copyTextTo(&buffer, 2, 3)) << "Should emit 4 UChars for 'U
+13001U+13002'."; |
| 506 EXPECT_EQ(3, iter.copyTextTo(&buffer, 6, 2)) << "Should emit 3 UChars for '
U+13140'."; | 493 EXPECT_EQ(3, iter.copyTextTo(&buffer, 6, 2)) << "Should emit 3 UChars for '
U+13140'."; |
| 507 EXPECT_EQ(2, iter.copyTextTo(&buffer, 9, 2)) << "Should emit 2 UChars for 'U
+13141'."; | 494 EXPECT_EQ(2, iter.copyTextTo(&buffer, 9, 2)) << "Should emit 2 UChars for 'U
+13141'."; |
| 508 EXPECT_EQ(1, iter.copyTextTo(&buffer, 11, 1)) << "Should emit 1 UChar for '.
'."; | 495 EXPECT_EQ(1, iter.copyTextTo(&buffer, 11, 1)) << "Should emit 1 UChar for '.
'."; |
| 509 for (int i = 0; i < 12; i++) | 496 for (int i = 0; i < 12; i++) |
| 510 EXPECT_EQ(expected[i], buffer[i]); | 497 EXPECT_EQ(expected[i], buffer[i]); |
| 511 } | 498 } |
| 512 | 499 |
| 513 } // namespace blink | 500 } // namespace blink |
| OLD | NEW |