| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3563 registerMockedHttpURLLoad("find.html"); | 3563 registerMockedHttpURLLoad("find.html"); |
| 3564 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3564 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 3565 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); | 3565 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); |
| 3566 ASSERT_TRUE(webViewHelper.webView()->mainFrame()->isWebLocalFrame()); | 3566 ASSERT_TRUE(webViewHelper.webView()->mainFrame()->isWebLocalFrame()); |
| 3567 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame
(); | 3567 WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame
(); |
| 3568 const int findIdentifier = 12345; | 3568 const int findIdentifier = 12345; |
| 3569 WebFindOptions options; | 3569 WebFindOptions options; |
| 3570 | 3570 |
| 3571 // Find in a <div> element. | 3571 // Find in a <div> element. |
| 3572 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options
, false, 0)); | 3572 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options
, false, 0)); |
| 3573 frame->stopFinding(false); | 3573 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
| 3574 WebRange range = frame->selectionRange(); | 3574 WebRange range = frame->selectionRange(); |
| 3575 EXPECT_EQ(5, range.startOffset()); | 3575 EXPECT_EQ(5, range.startOffset()); |
| 3576 EXPECT_EQ(9, range.endOffset()); | 3576 EXPECT_EQ(9, range.endOffset()); |
| 3577 EXPECT_TRUE(frame->document().focusedElement().isNull()); | 3577 EXPECT_TRUE(frame->document().focusedElement().isNull()); |
| 3578 | 3578 |
| 3579 // Find in an <input> value. | 3579 // Find in an <input> value. |
| 3580 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options
, false, 0)); | 3580 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options
, false, 0)); |
| 3581 // Confirm stopFinding(false) sets the selection on the found text. | 3581 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the
selection on the found text. |
| 3582 frame->stopFinding(false); | 3582 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
| 3583 range = frame->selectionRange(); | 3583 range = frame->selectionRange(); |
| 3584 ASSERT_FALSE(range.isNull()); | 3584 ASSERT_FALSE(range.isNull()); |
| 3585 EXPECT_EQ(5, range.startOffset()); | 3585 EXPECT_EQ(5, range.startOffset()); |
| 3586 EXPECT_EQ(9, range.endOffset()); | 3586 EXPECT_EQ(9, range.endOffset()); |
| 3587 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("input")); | 3587 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("input")); |
| 3588 | 3588 |
| 3589 // Find in a <textarea> content. | 3589 // Find in a <textarea> content. |
| 3590 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options
, false, 0)); | 3590 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options
, false, 0)); |
| 3591 // Confirm stopFinding(false) sets the selection on the found text. | 3591 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the
selection on the found text. |
| 3592 frame->stopFinding(false); | 3592 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
| 3593 range = frame->selectionRange(); | 3593 range = frame->selectionRange(); |
| 3594 ASSERT_FALSE(range.isNull()); | 3594 ASSERT_FALSE(range.isNull()); |
| 3595 EXPECT_EQ(5, range.startOffset()); | 3595 EXPECT_EQ(5, range.startOffset()); |
| 3596 EXPECT_EQ(9, range.endOffset()); | 3596 EXPECT_EQ(9, range.endOffset()); |
| 3597 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("textarea")); | 3597 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("textarea")); |
| 3598 | 3598 |
| 3599 // Find in a contentEditable element. | 3599 // Find in a contentEditable element. |
| 3600 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options
, false, 0)); | 3600 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options
, false, 0)); |
| 3601 // Confirm stopFinding(false) sets the selection on the found text. | 3601 // Confirm stopFinding(WebLocalFrame::StopFindActionKeepSelection) sets the
selection on the found text. |
| 3602 frame->stopFinding(false); | 3602 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
| 3603 range = frame->selectionRange(); | 3603 range = frame->selectionRange(); |
| 3604 ASSERT_FALSE(range.isNull()); | 3604 ASSERT_FALSE(range.isNull()); |
| 3605 EXPECT_EQ(0, range.startOffset()); | 3605 EXPECT_EQ(0, range.startOffset()); |
| 3606 EXPECT_EQ(4, range.endOffset()); | 3606 EXPECT_EQ(4, range.endOffset()); |
| 3607 // "bar4" is surrounded by <span>, but the focusable node should be the pare
nt <div>. | 3607 // "bar4" is surrounded by <span>, but the focusable node should be the pare
nt <div>. |
| 3608 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("div")); | 3608 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("div")); |
| 3609 | 3609 |
| 3610 // Find in <select> content. | 3610 // Find in <select> content. |
| 3611 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false, 0)); | 3611 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false, 0)); |
| 3612 // If there are any matches, stopFinding will set the selection on the found
text. | 3612 // If there are any matches, stopFinding will set the selection on the found
text. |
| 3613 // However, we do not expect any matches, so check that the selection is nul
l. | 3613 // However, we do not expect any matches, so check that the selection is nul
l. |
| 3614 frame->stopFinding(false); | 3614 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
| 3615 range = frame->selectionRange(); | 3615 range = frame->selectionRange(); |
| 3616 ASSERT_TRUE(range.isNull()); | 3616 ASSERT_TRUE(range.isNull()); |
| 3617 } | 3617 } |
| 3618 | 3618 |
| 3619 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) | 3619 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) |
| 3620 { | 3620 { |
| 3621 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3621 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 3622 webViewHelper.initializeAndLoad("about:blank", true); | 3622 webViewHelper.initializeAndLoad("about:blank", true); |
| 3623 // We set the size because it impacts line wrapping, which changes the | 3623 // We set the size because it impacts line wrapping, which changes the |
| 3624 // resulting text value. | 3624 // resulting text value. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3737 int activeIndex() const { return m_activeIndex; } | 3737 int activeIndex() const { return m_activeIndex; } |
| 3738 | 3738 |
| 3739 private: | 3739 private: |
| 3740 bool m_findResultsAreReady; | 3740 bool m_findResultsAreReady; |
| 3741 int m_count; | 3741 int m_count; |
| 3742 int m_activeIndex; | 3742 int m_activeIndex; |
| 3743 }; | 3743 }; |
| 3744 | 3744 |
| 3745 TEST_P(ParameterizedWebFrameTest, FindInPageMatchRects) | 3745 TEST_P(ParameterizedWebFrameTest, FindInPageMatchRects) |
| 3746 { | 3746 { |
| 3747 registerMockedHttpURLLoad("find_in_page.html"); | |
| 3748 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3747 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 3749 | 3748 |
| 3750 FindUpdateWebFrameClient client; | 3749 FindUpdateWebFrameClient client; |
| 3751 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3750 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 3752 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3751 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page_frame.html", true,
&client); |
| 3753 webViewHelper.resize(WebSize(640, 480)); | 3752 webViewHelper.resize(WebSize(640, 480)); |
| 3754 webViewHelper.webView()->setMaximumLegibleScale(1.f); | 3753 webViewHelper.webView()->setMaximumLegibleScale(1.f); |
| 3755 webViewHelper.webView()->updateAllLifecyclePhases(); | 3754 webViewHelper.webView()->updateAllLifecyclePhases(); |
| 3756 runPendingTasks(); | 3755 runPendingTasks(); |
| 3757 | 3756 |
| 3758 // Note that the 'result 19' in the <select> element is not expected to prod
uce a match. | 3757 // Note that the 'result 19' in the <select> element is not expected to |
| 3758 // produce a match. Also, results 00 and 01 are in a different frame that is |
| 3759 // not included in this test. |
| 3759 const char kFindString[] = "result"; | 3760 const char kFindString[] = "result"; |
| 3760 const int kFindIdentifier = 12345; | 3761 const int kFindIdentifier = 12345; |
| 3761 const int kNumResults = 19; | 3762 const int kNumResults = 17; |
| 3762 | 3763 |
| 3763 WebFindOptions options; | 3764 WebFindOptions options; |
| 3764 WebString searchText = WebString::fromUTF8(kFindString); | 3765 WebString searchText = WebString::fromUTF8(kFindString); |
| 3765 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3766 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3766 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3767 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3767 | 3768 |
| 3768 mainFrame->resetMatchCount(); | 3769 mainFrame->resetMatchCount(); |
| 3769 | 3770 |
| 3770 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3771 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3771 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); | 3772 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); |
| 3772 | 3773 |
| 3773 runPendingTasks(); | 3774 runPendingTasks(); |
| 3774 EXPECT_TRUE(client.findResultsAreReady()); | 3775 EXPECT_TRUE(client.findResultsAreReady()); |
| 3775 | 3776 |
| 3776 WebVector<WebFloatRect> webMatchRects; | 3777 WebVector<WebFloatRect> webMatchRects; |
| 3777 mainFrame->findMatchRects(webMatchRects); | 3778 mainFrame->findMatchRects(webMatchRects); |
| 3778 ASSERT_EQ(webMatchRects.size(), static_cast<size_t>(kNumResults)); | 3779 ASSERT_EQ(static_cast<size_t>(kNumResults), webMatchRects.size()); |
| 3779 int rectsVersion = mainFrame->findMatchMarkersVersion(); | 3780 int rectsVersion = mainFrame->findMatchMarkersVersion(); |
| 3780 | 3781 |
| 3781 for (int resultIndex = 0; resultIndex < kNumResults; ++resultIndex) { | 3782 for (int resultIndex = 0; resultIndex < kNumResults; ++resultIndex) { |
| 3782 FloatRect resultRect = static_cast<FloatRect>(webMatchRects[resultIndex]
); | 3783 FloatRect resultRect = static_cast<FloatRect>(webMatchRects[resultIndex]
); |
| 3783 | 3784 |
| 3784 // Select the match by the center of its rect. | 3785 // Select the match by the center of its rect. |
| 3785 EXPECT_EQ(mainFrame->selectNearestFindMatch(resultRect.center(), 0), res
ultIndex + 1); | 3786 EXPECT_EQ(mainFrame->selectNearestFindMatch(resultRect.center(), 0), res
ultIndex + 1); |
| 3786 | 3787 |
| 3787 // Check that the find result ordering matches with our expectations. | 3788 // Check that the find result ordering matches with our expectations. |
| 3788 Range* result = mainFrame->textFinder()->activeMatchFrame()->textFinder(
)->activeMatch(); | 3789 Range* result = mainFrame->textFinder()->activeMatch(); |
| 3789 ASSERT_TRUE(result); | 3790 ASSERT_TRUE(result); |
| 3790 result->setEnd(result->endContainer(), result->endOffset() + 3); | 3791 result->setEnd(result->endContainer(), result->endOffset() + 3); |
| 3791 EXPECT_EQ(result->text(), String::format("%s %02d", kFindString, resultI
ndex)); | 3792 EXPECT_EQ(result->text(), String::format("%s %02d", kFindString, resultI
ndex + 2)); |
| 3792 | 3793 |
| 3793 // Verify that the expected match rect also matches the currently active
match. | 3794 // Verify that the expected match rect also matches the currently active
match. |
| 3794 // Compare the enclosing rects to prevent precision issues caused by CSS
transforms. | 3795 // Compare the enclosing rects to prevent precision issues caused by CSS
transforms. |
| 3795 FloatRect activeMatch = mainFrame->activeFindMatchRect(); | 3796 FloatRect activeMatch = mainFrame->activeFindMatchRect(); |
| 3796 EXPECT_EQ(enclosingIntRect(activeMatch), enclosingIntRect(resultRect)); | 3797 EXPECT_EQ(enclosingIntRect(activeMatch), enclosingIntRect(resultRect)); |
| 3797 | 3798 |
| 3798 // The rects version should not have changed. | 3799 // The rects version should not have changed. |
| 3799 EXPECT_EQ(mainFrame->findMatchMarkersVersion(), rectsVersion); | 3800 EXPECT_EQ(mainFrame->findMatchMarkersVersion(), rectsVersion); |
| 3800 } | 3801 } |
| 3801 | 3802 |
| 3802 // All results after the first two ones should be below between them in find
-in-page coordinates. | |
| 3803 // This is because results 2 to 9 are inside an iframe located between resul
ts 0 and 1. This applies to the fixed div too. | |
| 3804 EXPECT_TRUE(webMatchRects[0].y < webMatchRects[1].y); | |
| 3805 for (int resultIndex = 2; resultIndex < kNumResults; ++resultIndex) { | |
| 3806 EXPECT_TRUE(webMatchRects[0].y < webMatchRects[resultIndex].y); | |
| 3807 EXPECT_TRUE(webMatchRects[1].y > webMatchRects[resultIndex].y); | |
| 3808 } | |
| 3809 | |
| 3810 // Result 3 should be below both 2 and 4. This is caused by the CSS transfor
m in the containing div. | |
| 3811 // If the transform doesn't work then 3 will be between 2 and 4. | |
| 3812 EXPECT_TRUE(webMatchRects[3].y > webMatchRects[2].y); | |
| 3813 EXPECT_TRUE(webMatchRects[3].y > webMatchRects[4].y); | |
| 3814 | |
| 3815 // Results 6, 7, 8 and 9 should be one below the other in that same order. | |
| 3816 // If overflow:scroll is not properly handled then result 8 would be below r
esult 9 or | |
| 3817 // result 7 above result 6 depending on the scroll. | |
| 3818 EXPECT_TRUE(webMatchRects[6].y < webMatchRects[7].y); | |
| 3819 EXPECT_TRUE(webMatchRects[7].y < webMatchRects[8].y); | |
| 3820 EXPECT_TRUE(webMatchRects[8].y < webMatchRects[9].y); | |
| 3821 | |
| 3822 // Results 11, 12, 13 and 14 should be between results 10 and 15, as they ar
e inside the table. | |
| 3823 EXPECT_TRUE(webMatchRects[11].y > webMatchRects[10].y); | |
| 3824 EXPECT_TRUE(webMatchRects[12].y > webMatchRects[10].y); | |
| 3825 EXPECT_TRUE(webMatchRects[13].y > webMatchRects[10].y); | |
| 3826 EXPECT_TRUE(webMatchRects[14].y > webMatchRects[10].y); | |
| 3827 EXPECT_TRUE(webMatchRects[11].y < webMatchRects[15].y); | |
| 3828 EXPECT_TRUE(webMatchRects[12].y < webMatchRects[15].y); | |
| 3829 EXPECT_TRUE(webMatchRects[13].y < webMatchRects[15].y); | |
| 3830 EXPECT_TRUE(webMatchRects[14].y < webMatchRects[15].y); | |
| 3831 | |
| 3832 // Result 11 should be above 12, 13 and 14 as it's in the table header. | |
| 3833 EXPECT_TRUE(webMatchRects[11].y < webMatchRects[12].y); | |
| 3834 EXPECT_TRUE(webMatchRects[11].y < webMatchRects[13].y); | |
| 3835 EXPECT_TRUE(webMatchRects[11].y < webMatchRects[14].y); | |
| 3836 | |
| 3837 // Result 11 should also be right to 12, 13 and 14 because of the colspan. | |
| 3838 EXPECT_TRUE(webMatchRects[11].x > webMatchRects[12].x); | |
| 3839 EXPECT_TRUE(webMatchRects[11].x > webMatchRects[13].x); | |
| 3840 EXPECT_TRUE(webMatchRects[11].x > webMatchRects[14].x); | |
| 3841 | |
| 3842 // Result 12 should be left to results 11, 13 and 14 in the table layout. | |
| 3843 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[11].x); | |
| 3844 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[13].x); | |
| 3845 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[14].x); | |
| 3846 | |
| 3847 // Results 13, 12 and 14 should be one above the other in that order because
of the rowspan | |
| 3848 // and vertical-align: middle by default. | |
| 3849 EXPECT_TRUE(webMatchRects[13].y < webMatchRects[12].y); | |
| 3850 EXPECT_TRUE(webMatchRects[12].y < webMatchRects[14].y); | |
| 3851 | |
| 3852 // Result 16 should be below result 15. | |
| 3853 EXPECT_TRUE(webMatchRects[15].y > webMatchRects[14].y); | |
| 3854 | |
| 3855 // Result 18 should be normalized with respect to the position:relative div,
and not it's | |
| 3856 // immediate containing div. Consequently, result 18 should be above result
17. | |
| 3857 EXPECT_TRUE(webMatchRects[17].y > webMatchRects[18].y); | |
| 3858 | |
| 3859 // Resizing should update the rects version. | 3803 // Resizing should update the rects version. |
| 3860 webViewHelper.resize(WebSize(800, 600)); | 3804 webViewHelper.resize(WebSize(800, 600)); |
| 3861 runPendingTasks(); | 3805 runPendingTasks(); |
| 3862 EXPECT_TRUE(mainFrame->findMatchMarkersVersion() != rectsVersion); | 3806 EXPECT_TRUE(mainFrame->findMatchMarkersVersion() != rectsVersion); |
| 3863 } | 3807 } |
| 3864 | 3808 |
| 3865 TEST_F(WebFrameTest, FindInPageActiveIndex) | 3809 TEST_F(WebFrameTest, FindInPageActiveIndex) |
| 3866 { | 3810 { |
| 3867 registerMockedHttpURLLoad("find_match_count.html"); | 3811 registerMockedHttpURLLoad("find_match_count.html"); |
| 3868 | 3812 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3880 WebString searchText = WebString::fromUTF8(kFindString); | 3824 WebString searchText = WebString::fromUTF8(kFindString); |
| 3881 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | 3825 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3882 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3826 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3883 mainFrame->resetMatchCount(); | 3827 mainFrame->resetMatchCount(); |
| 3884 | 3828 |
| 3885 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3829 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3886 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); | 3830 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); |
| 3887 | 3831 |
| 3888 runPendingTasks(); | 3832 runPendingTasks(); |
| 3889 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3833 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3890 mainFrame->stopFinding(true); | 3834 mainFrame->stopFinding(WebLocalFrame::StopFindActionClearSelection); |
| 3891 | 3835 |
| 3892 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3836 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3893 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); | 3837 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); |
| 3894 | 3838 |
| 3895 runPendingTasks(); | 3839 runPendingTasks(); |
| 3896 EXPECT_TRUE(client.findResultsAreReady()); | 3840 EXPECT_TRUE(client.findResultsAreReady()); |
| 3897 EXPECT_EQ(kActiveIndex, client.activeIndex()); | 3841 EXPECT_EQ(kActiveIndex, client.activeIndex()); |
| 3898 | 3842 |
| 3899 const char* kFindStringNew = "e"; | 3843 const char* kFindStringNew = "e"; |
| 3900 WebString searchTextNew = WebString::fromUTF8(kFindStringNew); | 3844 WebString searchTextNew = WebString::fromUTF8(kFindStringNew); |
| 3901 | 3845 |
| 3902 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchTextNew, options, false,
0)); | 3846 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchTextNew, options, false,
0)); |
| 3903 mainFrame->resetMatchCount(); | 3847 mainFrame->resetMatchCount(); |
| 3904 | 3848 |
| 3905 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3849 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3906 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
New, options, true); | 3850 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
New, options, true); |
| 3907 | 3851 |
| 3908 runPendingTasks(); | 3852 runPendingTasks(); |
| 3909 EXPECT_TRUE(client.findResultsAreReady()); | 3853 EXPECT_TRUE(client.findResultsAreReady()); |
| 3910 EXPECT_EQ(kActiveIndex, client.activeIndex()); | 3854 EXPECT_EQ(kActiveIndex, client.activeIndex()); |
| 3911 } | 3855 } |
| 3912 | 3856 |
| 3913 TEST_P(ParameterizedWebFrameTest, FindInPageSkipsHiddenFrames) | |
| 3914 { | |
| 3915 registerMockedHttpURLLoad("find_in_hidden_frame.html"); | |
| 3916 | |
| 3917 FindUpdateWebFrameClient client; | |
| 3918 FrameTestHelpers::WebViewHelper webViewHelper(this); | |
| 3919 webViewHelper.initializeAndLoad(m_baseURL + "find_in_hidden_frame.html", tru
e, &client); | |
| 3920 webViewHelper.resize(WebSize(640, 480)); | |
| 3921 runPendingTasks(); | |
| 3922 | |
| 3923 const char kFindString[] = "hello"; | |
| 3924 const int kFindIdentifier = 12345; | |
| 3925 const int kNumResults = 1; | |
| 3926 | |
| 3927 WebFindOptions options; | |
| 3928 WebString searchText = WebString::fromUTF8(kFindString); | |
| 3929 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); | |
| 3930 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | |
| 3931 | |
| 3932 mainFrame->resetMatchCount(); | |
| 3933 | |
| 3934 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | |
| 3935 frame->toWebLocalFrame()->scopeStringMatches(kFindIdentifier, searchText
, options, true); | |
| 3936 | |
| 3937 runPendingTasks(); | |
| 3938 EXPECT_TRUE(client.findResultsAreReady()); | |
| 3939 EXPECT_EQ(kNumResults, client.count()); | |
| 3940 } | |
| 3941 | |
| 3942 TEST_P(ParameterizedWebFrameTest, FindOnDetachedFrame) | 3857 TEST_P(ParameterizedWebFrameTest, FindOnDetachedFrame) |
| 3943 { | 3858 { |
| 3944 registerMockedHttpURLLoad("find_in_page.html"); | 3859 registerMockedHttpURLLoad("find_in_page.html"); |
| 3945 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3860 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 3946 | 3861 |
| 3947 FindUpdateWebFrameClient client; | 3862 FindUpdateWebFrameClient client; |
| 3948 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3863 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 3949 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3864 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
| 3950 webViewHelper.resize(WebSize(640, 480)); | 3865 webViewHelper.resize(WebSize(640, 480)); |
| 3951 runPendingTasks(); | 3866 runPendingTasks(); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4162 "var newTextNode = document.createTextNode('bar5 foo5');" | 4077 "var newTextNode = document.createTextNode('bar5 foo5');" |
| 4163 "var textArea = document.getElementsByTagName('textarea')[0];" | 4078 "var textArea = document.getElementsByTagName('textarea')[0];" |
| 4164 "document.body.insertBefore(newTextNode, textArea);")); | 4079 "document.body.insertBefore(newTextNode, textArea);")); |
| 4165 | 4080 |
| 4166 // Find in a <input> element. | 4081 // Find in a <input> element. |
| 4167 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti
veNow)); | 4082 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti
veNow)); |
| 4168 EXPECT_TRUE(activeNow); | 4083 EXPECT_TRUE(activeNow); |
| 4169 | 4084 |
| 4170 // Find in the inserted text node. | 4085 // Find in the inserted text node. |
| 4171 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti
veNow)); | 4086 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti
veNow)); |
| 4172 frame->stopFinding(false); | 4087 frame->stopFinding(WebLocalFrame::StopFindActionKeepSelection); |
| 4173 WebRange range = frame->selectionRange(); | 4088 WebRange range = frame->selectionRange(); |
| 4174 EXPECT_EQ(5, range.startOffset()); | 4089 EXPECT_EQ(5, range.startOffset()); |
| 4175 EXPECT_EQ(8, range.endOffset()); | 4090 EXPECT_EQ(8, range.endOffset()); |
| 4176 EXPECT_TRUE(frame->document().focusedElement().isNull()); | 4091 EXPECT_TRUE(frame->document().focusedElement().isNull()); |
| 4177 EXPECT_FALSE(activeNow); | 4092 EXPECT_FALSE(activeNow); |
| 4178 } | 4093 } |
| 4179 | 4094 |
| 4180 static WebPoint topLeft(const WebRect& rect) | 4095 static WebPoint topLeft(const WebRect& rect) |
| 4181 { | 4096 { |
| 4182 return WebPoint(rect.x, rect.y); | 4097 return WebPoint(rect.x, rect.y); |
| (...skipping 4501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8684 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8599 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
| 8685 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8600 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 8686 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8601 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
| 8687 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8602 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
| 8688 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); | 8603 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); |
| 8689 ASSERT_TRUE(result->IsString()); | 8604 ASSERT_TRUE(result->IsString()); |
| 8690 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); | 8605 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); |
| 8691 } | 8606 } |
| 8692 | 8607 |
| 8693 } // namespace blink | 8608 } // namespace blink |
| OLD | NEW |