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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1836973003: Move download messages from Renderer to Frame filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments, merge Created 4 years, 6 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
« no previous file with comments | « content/renderer/render_frame_impl_browsertest.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <tuple> 7 #include <tuple>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); 515 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
516 516
517 // Close the view, causing the main RenderFrame to be detached and deleted. 517 // Close the view, causing the main RenderFrame to be detached and deleted.
518 new_view->Close(); 518 new_view->Close();
519 EXPECT_FALSE(new_view->GetMainRenderFrame()); 519 EXPECT_FALSE(new_view->GetMainRenderFrame());
520 520
521 // Clean up after the new view so we don't leak it. 521 // Clean up after the new view so we don't leak it.
522 new_view->Release(); 522 new_view->Release();
523 } 523 }
524 524
525 TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
526 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
527 ViewHostMsg_SaveImageFromDataURL::ID);
528 EXPECT_FALSE(msg1);
529 render_thread_->sink().ClearMessages();
530
531 const std::string image_data_url =
532 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
533
534 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
535 ProcessPendingMessages();
536 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
537 ViewHostMsg_SaveImageFromDataURL::ID);
538 EXPECT_TRUE(msg2);
539
540 ViewHostMsg_SaveImageFromDataURL::Param param1;
541 ViewHostMsg_SaveImageFromDataURL::Read(msg2, &param1);
542 EXPECT_EQ(std::get<2>(param1).length(), image_data_url.length());
543 EXPECT_EQ(std::get<2>(param1), image_data_url);
544
545 ProcessPendingMessages();
546 render_thread_->sink().ClearMessages();
547
548 const std::string large_data_url(1024 * 1024 * 20 - 1, 'd');
549
550 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url));
551 ProcessPendingMessages();
552 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
553 ViewHostMsg_SaveImageFromDataURL::ID);
554 EXPECT_TRUE(msg3);
555
556 ViewHostMsg_SaveImageFromDataURL::Param param2;
557 ViewHostMsg_SaveImageFromDataURL::Read(msg3, &param2);
558 EXPECT_EQ(std::get<2>(param2).length(), large_data_url.length());
559 EXPECT_EQ(std::get<2>(param2), large_data_url);
560
561 ProcessPendingMessages();
562 render_thread_->sink().ClearMessages();
563
564 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd');
565
566 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
567 ProcessPendingMessages();
568 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
569 ViewHostMsg_SaveImageFromDataURL::ID);
570 EXPECT_FALSE(msg4);
571 }
572
573 // Test that we get form state change notifications when input fields change. 525 // Test that we get form state change notifications when input fields change.
574 TEST_F(RenderViewImplTest, OnNavStateChanged) { 526 TEST_F(RenderViewImplTest, OnNavStateChanged) {
575 view()->set_send_content_state_immediately(true); 527 view()->set_send_content_state_immediately(true);
576 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); 528 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>");
577 529
578 // We should NOT have gotten a form state change notification yet. 530 // We should NOT have gotten a form state change notification yet.
579 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 531 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
580 FrameHostMsg_UpdateState::ID)); 532 FrameHostMsg_UpdateState::ID));
581 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 533 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
582 ViewHostMsg_UpdateState::ID)); 534 ViewHostMsg_UpdateState::ID));
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 "," 2454 ","
2503 "\"functionDeclaration\":\"function foo(){ " 2455 "\"functionDeclaration\":\"function foo(){ "
2504 "Promise.resolve().then(() => " 2456 "Promise.resolve().then(() => "
2505 "console.log(239))}\"" 2457 "console.log(239))}\""
2506 "}" 2458 "}"
2507 "}"); 2459 "}");
2508 EXPECT_EQ(1, CountNotifications("Console.messageAdded")); 2460 EXPECT_EQ(1, CountNotifications("Console.messageAdded"));
2509 } 2461 }
2510 2462
2511 } // namespace content 2463 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl_browsertest.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698