Title: [132746] trunk/Source/WebKit/chromium
- Revision
- 132746
- Author
- [email protected]
- Date
- 2012-10-27 23:27:51 -0700 (Sat, 27 Oct 2012)
Log Message
[Chromium] Find-in-page reports matches in hidden iframes
https://bugs.webkit.org/show_bug.cgi?id=100604
Reviewed by Eric Seidel.
This is actually a regression caused by
http://trac.webkit.org/changeset/128784. This patch adds back some code
removed in WebFrameImpl::shouldScopeMatches in r128784.
This patch also introduces a test so that we don't make this mistake
again.
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::shouldScopeMatches):
* tests/WebFrameTest.cpp:
* tests/data/find_in_hidden_frame.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (132745 => 132746)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-10-28 06:13:23 UTC (rev 132745)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-10-28 06:27:51 UTC (rev 132746)
@@ -1,3 +1,22 @@
+2012-10-27 Adam Barth <[email protected]>
+
+ [Chromium] Find-in-page reports matches in hidden iframes
+ https://bugs.webkit.org/show_bug.cgi?id=100604
+
+ Reviewed by Eric Seidel.
+
+ This is actually a regression caused by
+ http://trac.webkit.org/changeset/128784. This patch adds back some code
+ removed in WebFrameImpl::shouldScopeMatches in r128784.
+
+ This patch also introduces a test so that we don't make this mistake
+ again.
+
+ * src/WebFrameImpl.cpp:
+ (WebKit::WebFrameImpl::shouldScopeMatches):
+ * tests/WebFrameTest.cpp:
+ * tests/data/find_in_hidden_frame.html: Added.
+
2012-10-26 Kent Tamura <[email protected]>
[Chromium] Convert Chromium template string to an LDML date format
Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (132745 => 132746)
--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-10-28 06:13:23 UTC (rev 132745)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-10-28 06:27:51 UTC (rev 132746)
@@ -2453,7 +2453,7 @@
// Don't scope if we can't find a frame or a view.
// The user may have closed the tab/application, so abort.
// Also ignore detached frames, as many find operations report to the main frame.
- if (!frame() || !frame()->view() || !frame()->page())
+ if (!frame() || !frame()->view() || !frame()->page() || !hasVisibleContent())
return false;
ASSERT(frame()->document() && frame()->view());
Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (132745 => 132746)
--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-10-28 06:13:23 UTC (rev 132745)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-10-28 06:27:51 UTC (rev 132746)
@@ -1045,19 +1045,23 @@
public:
FindUpdateWebFrameClient()
: m_findResultsAreReady(false)
+ , m_count(-1)
{
}
- virtual void reportFindInPageMatchCount(int, int, bool finalUpdate) OVERRIDE
+ virtual void reportFindInPageMatchCount(int, int count, bool finalUpdate) OVERRIDE
{
+ m_count = count;
if (finalUpdate)
m_findResultsAreReady = true;
}
bool findResultsAreReady() const { return m_findResultsAreReady; }
+ int count() const { return m_count; }
private:
bool m_findResultsAreReady;
+ int m_count;
};
TEST_F(WebFrameTest, FindInPageMatchRects)
@@ -1172,6 +1176,37 @@
webView->close();
}
+TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames)
+{
+ registerMockedHttpURLLoad("find_in_hidden_frame.html");
+
+ FindUpdateWebFrameClient client;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_hidden_frame.html", true, &client);
+ webView->resize(WebSize(640, 480));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ static const char* kFindString = "hello";
+ static const int kFindIdentifier = 12345;
+ static const int kNumResults = 1;
+
+ WebFindOptions options;
+ WebString searchText = WebString::fromUTF8(kFindString);
+ WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame());
+ EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0));
+
+ mainFrame->resetMatchCount();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_TRUE(client.findResultsAreReady());
+ EXPECT_EQ(kNumResults, client.count());
+
+ webView->close();
+}
+
TEST_F(WebFrameTest, FindOnDetachedFrame)
{
registerMockedHttpURLLoad("find_in_page.html");
Added: trunk/Source/WebKit/chromium/tests/data/find_in_hidden_frame.html (0 => 132746)
--- trunk/Source/WebKit/chromium/tests/data/find_in_hidden_frame.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/find_in_hidden_frame.html 2012-10-28 06:27:51 UTC (rev 132746)
@@ -0,0 +1 @@
+<div>hello</div><iframe style="display:inline;width:0;height:0;border:none" src=""
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes