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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 #else 285 #else
286 NOTIMPLEMENTED(); 286 NOTIMPLEMENTED();
287 return L'\0'; 287 return L'\0';
288 #endif 288 #endif
289 } 289 }
290 290
291 private: 291 private:
292 scoped_ptr<MockKeyboard> mock_keyboard_; 292 scoped_ptr<MockKeyboard> mock_keyboard_;
293 }; 293 };
294 294
295 TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
Ken Russell (switch to Gerrit) 2014/09/04 00:23:26 Nice work on the test.
zino 2014/09/05 03:47:47 Thanks :)
296 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
297 ViewHostMsg_SaveImageFromDataURL::ID);
298 EXPECT_FALSE(msg1);
299 render_thread_->sink().ClearMessages();
300
301 const std::string image_data_url =
302 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
303
304 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
305 ProcessPendingMessages();
306 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
307 ViewHostMsg_SaveImageFromDataURL::ID);
308 EXPECT_TRUE(msg2);
309
310 ViewHostMsg_SaveImageFromDataURL::Param param1;
311 ViewHostMsg_SaveImageFromDataURL::Read(msg2, &param1);
312 EXPECT_EQ(param1.b.length(), image_data_url.length());
313 EXPECT_EQ(param1.b, image_data_url);
314
315 ProcessPendingMessages();
316 render_thread_->sink().ClearMessages();
317
318 const std::string large_data_url(1024 * 1024 * 10 - 1, 'd');
319
320 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url));
321 ProcessPendingMessages();
322 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
323 ViewHostMsg_SaveImageFromDataURL::ID);
324 EXPECT_TRUE(msg3);
325
326 ViewHostMsg_SaveImageFromDataURL::Param param2;
327 ViewHostMsg_SaveImageFromDataURL::Read(msg3, &param2);
328 EXPECT_EQ(param2.b.length(), large_data_url.length());
329 EXPECT_EQ(param2.b, large_data_url);
330
331 ProcessPendingMessages();
332 render_thread_->sink().ClearMessages();
333
334 const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd');
335
336 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
337 ProcessPendingMessages();
338 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
339 ViewHostMsg_SaveImageFromDataURL::ID);
340 EXPECT_FALSE(msg4);
341 }
342
295 // Test that we get form state change notifications when input fields change. 343 // Test that we get form state change notifications when input fields change.
296 TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) { 344 TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) {
297 // Don't want any delay for form state sync changes. This will still post a 345 // Don't want any delay for form state sync changes. This will still post a
298 // message so updates will get coalesced, but as soon as we spin the message 346 // message so updates will get coalesced, but as soon as we spin the message
299 // loop, it will generate an update. 347 // loop, it will generate an update.
300 view()->set_send_content_state_immediately(true); 348 view()->set_send_content_state_immediately(true);
301 349
302 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); 350 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>");
303 351
304 // We should NOT have gotten a form state change notification yet. 352 // We should NOT have gotten a form state change notification yet.
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 ProcessPendingMessages(); 2482 ProcessPendingMessages();
2435 base::Time after_navigation = 2483 base::Time after_navigation =
2436 base::Time::Now() + base::TimeDelta::FromDays(1); 2484 base::Time::Now() + base::TimeDelta::FromDays(1);
2437 2485
2438 base::Time late_nav_reported_start = 2486 base::Time late_nav_reported_start =
2439 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2487 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2440 EXPECT_LE(late_nav_reported_start, after_navigation); 2488 EXPECT_LE(late_nav_reported_start, after_navigation);
2441 } 2489 }
2442 2490
2443 } // namespace content 2491 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698