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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 482 |
483 EXPECT_EQ(expectedTextChunks, iterate(TextIteratorEntersAuthorShadowRoots)); | 483 EXPECT_EQ(expectedTextChunks, iterate(TextIteratorEntersAuthorShadowRoots)); |
484 } | 484 } |
485 | 485 |
486 TEST_F(TextIteratorTest, FindPlainTextInvalidTarget) | 486 TEST_F(TextIteratorTest, FindPlainTextInvalidTarget) |
487 { | 487 { |
488 static const char* bodyContent = "<div>foo bar test</div>"; | 488 static const char* bodyContent = "<div>foo bar test</div>"; |
489 setBodyInnerHTML(bodyContent); | 489 setBodyInnerHTML(bodyContent); |
490 RefPtrWillBeRawPtr<Range> range = getBodyRange(); | 490 RefPtrWillBeRawPtr<Range> range = getBodyRange(); |
491 | 491 |
492 RefPtrWillBeRawPtr<Range> expectedRange = range->cloneRange(ASSERT_NO_EXCEPT
ION); | 492 RefPtrWillBeRawPtr<Range> expectedRange = range->cloneRange(); |
493 expectedRange->collapse(false, ASSERT_NO_EXCEPTION); | 493 expectedRange->collapse(false); |
494 | 494 |
495 // A lone lead surrogate (0xDA0A) example taken from fuzz-58. | 495 // A lone lead surrogate (0xDA0A) example taken from fuzz-58. |
496 static const UChar invalid1[] = { | 496 static const UChar invalid1[] = { |
497 0x1461u, 0x2130u, 0x129bu, 0xd711u, 0xd6feu, 0xccadu, 0x7064u, | 497 0x1461u, 0x2130u, 0x129bu, 0xd711u, 0xd6feu, 0xccadu, 0x7064u, |
498 0xd6a0u, 0x4e3bu, 0x03abu, 0x17dcu, 0xb8b7u, 0xbf55u, 0xfca0u, | 498 0xd6a0u, 0x4e3bu, 0x03abu, 0x17dcu, 0xb8b7u, 0xbf55u, 0xfca0u, |
499 0x07fau, 0x0427u, 0xda0au, 0 | 499 0x07fau, 0x0427u, 0xda0au, 0 |
500 }; | 500 }; |
501 | 501 |
502 // A lone trailing surrogate (U+DC01). | 502 // A lone trailing surrogate (U+DC01). |
503 static const UChar invalid2[] = { | 503 static const UChar invalid2[] = { |
504 0x1461u, 0x2130u, 0x129bu, 0xdc01u, 0xd6feu, 0xccadu, 0 | 504 0x1461u, 0x2130u, 0x129bu, 0xdc01u, 0xd6feu, 0xccadu, 0 |
505 }; | 505 }; |
506 // A trailing surrogate followed by a lead surrogate (U+DC03 U+D901). | 506 // A trailing surrogate followed by a lead surrogate (U+DC03 U+D901). |
507 static const UChar invalid3[] = { | 507 static const UChar invalid3[] = { |
508 0xd800u, 0xdc00u, 0x0061u, 0xdc03u, 0xd901u, 0xccadu, 0 | 508 0xd800u, 0xdc00u, 0x0061u, 0xdc03u, 0xd901u, 0xccadu, 0 |
509 }; | 509 }; |
510 | 510 |
511 static const UChar* invalidUStrings[] = { invalid1, invalid2, invalid3 }; | 511 static const UChar* invalidUStrings[] = { invalid1, invalid2, invalid3 }; |
512 | 512 |
513 for (size_t i = 0; i < WTF_ARRAY_LENGTH(invalidUStrings); ++i) { | 513 for (size_t i = 0; i < WTF_ARRAY_LENGTH(invalidUStrings); ++i) { |
514 String invalidTarget(invalidUStrings[i]); | 514 String invalidTarget(invalidUStrings[i]); |
515 RefPtrWillBeRawPtr<Range> actualRange = findPlainText(range.get(), inval
idTarget, 0); | 515 RefPtrWillBeRawPtr<Range> actualRange = findPlainText(range.get(), inval
idTarget, 0); |
516 EXPECT_TRUE(areRangesEqual(expectedRange.get(), actualRange.get())); | 516 EXPECT_TRUE(areRangesEqual(expectedRange.get(), actualRange.get())); |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 } | 520 } |
OLD | NEW |