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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 518693002: Fix a crash when saving a <canvas> or <img> image which is large. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CONTENT_EXPORT Created 6 years, 3 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: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index e3ed9fad6c0bc1f7512f02501f3f2ea6d6d962a9..55b6ff059e9ea1a1378f0b68fc5540829cd96355 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -292,6 +292,54 @@ class RenderViewImplTest : public RenderViewTest {
scoped_ptr<MockKeyboard> mock_keyboard_;
};
+TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
+ const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_FALSE(msg1);
+ render_thread_->sink().ClearMessages();
+
+ const std::string image_data_url =
+ "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
+
+ view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
+ ProcessPendingMessages();
+ const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_TRUE(msg2);
+
+ ViewHostMsg_SaveImageFromDataURL::Param param1;
+ ViewHostMsg_SaveImageFromDataURL::Read(msg2, &param1);
+ EXPECT_EQ(param1.b.length(), image_data_url.length());
+ EXPECT_EQ(param1.b, image_data_url);
+
+ ProcessPendingMessages();
+ render_thread_->sink().ClearMessages();
+
+ const std::string large_data_url(1024 * 1024 * 10 - 1, 'd');
+
+ view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url));
+ ProcessPendingMessages();
+ const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_TRUE(msg3);
+
+ ViewHostMsg_SaveImageFromDataURL::Param param2;
+ ViewHostMsg_SaveImageFromDataURL::Read(msg3, &param2);
+ EXPECT_EQ(param2.b.length(), large_data_url.length());
+ EXPECT_EQ(param2.b, large_data_url);
+
+ ProcessPendingMessages();
+ render_thread_->sink().ClearMessages();
+
+ const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd');
+
+ view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
+ ProcessPendingMessages();
+ const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_FALSE(msg4);
+}
+
// Test that we get form state change notifications when input fields change.
TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) {
// Don't want any delay for form state sync changes. This will still post a

Powered by Google App Engine
This is Rietveld 408576698