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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("smartclip_user_select_none.html")); 2181 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("smartclip_user_select_none.html"));
2182 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip_ user_select_none.html"); 2182 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip_ user_select_none.html");
2183 webView->resize(WebSize(500, 500)); 2183 webView->resize(WebSize(500, 500));
2184 webView->updateAllLifecyclePhases(); 2184 webView->updateAllLifecyclePhases();
2185 WebRect cropRect(0, 0, 100, 100); 2185 WebRect cropRect(0, 0, 100, 100);
2186 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); 2186 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
2187 EXPECT_STREQ("", clipText.utf8().c_str()); 2187 EXPECT_STREQ("", clipText.utf8().c_str());
2188 EXPECT_STREQ("", clipHtml.utf8().c_str()); 2188 EXPECT_STREQ("", clipHtml.utf8().c_str());
2189 } 2189 }
2190 2190
2191 TEST_F(WebViewTest, SmartClipDoesNotCrashPositionReversed)
2192 {
2193 WebString clipText;
2194 WebString clipHtml;
2195 WebRect clipRect;
2196 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("Ahem.ttf"));
2197 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("smartclip_reversed_positions.html"));
2198 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip_ reversed_positions.html");
2199 webView->resize(WebSize(500, 500));
2200 webView->updateAllLifecyclePhases();
2201 // Left upper corner of the rect will be end position in the DOM hierarchy.
2202 WebRect cropRect(30, 110, 400, 250);
2203 // This should not still crash. See crbug.com/589082 for more details.
2204 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect);
2205 }
2206
2191 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien t { 2207 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien t {
2192 public: 2208 public:
2193 CreateChildCounterFrameClient() : m_count(0) { } 2209 CreateChildCounterFrameClient() : m_count(0) { }
2194 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We bString& name, const WebString& uniqueName, WebSandboxFlags, const WebFrameOwner Properties&) override; 2210 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We bString& name, const WebString& uniqueName, WebSandboxFlags, const WebFrameOwner Properties&) override;
2195 2211
2196 int count() const { return m_count; } 2212 int count() const { return m_count; }
2197 2213
2198 private: 2214 private:
2199 int m_count; 2215 int m_count;
2200 }; 2216 };
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
3226 frame->setAutofillClient(&client); 3242 frame->setAutofillClient(&client);
3227 webView->setInitialFocus(false); 3243 webView->setInitialFocus(false);
3228 3244
3229 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3245 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3230 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3246 EXPECT_EQ(1, client.textChangesFromUserGesture());
3231 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3247 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3232 frame->setAutofillClient(0); 3248 frame->setAutofillClient(0);
3233 } 3249 }
3234 3250
3235 } // namespace blink 3251 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698