Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2275323003: Fix position of dictionary pop-up for <iframe>. (Closed)
Patch Set: Added a WebViewTest Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/mac/WebSubstringUtil.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
index c542443721ecc9ea3c9f7e82fa981a181ebd2ffb..74a7b37080f8852d11a5e2bfc782cfd7fecec92c 100644
--- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
@@ -3198,6 +3198,39 @@ TEST_F(WebViewTest, WebSubstringUtil)
result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoint);
ASSERT_TRUE(!!result);
}
+
+TEST_F(WebViewTest, WebSubstringUtilIframe)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("single_iframe.html"));
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("visible_iframe.html"));
bokan 2016/08/26 19:10:31 I don't think you have to register iframe loads bu
EhsanK 2016/08/26 20:14:48 Unfortunately, I can't remove it since this CHECK
bokan 2016/08/26 20:23:19 Ok, it's fine as-is, thanks for trying.
+ WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html");
+ webView->settings()->setDefaultFontSize(12);
+ webView->settings()->setJavaScriptEnabled(true);
+ webView->resize(WebSize(400, 400));
+ WebLocalFrameImpl* mainFrame = webView->mainFrameImpl();
+ WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(mainFrame->frame()->tree().firstChild()));
+
+ WebPoint baselinePoint;
+ NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(childFrame, 11, 7, &baselinePoint);
+ ASSERT_TRUE(!!result);
bokan 2016/08/26 19:10:31 Nit: no double-bang needed. Even better: ASSERT_NE
EhsanK 2016/08/26 20:14:48 Thanks! Done.
+
+ WebPoint point(baselinePoint.x, mainFrame->frameView()->height() - baselinePoint.y);
+ result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoint);
+ ASSERT_TRUE(!!result);
+
+ int yBeforeChange = baselinePoint.y;
+
+ // Now move the <iframe> down by 100px.
+ mainFrame->executeScript(WebScriptSource(
+ "document.querySelector('iframe').style.marginTop = '100px';"));
+
+ point = WebPoint(point.x, point.y + 100);
+ result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoint);
+ ASSERT_TRUE(!!result);
+
+ EXPECT_EQ(yBeforeChange, baselinePoint.y + 100);
+}
+
#endif
TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture)
« no previous file with comments | « third_party/WebKit/Source/web/mac/WebSubstringUtil.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698