| 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options
, false, 0)); | 975 EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options
, false, 0)); |
| 976 // Confirm stopFinding(false) sets the selection on the found text. | 976 // Confirm stopFinding(false) sets the selection on the found text. |
| 977 frame->stopFinding(false); | 977 frame->stopFinding(false); |
| 978 range = frame->selectionRange(); | 978 range = frame->selectionRange(); |
| 979 ASSERT_FALSE(range.isNull()); | 979 ASSERT_FALSE(range.isNull()); |
| 980 EXPECT_EQ(0, range.startOffset()); | 980 EXPECT_EQ(0, range.startOffset()); |
| 981 EXPECT_EQ(4, range.endOffset()); | 981 EXPECT_EQ(4, range.endOffset()); |
| 982 // "bar4" is surrounded by <span>, but the focusable node should be the pare
nt <div>. | 982 // "bar4" is surrounded by <span>, but the focusable node should be the pare
nt <div>. |
| 983 EXPECT_EQ(WebString::fromUTF8("DIV"), frame->document().focusedNode().nodeNa
me()); | 983 EXPECT_EQ(WebString::fromUTF8("DIV"), frame->document().focusedNode().nodeNa
me()); |
| 984 | 984 |
| 985 // Find in <select> content. |
| 986 EXPECT_FALSE(frame->find(findIdentifier, WebString::fromUTF8("bar5"), option
s, false, 0)); |
| 987 // If there are any matches, stopFinding will set the selection on the found
text. |
| 988 // However, we do not expect any matches, so check that the selection is nul
l. |
| 989 frame->stopFinding(false); |
| 990 range = frame->selectionRange(); |
| 991 ASSERT_TRUE(range.isNull()); |
| 992 |
| 985 webView->close(); | 993 webView->close(); |
| 986 } | 994 } |
| 987 | 995 |
| 988 TEST_F(WebFrameTest, GetContentAsPlainText) | 996 TEST_F(WebFrameTest, GetContentAsPlainText) |
| 989 { | 997 { |
| 990 WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", tru
e); | 998 WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", tru
e); |
| 991 // We set the size because it impacts line wrapping, which changes the | 999 // We set the size because it impacts line wrapping, which changes the |
| 992 // resulting text value. | 1000 // resulting text value. |
| 993 webView->resize(WebSize(640, 480)); | 1001 webView->resize(WebSize(640, 480)); |
| 994 WebFrame* frame = webView->mainFrame(); | 1002 WebFrame* frame = webView->mainFrame(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 { | 1151 { |
| 1144 registerMockedHttpURLLoad("find_in_page.html"); | 1152 registerMockedHttpURLLoad("find_in_page.html"); |
| 1145 registerMockedHttpURLLoad("find_in_page_frame.html"); | 1153 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 1146 | 1154 |
| 1147 FindUpdateWebFrameClient client; | 1155 FindUpdateWebFrameClient client; |
| 1148 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_
in_page.html", true, &client); | 1156 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_
in_page.html", true, &client); |
| 1149 webView->resize(WebSize(640, 480)); | 1157 webView->resize(WebSize(640, 480)); |
| 1150 webView->layout(); | 1158 webView->layout(); |
| 1151 webkit_support::RunAllPendingMessages(); | 1159 webkit_support::RunAllPendingMessages(); |
| 1152 | 1160 |
| 1161 // Note that the 'result 19' in the <select> element is not expected to prod
uce a match. |
| 1153 static const char* kFindString = "result"; | 1162 static const char* kFindString = "result"; |
| 1154 static const int kFindIdentifier = 12345; | 1163 static const int kFindIdentifier = 12345; |
| 1155 static const int kNumResults = 16; | 1164 static const int kNumResults = 19; |
| 1156 | 1165 |
| 1157 WebFindOptions options; | 1166 WebFindOptions options; |
| 1158 WebString searchText = WebString::fromUTF8(kFindString); | 1167 WebString searchText = WebString::fromUTF8(kFindString); |
| 1159 WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame()); | 1168 WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame()); |
| 1160 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 1169 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 1161 | 1170 |
| 1162 mainFrame->resetMatchCount(); | 1171 mainFrame->resetMatchCount(); |
| 1163 | 1172 |
| 1164 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 1173 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 1165 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 1174 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 // Result 12 should be left to results 11, 13 and 14 in the table layout. | 1245 // Result 12 should be left to results 11, 13 and 14 in the table layout. |
| 1237 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[11].x); | 1246 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[11].x); |
| 1238 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[13].x); | 1247 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[13].x); |
| 1239 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[14].x); | 1248 EXPECT_TRUE(webMatchRects[12].x < webMatchRects[14].x); |
| 1240 | 1249 |
| 1241 // Results 13, 12 and 14 should be one above the other in that order because
of the rowspan | 1250 // Results 13, 12 and 14 should be one above the other in that order because
of the rowspan |
| 1242 // and vertical-align: middle by default. | 1251 // and vertical-align: middle by default. |
| 1243 EXPECT_TRUE(webMatchRects[13].y < webMatchRects[12].y); | 1252 EXPECT_TRUE(webMatchRects[13].y < webMatchRects[12].y); |
| 1244 EXPECT_TRUE(webMatchRects[12].y < webMatchRects[14].y); | 1253 EXPECT_TRUE(webMatchRects[12].y < webMatchRects[14].y); |
| 1245 | 1254 |
| 1255 // Result 16 should be below result 15. |
| 1256 EXPECT_TRUE(webMatchRects[15].y > webMatchRects[14].y); |
| 1257 |
| 1258 // Result 18 should be normalized with respect to the position:relative div,
and not it's |
| 1259 // immediate containing div. Consequently, result 18 should be above result
17. |
| 1260 EXPECT_TRUE(webMatchRects[17].y > webMatchRects[18].y); |
| 1261 |
| 1246 // Resizing should update the rects version. | 1262 // Resizing should update the rects version. |
| 1247 webView->resize(WebSize(800, 600)); | 1263 webView->resize(WebSize(800, 600)); |
| 1248 webkit_support::RunAllPendingMessages(); | 1264 webkit_support::RunAllPendingMessages(); |
| 1249 EXPECT_TRUE(mainFrame->findMatchMarkersVersion() != rectsVersion); | 1265 EXPECT_TRUE(mainFrame->findMatchMarkersVersion() != rectsVersion); |
| 1250 | 1266 |
| 1251 webView->close(); | 1267 webView->close(); |
| 1252 } | 1268 } |
| 1253 | 1269 |
| 1254 TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) | 1270 TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) |
| 1255 { | 1271 { |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 webkit_support::RegisterMockedErrorURL(URLTestHelpers::toKURL(errorURL), res
ponse, error); | 1750 webkit_support::RegisterMockedErrorURL(URLTestHelpers::toKURL(errorURL), res
ponse, error); |
| 1735 frame->loadHistoryItem(errorHistoryItem); | 1751 frame->loadHistoryItem(errorHistoryItem); |
| 1736 webkit_support::ServeAsynchronousMockedRequests(); | 1752 webkit_support::ServeAsynchronousMockedRequests(); |
| 1737 | 1753 |
| 1738 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 1754 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
| 1739 EXPECT_EQ("This should appear", std::string(text.utf8().data())); | 1755 EXPECT_EQ("This should appear", std::string(text.utf8().data())); |
| 1740 EXPECT_TRUE(webFrameClient.commitCalled()); | 1756 EXPECT_TRUE(webFrameClient.commitCalled()); |
| 1741 } | 1757 } |
| 1742 | 1758 |
| 1743 } // namespace | 1759 } // namespace |
| OLD | NEW |