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

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

Issue 1806813004: Fix smartclip crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 90474baf9def0641c77ed5b26a4a56d425f05eb5..d3ca751b1da9b8338981e41f2383f445dd77fc4e 100644
--- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
@@ -2188,6 +2188,22 @@ TEST_F(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone)
EXPECT_STREQ("", clipHtml.utf8().c_str());
}
+TEST_F(WebViewTest, SmartClipDoesNotCrashPositionReversed)
+{
+ WebString clipText;
+ WebString clipHtml;
+ WebRect clipRect;
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("Ahem.ttf"));
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("smartclip_reversed_positions.html"));
+ WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip_reversed_positions.html");
+ webView->resize(WebSize(500, 500));
+ webView->updateAllLifecyclePhases();
+ // Left upper corner of the rect will be end position in the DOM hierarchy.
+ WebRect cropRect(30, 110, 400, 250);
+ // This should not still crash. See crbug.com/589082 for more details.
+ webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
+}
+
class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClient {
public:
CreateChildCounterFrameClient() : m_count(0) { }

Powered by Google App Engine
This is Rietveld 408576698