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

Side by Side Diff: content/renderer/render_frame_impl_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: merge boo boo 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/common/frame_messages.h" 10 #include "content/common/frame_messages.h"
11 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
12 #include "content/public/renderer/document_state.h" 12 #include "content/public/renderer/document_state.h"
13 #include "content/public/test/frame_load_waiter.h" 13 #include "content/public/test/frame_load_waiter.h"
14 #include "content/public/test/render_view_test.h" 14 #include "content/public/test/render_view_test.h"
15 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
16 #include "content/renderer/navigation_state_impl.h" 16 #include "content/renderer/navigation_state_impl.h"
17 #include "content/renderer/render_frame_impl.h" 17 #include "content/renderer/render_frame_impl.h"
18 #include "content/renderer/render_view_impl.h" 18 #include "content/renderer/render_view_impl.h"
19 #include "content/test/fake_compositor_dependencies.h" 19 #include "content/test/fake_compositor_dependencies.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h" 21 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h"
22 #include "third_party/WebKit/public/platform/WebString.h"
22 #include "third_party/WebKit/public/platform/WebURLRequest.h" 23 #include "third_party/WebKit/public/platform/WebURLRequest.h"
23 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" 24 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h"
24 #include "third_party/WebKit/public/web/WebHistoryItem.h" 25 #include "third_party/WebKit/public/web/WebHistoryItem.h"
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" 26 #include "third_party/WebKit/public/web/WebLocalFrame.h"
26 27
28 using blink::WebString;
29
27 namespace { 30 namespace {
28 const int32_t kSubframeRouteId = 20; 31 const int32_t kSubframeRouteId = 20;
29 const int32_t kSubframeWidgetRouteId = 21; 32 const int32_t kSubframeWidgetRouteId = 21;
30 const int32_t kFrameProxyRouteId = 22; 33 const int32_t kFrameProxyRouteId = 22;
31 } // namespace 34 } // namespace
32 35
33 namespace content { 36 namespace content {
34 37
35 // RenderFrameImplTest creates a RenderFrameImpl that is a child of the 38 // RenderFrameImplTest creates a RenderFrameImpl that is a child of the
36 // main frame, and has its own RenderWidget. This behaves like an out 39 // main frame, and has its own RenderWidget. This behaves like an out
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit); 290 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit);
288 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown, 291 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown,
289 GetMainRenderFrame()->getEffectiveConnectionType()); 292 GetMainRenderFrame()->getEffectiveConnectionType());
290 293
291 // The subframe would be deleted here after a cross-document navigation. 294 // The subframe would be deleted here after a cross-document navigation.
292 // It happens to be left around in this test because this does not simulate 295 // It happens to be left around in this test because this does not simulate
293 // the frame detach. 296 // the frame detach.
294 } 297 }
295 } 298 }
296 299
300 TEST_F(RenderFrameImplTest, SaveImageFromDataURL) {
301 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
302 FrameHostMsg_SaveImageFromDataURL::ID);
303 EXPECT_FALSE(msg1);
304 render_thread_->sink().ClearMessages();
305
306 const std::string image_data_url =
307 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
308
309 frame()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
310 ProcessPendingMessages();
311 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
312 FrameHostMsg_SaveImageFromDataURL::ID);
313 EXPECT_TRUE(msg2);
314
315 FrameHostMsg_SaveImageFromDataURL::Param param1;
316 FrameHostMsg_SaveImageFromDataURL::Read(msg2, &param1);
317 EXPECT_EQ(std::get<2>(param1).length(), image_data_url.length());
asanka 2016/06/20 17:13:18 Redundant? Here and below.
318 EXPECT_EQ(std::get<2>(param1), image_data_url);
319
320 ProcessPendingMessages();
321 render_thread_->sink().ClearMessages();
322
323 const std::string large_data_url(1024 * 1024 * 20 - 1, 'd');
324
325 frame()->saveImageFromDataURL(WebString::fromUTF8(large_data_url));
326 ProcessPendingMessages();
327 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
328 FrameHostMsg_SaveImageFromDataURL::ID);
329 EXPECT_TRUE(msg3);
330
331 FrameHostMsg_SaveImageFromDataURL::Param param2;
332 FrameHostMsg_SaveImageFromDataURL::Read(msg3, &param2);
333 EXPECT_EQ(std::get<2>(param2).length(), large_data_url.length());
334 EXPECT_EQ(std::get<2>(param2), large_data_url);
335
336 ProcessPendingMessages();
337 render_thread_->sink().ClearMessages();
338
339 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd');
340
341 frame()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
342 ProcessPendingMessages();
343 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
344 FrameHostMsg_SaveImageFromDataURL::ID);
345 EXPECT_FALSE(msg4);
346 }
347
297 } // namespace 348 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698