Chromium Code Reviews| 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 3549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3560 TEST_P(ParameterizedWebFrameTest, FindInPage) | 3560 TEST_P(ParameterizedWebFrameTest, FindInPage) |
| 3561 { | 3561 { |
| 3562 registerMockedHttpURLLoad("find.html"); | 3562 registerMockedHttpURLLoad("find.html"); |
| 3563 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3563 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 3564 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); | 3564 webViewHelper.initializeAndLoad(m_baseURL + "find.html"); |
| 3565 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 3565 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 3566 const int findIdentifier = 12345; | 3566 const int findIdentifier = 12345; |
| 3567 WebFindOptions options; | 3567 WebFindOptions options; |
| 3568 | 3568 |
| 3569 // Find in a <div> element. | 3569 // Find in a <div> element. |
| 3570 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options , false, 0)); | 3570 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options , false, 0, nullptr)); |
| 3571 frame->stopFinding(false); | 3571 frame->stopFinding(false); |
| 3572 WebRange range = frame->selectionRange(); | 3572 WebRange range = frame->selectionRange(); |
| 3573 EXPECT_EQ(5, range.startOffset()); | 3573 EXPECT_EQ(5, range.startOffset()); |
| 3574 EXPECT_EQ(9, range.endOffset()); | 3574 EXPECT_EQ(9, range.endOffset()); |
| 3575 EXPECT_TRUE(frame->document().focusedElement().isNull()); | 3575 EXPECT_TRUE(frame->document().focusedElement().isNull()); |
| 3576 | 3576 |
| 3577 // Find in an <input> value. | 3577 // Find in an <input> value. |
| 3578 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options , false, 0)); | 3578 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options , false, 0, nullptr)); |
| 3579 // Confirm stopFinding(false) sets the selection on the found text. | 3579 // Confirm stopFinding(false) sets the selection on the found text. |
| 3580 frame->stopFinding(false); | 3580 frame->stopFinding(false); |
| 3581 range = frame->selectionRange(); | 3581 range = frame->selectionRange(); |
| 3582 ASSERT_FALSE(range.isNull()); | 3582 ASSERT_FALSE(range.isNull()); |
| 3583 EXPECT_EQ(5, range.startOffset()); | 3583 EXPECT_EQ(5, range.startOffset()); |
| 3584 EXPECT_EQ(9, range.endOffset()); | 3584 EXPECT_EQ(9, range.endOffset()); |
| 3585 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("input")); | 3585 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("input")); |
| 3586 | 3586 |
| 3587 // Find in a <textarea> content. | 3587 // Find in a <textarea> content. |
| 3588 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options , false, 0)); | 3588 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options , false, 0, nullptr)); |
| 3589 // Confirm stopFinding(false) sets the selection on the found text. | 3589 // Confirm stopFinding(false) sets the selection on the found text. |
| 3590 frame->stopFinding(false); | 3590 frame->stopFinding(false); |
| 3591 range = frame->selectionRange(); | 3591 range = frame->selectionRange(); |
| 3592 ASSERT_FALSE(range.isNull()); | 3592 ASSERT_FALSE(range.isNull()); |
| 3593 EXPECT_EQ(5, range.startOffset()); | 3593 EXPECT_EQ(5, range.startOffset()); |
| 3594 EXPECT_EQ(9, range.endOffset()); | 3594 EXPECT_EQ(9, range.endOffset()); |
| 3595 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("textarea")); | 3595 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("textarea")); |
| 3596 | 3596 |
| 3597 // Find in a contentEditable element. | 3597 // Find in a contentEditable element. |
| 3598 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options , false, 0)); | 3598 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options , false, 0, nullptr)); |
| 3599 // Confirm stopFinding(false) sets the selection on the found text. | 3599 // Confirm stopFinding(false) sets the selection on the found text. |
| 3600 frame->stopFinding(false); | 3600 frame->stopFinding(false); |
| 3601 range = frame->selectionRange(); | 3601 range = frame->selectionRange(); |
| 3602 ASSERT_FALSE(range.isNull()); | 3602 ASSERT_FALSE(range.isNull()); |
| 3603 EXPECT_EQ(0, range.startOffset()); | 3603 EXPECT_EQ(0, range.startOffset()); |
| 3604 EXPECT_EQ(4, range.endOffset()); | 3604 EXPECT_EQ(4, range.endOffset()); |
| 3605 // "bar4" is surrounded by <span>, but the focusable node should be the pare nt <div>. | 3605 // "bar4" is surrounded by <span>, but the focusable node should be the pare nt <div>. |
| 3606 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("div")); | 3606 EXPECT_TRUE(frame->document().focusedElement().hasHTMLTagName("div")); |
| 3607 | 3607 |
| 3608 // Find in <select> content. | 3608 // Find in <select> content. |
| 3609 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option s, false, 0)); | 3609 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option s, false, 0, nullptr)); |
| 3610 // If there are any matches, stopFinding will set the selection on the found text. | 3610 // If there are any matches, stopFinding will set the selection on the found text. |
| 3611 // However, we do not expect any matches, so check that the selection is nul l. | 3611 // However, we do not expect any matches, so check that the selection is nul l. |
| 3612 frame->stopFinding(false); | 3612 frame->stopFinding(false); |
| 3613 range = frame->selectionRange(); | 3613 range = frame->selectionRange(); |
| 3614 ASSERT_TRUE(range.isNull()); | 3614 ASSERT_TRUE(range.isNull()); |
| 3615 } | 3615 } |
| 3616 | 3616 |
| 3617 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) | 3617 TEST_P(ParameterizedWebFrameTest, GetContentAsPlainText) |
| 3618 { | 3618 { |
| 3619 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3619 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3746 runPendingTasks(); | 3746 runPendingTasks(); |
| 3747 | 3747 |
| 3748 // Note that the 'result 19' in the <select> element is not expected to prod uce a match. | 3748 // Note that the 'result 19' in the <select> element is not expected to prod uce a match. |
| 3749 static const char* kFindString = "result"; | 3749 static const char* kFindString = "result"; |
| 3750 static const int kFindIdentifier = 12345; | 3750 static const int kFindIdentifier = 12345; |
| 3751 static const int kNumResults = 19; | 3751 static const int kNumResults = 19; |
| 3752 | 3752 |
| 3753 WebFindOptions options; | 3753 WebFindOptions options; |
| 3754 WebString searchText = WebString::fromUTF8(kFindString); | 3754 WebString searchText = WebString::fromUTF8(kFindString); |
| 3755 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 3755 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 3756 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; | 3756 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 3757 | 3757 |
| 3758 mainFrame->resetMatchCount(); | 3758 mainFrame->resetMatchCount(); |
| 3759 | 3759 |
| 3760 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3760 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3761 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3761 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3762 | 3762 |
| 3763 runPendingTasks(); | 3763 runPendingTasks(); |
| 3764 EXPECT_TRUE(client.findResultsAreReady()); | 3764 EXPECT_TRUE(client.findResultsAreReady()); |
| 3765 | 3765 |
| 3766 WebVector<WebFloatRect> webMatchRects; | 3766 WebVector<WebFloatRect> webMatchRects; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3862 webViewHelper.resize(WebSize(640, 480)); | 3862 webViewHelper.resize(WebSize(640, 480)); |
| 3863 runPendingTasks(); | 3863 runPendingTasks(); |
| 3864 | 3864 |
| 3865 static const char* kFindString = "hello"; | 3865 static const char* kFindString = "hello"; |
| 3866 static const int kFindIdentifier = 12345; | 3866 static const int kFindIdentifier = 12345; |
| 3867 static const int kNumResults = 1; | 3867 static const int kNumResults = 1; |
| 3868 | 3868 |
| 3869 WebFindOptions options; | 3869 WebFindOptions options; |
| 3870 WebString searchText = WebString::fromUTF8(kFindString); | 3870 WebString searchText = WebString::fromUTF8(kFindString); |
| 3871 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 3871 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 3872 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; | 3872 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 3873 | 3873 |
| 3874 mainFrame->resetMatchCount(); | 3874 mainFrame->resetMatchCount(); |
| 3875 | 3875 |
| 3876 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3876 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3877 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3877 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3878 | 3878 |
| 3879 runPendingTasks(); | 3879 runPendingTasks(); |
| 3880 EXPECT_TRUE(client.findResultsAreReady()); | 3880 EXPECT_TRUE(client.findResultsAreReady()); |
| 3881 EXPECT_EQ(kNumResults, client.count()); | 3881 EXPECT_EQ(kNumResults, client.count()); |
| 3882 } | 3882 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 3897 | 3897 |
| 3898 WebFindOptions options; | 3898 WebFindOptions options; |
| 3899 WebString searchText = WebString::fromUTF8(kFindString); | 3899 WebString searchText = WebString::fromUTF8(kFindString); |
| 3900 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 3900 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 3901 RefPtrWillBeRawPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(main Frame->traverseNext(false)); | 3901 RefPtrWillBeRawPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(main Frame->traverseNext(false)); |
| 3902 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); | 3902 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); |
| 3903 | 3903 |
| 3904 // Detach the frame before finding. | 3904 // Detach the frame before finding. |
| 3905 removeElementById(mainFrame, "frame"); | 3905 removeElementById(mainFrame, "frame"); |
| 3906 | 3906 |
| 3907 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; | 3907 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 3908 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0)); | 3908 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 3909 | 3909 |
| 3910 runPendingTasks(); | 3910 runPendingTasks(); |
| 3911 EXPECT_FALSE(client.findResultsAreReady()); | 3911 EXPECT_FALSE(client.findResultsAreReady()); |
| 3912 | 3912 |
| 3913 mainFrame->resetMatchCount(); | 3913 mainFrame->resetMatchCount(); |
| 3914 | 3914 |
| 3915 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3915 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3916 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3916 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3917 | 3917 |
| 3918 runPendingTasks(); | 3918 runPendingTasks(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 3933 static const char* kFindString = "result"; | 3933 static const char* kFindString = "result"; |
| 3934 static const int kFindIdentifier = 12345; | 3934 static const int kFindIdentifier = 12345; |
| 3935 | 3935 |
| 3936 WebFindOptions options; | 3936 WebFindOptions options; |
| 3937 WebString searchText = WebString::fromUTF8(kFindString); | 3937 WebString searchText = WebString::fromUTF8(kFindString); |
| 3938 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 3938 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 3939 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); | 3939 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); |
| 3940 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); | 3940 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); |
| 3941 | 3941 |
| 3942 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3942 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3943 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)) ; | 3943 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 3944 | 3944 |
| 3945 runPendingTasks(); | 3945 runPendingTasks(); |
| 3946 EXPECT_FALSE(client.findResultsAreReady()); | 3946 EXPECT_FALSE(client.findResultsAreReady()); |
| 3947 | 3947 |
| 3948 // Detach the frame between finding and scoping. | 3948 // Detach the frame between finding and scoping. |
| 3949 removeElementById(mainFrame, "frame"); | 3949 removeElementById(mainFrame, "frame"); |
| 3950 | 3950 |
| 3951 mainFrame->resetMatchCount(); | 3951 mainFrame->resetMatchCount(); |
| 3952 | 3952 |
| 3953 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3953 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3971 static const char* kFindString = "result"; | 3971 static const char* kFindString = "result"; |
| 3972 static const int kFindIdentifier = 12345; | 3972 static const int kFindIdentifier = 12345; |
| 3973 | 3973 |
| 3974 WebFindOptions options; | 3974 WebFindOptions options; |
| 3975 WebString searchText = WebString::fromUTF8(kFindString); | 3975 WebString searchText = WebString::fromUTF8(kFindString); |
| 3976 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 3976 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 3977 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); | 3977 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext (false)); |
| 3978 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); | 3978 RefPtrWillBeRawPtr<LocalFrame> holdSecondFrame(secondFrame->frame()); |
| 3979 | 3979 |
| 3980 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3980 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3981 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)) ; | 3981 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 3982 | 3982 |
| 3983 runPendingTasks(); | 3983 runPendingTasks(); |
| 3984 EXPECT_FALSE(client.findResultsAreReady()); | 3984 EXPECT_FALSE(client.findResultsAreReady()); |
| 3985 | 3985 |
| 3986 mainFrame->resetMatchCount(); | 3986 mainFrame->resetMatchCount(); |
| 3987 | 3987 |
| 3988 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3988 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3989 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3989 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3990 | 3990 |
| 3991 // The first scopeStringMatches will have reset the state. Detach before it actually scopes. | 3991 // The first scopeStringMatches will have reset the state. Detach before it actually scopes. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 4009 static const int kFindIdentifier = 12345; | 4009 static const int kFindIdentifier = 12345; |
| 4010 | 4010 |
| 4011 WebFindOptions options; | 4011 WebFindOptions options; |
| 4012 WebString searchText = WebString::fromUTF8(kFindString); | 4012 WebString searchText = WebString::fromUTF8(kFindString); |
| 4013 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 4013 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 4014 | 4014 |
| 4015 // Check that child frame exists. | 4015 // Check that child frame exists. |
| 4016 EXPECT_TRUE(!!mainFrame->traverseNext(false)); | 4016 EXPECT_TRUE(!!mainFrame->traverseNext(false)); |
| 4017 | 4017 |
| 4018 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) { | 4018 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) { |
| 4019 EXPECT_FALSE(frame->find(kFindIdentifier, searchText, options, false, 0) ); | 4019 EXPECT_FALSE(frame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 4020 } | 4020 } |
| 4021 | 4021 |
| 4022 runPendingTasks(); | 4022 runPendingTasks(); |
| 4023 EXPECT_FALSE(client.findResultsAreReady()); | 4023 EXPECT_FALSE(client.findResultsAreReady()); |
| 4024 | 4024 |
| 4025 mainFrame->resetMatchCount(); | 4025 mainFrame->resetMatchCount(); |
| 4026 } | 4026 } |
| 4027 | 4027 |
| 4028 TEST_P(ParameterizedWebFrameTest, SetTickmarks) | 4028 TEST_P(ParameterizedWebFrameTest, SetTickmarks) |
| 4029 { | 4029 { |
| 4030 registerMockedHttpURLLoad("find.html"); | 4030 registerMockedHttpURLLoad("find.html"); |
| 4031 | 4031 |
| 4032 FindUpdateWebFrameClient client; | 4032 FindUpdateWebFrameClient client; |
| 4033 FrameTestHelpers::WebViewHelper webViewHelper(this); | 4033 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 4034 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); | 4034 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); |
| 4035 webViewHelper.resize(WebSize(640, 480)); | 4035 webViewHelper.resize(WebSize(640, 480)); |
| 4036 runPendingTasks(); | 4036 runPendingTasks(); |
| 4037 | 4037 |
| 4038 static const char* kFindString = "foo"; | 4038 static const char* kFindString = "foo"; |
| 4039 static const int kFindIdentifier = 12345; | 4039 static const int kFindIdentifier = 12345; |
| 4040 | 4040 |
| 4041 WebFindOptions options; | 4041 WebFindOptions options; |
| 4042 WebString searchText = WebString::fromUTF8(kFindString); | 4042 WebString searchText = WebString::fromUTF8(kFindString); |
| 4043 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); | 4043 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()-> mainFrame()); |
| 4044 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)) ; | 4044 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0, nullptr)); |
| 4045 | 4045 |
| 4046 mainFrame->resetMatchCount(); | 4046 mainFrame->resetMatchCount(); |
| 4047 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 4047 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 4048 | 4048 |
| 4049 runPendingTasks(); | 4049 runPendingTasks(); |
| 4050 EXPECT_TRUE(client.findResultsAreReady()); | 4050 EXPECT_TRUE(client.findResultsAreReady()); |
| 4051 | 4051 |
| 4052 // Get the tickmarks for the original find request. | 4052 // Get the tickmarks for the original find request. |
| 4053 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); | 4053 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); |
| 4054 RefPtrWillBeRawPtr<Scrollbar> scrollbar = frameView->createScrollbar(Horizon talScrollbar); | 4054 RefPtrWillBeRawPtr<Scrollbar> scrollbar = frameView->createScrollbar(Horizon talScrollbar); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 4071 // Reset the tickmark behavior. | 4071 // Reset the tickmark behavior. |
| 4072 Vector<IntRect> resetTickmarks; | 4072 Vector<IntRect> resetTickmarks; |
| 4073 mainFrame->setTickmarks(resetTickmarks); | 4073 mainFrame->setTickmarks(resetTickmarks); |
| 4074 | 4074 |
| 4075 // Check that the original tickmarks are returned | 4075 // Check that the original tickmarks are returned |
| 4076 Vector<IntRect> originalTickmarksAfterReset; | 4076 Vector<IntRect> originalTickmarksAfterReset; |
| 4077 scrollbar->getTickmarks(originalTickmarksAfterReset); | 4077 scrollbar->getTickmarks(originalTickmarksAfterReset); |
| 4078 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); | 4078 EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset); |
| 4079 } | 4079 } |
| 4080 | 4080 |
| 4081 TEST_P(ParameterizedWebFrameTest, FindInPageJavaScriptUpdatesDOM) | |
| 4082 { | |
| 4083 registerMockedHttpURLLoad("find.html"); | |
| 4084 | |
| 4085 FindUpdateWebFrameClient client; | |
| 4086 FrameTestHelpers::WebViewHelper webViewHelper(this); | |
| 4087 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); | |
| 4088 webViewHelper.resize(WebSize(640, 480)); | |
| 4089 runPendingTasks(); | |
| 4090 | |
| 4091 WebFrame* frame = webViewHelper.webView()->mainFrame(); | |
| 4092 const int findIdentifier = 12345; | |
| 4093 static const char* kFindString = "foo"; | |
| 4094 WebString searchText = WebString::fromUTF8(kFindString); | |
| 4095 WebFindOptions options; | |
| 4096 bool activeNow; | |
| 4097 | |
| 4098 frame->resetMatchCount(); | |
| 4099 frame->scopeStringMatches(findIdentifier, searchText, options, true); | |
| 4100 runPendingTasks(); | |
| 4101 EXPECT_TRUE(client.findResultsAreReady()); | |
| 4102 | |
| 4103 // Find in a <div> element. | |
| 4104 options.findNext = true; | |
| 4105 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti veNow)); | |
| 4106 EXPECT_TRUE(activeNow); | |
| 4107 | |
| 4108 // Insert new text, which contains occurence of |searchText|. | |
| 4109 frame->executeScript( | |
| 4110 WebScriptSource("document.body.insertBefore(document.createTextNode('bar 5 foo5'), document.getElementsByTagName('textarea')[0]);")); | |
|
Finnur
2016/01/29 17:47:50
Nit: I would probably try to break this up into mo
dvadym
2016/02/01 12:41:10
Done.
| |
| 4111 | |
| 4112 // Find in a <input> element. | |
| 4113 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti veNow)); | |
| 4114 EXPECT_TRUE(activeNow); | |
| 4115 | |
| 4116 // Find in the inserted text node. | |
| 4117 EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &acti veNow)); | |
| 4118 frame->stopFinding(false); | |
| 4119 WebRange range = frame->selectionRange(); | |
| 4120 EXPECT_EQ(5, range.startOffset()); | |
| 4121 EXPECT_EQ(8, range.endOffset()); | |
| 4122 EXPECT_TRUE(frame->document().focusedElement().isNull()); | |
| 4123 EXPECT_FALSE(activeNow); | |
| 4124 } | |
| 4125 | |
| 4081 static WebPoint topLeft(const WebRect& rect) | 4126 static WebPoint topLeft(const WebRect& rect) |
| 4082 { | 4127 { |
| 4083 return WebPoint(rect.x, rect.y); | 4128 return WebPoint(rect.x, rect.y); |
| 4084 } | 4129 } |
| 4085 | 4130 |
| 4086 static WebPoint bottomRightMinusOne(const WebRect& rect) | 4131 static WebPoint bottomRightMinusOne(const WebRect& rect) |
| 4087 { | 4132 { |
| 4088 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the | 4133 // FIXME: If we don't subtract 1 from the x- and y-coordinates of the |
| 4089 // selection bounds, selectRange() will select the *next* element. That's | 4134 // selection bounds, selectRange() will select the *next* element. That's |
| 4090 // strictly correct, as hit-testing checks the pixel to the lower-right of | 4135 // strictly correct, as hit-testing checks the pixel to the lower-right of |
| (...skipping 4314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8405 } | 8450 } |
| 8406 | 8451 |
| 8407 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) | 8452 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
| 8408 { | 8453 { |
| 8409 swapLocalFrameToRemoteFrame(); | 8454 swapLocalFrameToRemoteFrame(); |
| 8410 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); | 8455 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); |
| 8411 EXPECT_FALSE(remoteFrameClient()->isVisible()); | 8456 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
| 8412 } | 8457 } |
| 8413 | 8458 |
| 8414 } // namespace blink | 8459 } // namespace blink |
| OLD | NEW |