| 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 4629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4640 const int kNumResults = 17; | 4640 const int kNumResults = 17; |
| 4641 | 4641 |
| 4642 WebFindOptions options; | 4642 WebFindOptions options; |
| 4643 WebString searchText = WebString::fromUTF8(kFindString); | 4643 WebString searchText = WebString::fromUTF8(kFindString); |
| 4644 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 4644 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
| 4645 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); | 4645 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); |
| 4646 | 4646 |
| 4647 mainFrame->ensureTextFinder().resetMatchCount(); | 4647 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4648 | 4648 |
| 4649 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4649 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4650 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4650 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4651 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4651 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4652 options, true); | 4652 searchText, options); |
| 4653 } |
| 4653 | 4654 |
| 4654 runPendingTasks(); | 4655 runPendingTasks(); |
| 4655 EXPECT_TRUE(client.findResultsAreReady()); | 4656 EXPECT_TRUE(client.findResultsAreReady()); |
| 4656 | 4657 |
| 4657 WebVector<WebFloatRect> webMatchRects; | 4658 WebVector<WebFloatRect> webMatchRects; |
| 4658 mainFrame->findMatchRects(webMatchRects); | 4659 mainFrame->findMatchRects(webMatchRects); |
| 4659 ASSERT_EQ(static_cast<size_t>(kNumResults), webMatchRects.size()); | 4660 ASSERT_EQ(static_cast<size_t>(kNumResults), webMatchRects.size()); |
| 4660 int rectsVersion = mainFrame->findMatchMarkersVersion(); | 4661 int rectsVersion = mainFrame->findMatchMarkersVersion(); |
| 4661 | 4662 |
| 4662 for (int resultIndex = 0; resultIndex < kNumResults; ++resultIndex) { | 4663 for (int resultIndex = 0; resultIndex < kNumResults; ++resultIndex) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4703 const int kFindIdentifier = 7777; | 4704 const int kFindIdentifier = 7777; |
| 4704 const int kActiveIndex = 1; | 4705 const int kActiveIndex = 1; |
| 4705 | 4706 |
| 4706 WebFindOptions options; | 4707 WebFindOptions options; |
| 4707 WebString searchText = WebString::fromUTF8(kFindString); | 4708 WebString searchText = WebString::fromUTF8(kFindString); |
| 4708 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 4709 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
| 4709 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); | 4710 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); |
| 4710 mainFrame->ensureTextFinder().resetMatchCount(); | 4711 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4711 | 4712 |
| 4712 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4713 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4713 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4714 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4714 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4715 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4715 options, true); | 4716 searchText, options); |
| 4717 } |
| 4716 | 4718 |
| 4717 runPendingTasks(); | 4719 runPendingTasks(); |
| 4718 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); | 4720 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); |
| 4719 mainFrame->stopFinding(WebLocalFrame::StopFindActionClearSelection); | 4721 mainFrame->stopFinding(WebLocalFrame::StopFindActionClearSelection); |
| 4720 | 4722 |
| 4721 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4723 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4722 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4724 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4723 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4725 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4724 options, true); | 4726 searchText, options); |
| 4727 } |
| 4725 | 4728 |
| 4726 runPendingTasks(); | 4729 runPendingTasks(); |
| 4727 EXPECT_TRUE(client.findResultsAreReady()); | 4730 EXPECT_TRUE(client.findResultsAreReady()); |
| 4728 EXPECT_EQ(kActiveIndex, client.activeIndex()); | 4731 EXPECT_EQ(kActiveIndex, client.activeIndex()); |
| 4729 | 4732 |
| 4730 const char* kFindStringNew = "e"; | 4733 const char* kFindStringNew = "e"; |
| 4731 WebString searchTextNew = WebString::fromUTF8(kFindStringNew); | 4734 WebString searchTextNew = WebString::fromUTF8(kFindStringNew); |
| 4732 | 4735 |
| 4733 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchTextNew, options, false)); | 4736 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchTextNew, options, false)); |
| 4734 mainFrame->ensureTextFinder().resetMatchCount(); | 4737 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4735 | 4738 |
| 4736 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4739 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4737 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4740 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4738 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchTextNew, | 4741 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4739 options, true); | 4742 searchTextNew, options); |
| 4743 } |
| 4740 | 4744 |
| 4741 runPendingTasks(); | 4745 runPendingTasks(); |
| 4742 EXPECT_TRUE(client.findResultsAreReady()); | 4746 EXPECT_TRUE(client.findResultsAreReady()); |
| 4743 EXPECT_EQ(kActiveIndex, client.activeIndex()); | 4747 EXPECT_EQ(kActiveIndex, client.activeIndex()); |
| 4744 } | 4748 } |
| 4745 | 4749 |
| 4746 TEST_P(ParameterizedWebFrameTest, FindOnDetachedFrame) { | 4750 TEST_P(ParameterizedWebFrameTest, FindOnDetachedFrame) { |
| 4747 registerMockedHttpURLLoad("find_in_page.html"); | 4751 registerMockedHttpURLLoad("find_in_page.html"); |
| 4748 registerMockedHttpURLLoad("find_in_page_frame.html"); | 4752 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 4749 | 4753 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4768 | 4772 |
| 4769 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); | 4773 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); |
| 4770 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false)); | 4774 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false)); |
| 4771 | 4775 |
| 4772 runPendingTasks(); | 4776 runPendingTasks(); |
| 4773 EXPECT_FALSE(client.findResultsAreReady()); | 4777 EXPECT_FALSE(client.findResultsAreReady()); |
| 4774 | 4778 |
| 4775 mainFrame->ensureTextFinder().resetMatchCount(); | 4779 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4776 | 4780 |
| 4777 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4781 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4778 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4782 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4779 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4783 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4780 options, true); | 4784 searchText, options); |
| 4785 } |
| 4781 | 4786 |
| 4782 runPendingTasks(); | 4787 runPendingTasks(); |
| 4783 EXPECT_TRUE(client.findResultsAreReady()); | 4788 EXPECT_TRUE(client.findResultsAreReady()); |
| 4784 } | 4789 } |
| 4785 | 4790 |
| 4786 TEST_P(ParameterizedWebFrameTest, FindDetachFrameBeforeScopeStrings) { | 4791 TEST_P(ParameterizedWebFrameTest, FindDetachFrameBeforeScopeStrings) { |
| 4787 registerMockedHttpURLLoad("find_in_page.html"); | 4792 registerMockedHttpURLLoad("find_in_page.html"); |
| 4788 registerMockedHttpURLLoad("find_in_page_frame.html"); | 4793 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 4789 | 4794 |
| 4790 FindUpdateWebFrameClient client; | 4795 FindUpdateWebFrameClient client; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4807 | 4812 |
| 4808 runPendingTasks(); | 4813 runPendingTasks(); |
| 4809 EXPECT_FALSE(client.findResultsAreReady()); | 4814 EXPECT_FALSE(client.findResultsAreReady()); |
| 4810 | 4815 |
| 4811 // Detach the frame between finding and scoping. | 4816 // Detach the frame between finding and scoping. |
| 4812 removeElementById(mainFrame, "frame"); | 4817 removeElementById(mainFrame, "frame"); |
| 4813 | 4818 |
| 4814 mainFrame->ensureTextFinder().resetMatchCount(); | 4819 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4815 | 4820 |
| 4816 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4821 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4817 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4822 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4818 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4823 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4819 options, true); | 4824 searchText, options); |
| 4825 } |
| 4820 | 4826 |
| 4821 runPendingTasks(); | 4827 runPendingTasks(); |
| 4822 EXPECT_TRUE(client.findResultsAreReady()); | 4828 EXPECT_TRUE(client.findResultsAreReady()); |
| 4823 } | 4829 } |
| 4824 | 4830 |
| 4825 TEST_P(ParameterizedWebFrameTest, FindDetachFrameWhileScopingStrings) { | 4831 TEST_P(ParameterizedWebFrameTest, FindDetachFrameWhileScopingStrings) { |
| 4826 registerMockedHttpURLLoad("find_in_page.html"); | 4832 registerMockedHttpURLLoad("find_in_page.html"); |
| 4827 registerMockedHttpURLLoad("find_in_page_frame.html"); | 4833 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 4828 | 4834 |
| 4829 FindUpdateWebFrameClient client; | 4835 FindUpdateWebFrameClient client; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4843 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext()) | 4849 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext()) |
| 4844 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, | 4850 EXPECT_TRUE(frame->toWebLocalFrame()->find(kFindIdentifier, searchText, |
| 4845 options, false)); | 4851 options, false)); |
| 4846 | 4852 |
| 4847 runPendingTasks(); | 4853 runPendingTasks(); |
| 4848 EXPECT_FALSE(client.findResultsAreReady()); | 4854 EXPECT_FALSE(client.findResultsAreReady()); |
| 4849 | 4855 |
| 4850 mainFrame->ensureTextFinder().resetMatchCount(); | 4856 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4851 | 4857 |
| 4852 for (WebLocalFrameImpl* frame = mainFrame; frame; | 4858 for (WebLocalFrameImpl* frame = mainFrame; frame; |
| 4853 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) | 4859 frame = static_cast<WebLocalFrameImpl*>(frame->traverseNext())) { |
| 4854 frame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4860 frame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4855 options, true); | 4861 searchText, options); |
| 4862 } |
| 4856 | 4863 |
| 4857 // The first scopeStringMatches will have reset the state. Detach before it | 4864 // The first startScopingStringMatches will have reset the state. Detach |
| 4858 // actually scopes. | 4865 // before it actually scopes. |
| 4859 removeElementById(mainFrame, "frame"); | 4866 removeElementById(mainFrame, "frame"); |
| 4860 | 4867 |
| 4861 runPendingTasks(); | 4868 runPendingTasks(); |
| 4862 EXPECT_TRUE(client.findResultsAreReady()); | 4869 EXPECT_TRUE(client.findResultsAreReady()); |
| 4863 } | 4870 } |
| 4864 | 4871 |
| 4865 TEST_P(ParameterizedWebFrameTest, ResetMatchCount) { | 4872 TEST_P(ParameterizedWebFrameTest, ResetMatchCount) { |
| 4866 registerMockedHttpURLLoad("find_in_generated_frame.html"); | 4873 registerMockedHttpURLLoad("find_in_generated_frame.html"); |
| 4867 | 4874 |
| 4868 FindUpdateWebFrameClient client; | 4875 FindUpdateWebFrameClient client; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4903 | 4910 |
| 4904 const char kFindString[] = "foo"; | 4911 const char kFindString[] = "foo"; |
| 4905 const int kFindIdentifier = 12345; | 4912 const int kFindIdentifier = 12345; |
| 4906 | 4913 |
| 4907 WebFindOptions options; | 4914 WebFindOptions options; |
| 4908 WebString searchText = WebString::fromUTF8(kFindString); | 4915 WebString searchText = WebString::fromUTF8(kFindString); |
| 4909 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); | 4916 WebLocalFrameImpl* mainFrame = webViewHelper.webView()->mainFrameImpl(); |
| 4910 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); | 4917 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false)); |
| 4911 | 4918 |
| 4912 mainFrame->ensureTextFinder().resetMatchCount(); | 4919 mainFrame->ensureTextFinder().resetMatchCount(); |
| 4913 mainFrame->ensureTextFinder().scopeStringMatches(kFindIdentifier, searchText, | 4920 mainFrame->ensureTextFinder().startScopingStringMatches(kFindIdentifier, |
| 4914 options, true); | 4921 searchText, options); |
| 4915 | 4922 |
| 4916 runPendingTasks(); | 4923 runPendingTasks(); |
| 4917 EXPECT_TRUE(client.findResultsAreReady()); | 4924 EXPECT_TRUE(client.findResultsAreReady()); |
| 4918 | 4925 |
| 4919 // Get the tickmarks for the original find request. | 4926 // Get the tickmarks for the original find request. |
| 4920 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); | 4927 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); |
| 4921 Scrollbar* scrollbar = frameView->createScrollbar(HorizontalScrollbar); | 4928 Scrollbar* scrollbar = frameView->createScrollbar(HorizontalScrollbar); |
| 4922 Vector<IntRect> originalTickmarks; | 4929 Vector<IntRect> originalTickmarks; |
| 4923 scrollbar->getTickmarks(originalTickmarks); | 4930 scrollbar->getTickmarks(originalTickmarks); |
| 4924 EXPECT_EQ(4u, originalTickmarks.size()); | 4931 EXPECT_EQ(4u, originalTickmarks.size()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4955 runPendingTasks(); | 4962 runPendingTasks(); |
| 4956 | 4963 |
| 4957 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 4964 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 4958 const int findIdentifier = 12345; | 4965 const int findIdentifier = 12345; |
| 4959 static const char* kFindString = "foo"; | 4966 static const char* kFindString = "foo"; |
| 4960 WebString searchText = WebString::fromUTF8(kFindString); | 4967 WebString searchText = WebString::fromUTF8(kFindString); |
| 4961 WebFindOptions options; | 4968 WebFindOptions options; |
| 4962 bool activeNow; | 4969 bool activeNow; |
| 4963 | 4970 |
| 4964 frame->ensureTextFinder().resetMatchCount(); | 4971 frame->ensureTextFinder().resetMatchCount(); |
| 4965 frame->ensureTextFinder().scopeStringMatches(findIdentifier, searchText, | 4972 frame->ensureTextFinder().startScopingStringMatches(findIdentifier, |
| 4966 options, true); | 4973 searchText, options); |
| 4967 runPendingTasks(); | 4974 runPendingTasks(); |
| 4968 EXPECT_TRUE(client.findResultsAreReady()); | 4975 EXPECT_TRUE(client.findResultsAreReady()); |
| 4969 | 4976 |
| 4970 // Find in a <div> element. | 4977 // Find in a <div> element. |
| 4971 options.findNext = true; | 4978 options.findNext = true; |
| 4972 EXPECT_TRUE( | 4979 EXPECT_TRUE( |
| 4973 frame->find(findIdentifier, searchText, options, false, &activeNow)); | 4980 frame->find(findIdentifier, searchText, options, false, &activeNow)); |
| 4974 EXPECT_TRUE(activeNow); | 4981 EXPECT_TRUE(activeNow); |
| 4975 | 4982 |
| 4976 // Insert new text, which contains occurence of |searchText|. | 4983 // Insert new text, which contains occurence of |searchText|. |
| (...skipping 5966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10943 | 10950 |
| 10944 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 10951 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 10945 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 10952 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 10946 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 10953 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 10947 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 10954 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 10948 | 10955 |
| 10949 webViewHelper.reset(); | 10956 webViewHelper.reset(); |
| 10950 } | 10957 } |
| 10951 | 10958 |
| 10952 } // namespace blink | 10959 } // namespace blink |
| OLD | NEW |