Chromium Code Reviews| 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) |