OLD | NEW |
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/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 EXPECT_TRUE(msg2); | 435 EXPECT_TRUE(msg2); |
436 | 436 |
437 ViewHostMsg_SaveImageFromDataURL::Param param1; | 437 ViewHostMsg_SaveImageFromDataURL::Param param1; |
438 ViewHostMsg_SaveImageFromDataURL::Read(msg2, ¶m1); | 438 ViewHostMsg_SaveImageFromDataURL::Read(msg2, ¶m1); |
439 EXPECT_EQ(base::get<2>(param1).length(), image_data_url.length()); | 439 EXPECT_EQ(base::get<2>(param1).length(), image_data_url.length()); |
440 EXPECT_EQ(base::get<2>(param1), image_data_url); | 440 EXPECT_EQ(base::get<2>(param1), image_data_url); |
441 | 441 |
442 ProcessPendingMessages(); | 442 ProcessPendingMessages(); |
443 render_thread_->sink().ClearMessages(); | 443 render_thread_->sink().ClearMessages(); |
444 | 444 |
445 const std::string large_data_url(1024 * 1024 * 10 - 1, 'd'); | 445 const std::string large_data_url(1024 * 1024 * 20 - 1, 'd'); |
446 | 446 |
447 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url)); | 447 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url)); |
448 ProcessPendingMessages(); | 448 ProcessPendingMessages(); |
449 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 449 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
450 ViewHostMsg_SaveImageFromDataURL::ID); | 450 ViewHostMsg_SaveImageFromDataURL::ID); |
451 EXPECT_TRUE(msg3); | 451 EXPECT_TRUE(msg3); |
452 | 452 |
453 ViewHostMsg_SaveImageFromDataURL::Param param2; | 453 ViewHostMsg_SaveImageFromDataURL::Param param2; |
454 ViewHostMsg_SaveImageFromDataURL::Read(msg3, ¶m2); | 454 ViewHostMsg_SaveImageFromDataURL::Read(msg3, ¶m2); |
455 EXPECT_EQ(base::get<2>(param2).length(), large_data_url.length()); | 455 EXPECT_EQ(base::get<2>(param2).length(), large_data_url.length()); |
456 EXPECT_EQ(base::get<2>(param2), large_data_url); | 456 EXPECT_EQ(base::get<2>(param2), large_data_url); |
457 | 457 |
458 ProcessPendingMessages(); | 458 ProcessPendingMessages(); |
459 render_thread_->sink().ClearMessages(); | 459 render_thread_->sink().ClearMessages(); |
460 | 460 |
461 const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd'); | 461 const std::string exceeded_data_url(1024 * 1024 * 20 + 1, 'd'); |
462 | 462 |
463 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); | 463 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); |
464 ProcessPendingMessages(); | 464 ProcessPendingMessages(); |
465 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( | 465 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( |
466 ViewHostMsg_SaveImageFromDataURL::ID); | 466 ViewHostMsg_SaveImageFromDataURL::ID); |
467 EXPECT_FALSE(msg4); | 467 EXPECT_FALSE(msg4); |
468 } | 468 } |
469 | 469 |
470 // Test that we get form state change notifications when input fields change. | 470 // Test that we get form state change notifications when input fields change. |
471 TEST_F(RenderViewImplTest, OnNavStateChanged) { | 471 TEST_F(RenderViewImplTest, OnNavStateChanged) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state); | 535 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state); |
536 blink::WebHTTPBody body = entry->root().httpBody(); | 536 blink::WebHTTPBody body = entry->root().httpBody(); |
537 blink::WebHTTPBody::Element element; | 537 blink::WebHTTPBody::Element element; |
538 bool successful = body.elementAt(0, element); | 538 bool successful = body.elementAt(0, element); |
539 EXPECT_TRUE(successful); | 539 EXPECT_TRUE(successful); |
540 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); | 540 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); |
541 EXPECT_EQ(length, element.data.size()); | 541 EXPECT_EQ(length, element.data.size()); |
542 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | 542 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); |
543 } | 543 } |
544 | 544 |
| 545 #if defined(OS_ANDROID) |
| 546 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { |
| 547 CommonNavigationParams common_params; |
| 548 common_params.url = GURL("data:text/html,"); |
| 549 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 550 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 551 common_params.base_url_for_data_url = GURL("about:blank"); |
| 552 common_params.history_url_for_data_url = GURL("about:blank"); |
| 553 RequestNavigationParams request_params; |
| 554 request_params.data_url_as_string = |
| 555 "data:text/html,<html><head><title>Data page</title></head></html>"; |
| 556 |
| 557 frame()->Navigate(common_params, StartNavigationParams(), |
| 558 request_params); |
| 559 const IPC::Message* frame_title_msg = nullptr; |
| 560 do { |
| 561 ProcessPendingMessages(); |
| 562 frame_title_msg = render_thread_->sink().GetUniqueMessageMatching( |
| 563 FrameHostMsg_UpdateTitle::ID); |
| 564 } while (!frame_title_msg); |
| 565 |
| 566 // Check post data sent to browser matches. |
| 567 FrameHostMsg_UpdateTitle::Param title_params; |
| 568 EXPECT_TRUE(FrameHostMsg_UpdateTitle::Read(frame_title_msg, &title_params)); |
| 569 EXPECT_EQ(base::ASCIIToUTF16("Data page"), base::get<0>(title_params)); |
| 570 } |
| 571 #endif |
| 572 |
545 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { | 573 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { |
546 WebUITestWebUIControllerFactory factory; | 574 WebUITestWebUIControllerFactory factory; |
547 WebUIControllerFactory::RegisterFactory(&factory); | 575 WebUIControllerFactory::RegisterFactory(&factory); |
548 | 576 |
549 DocumentState state; | 577 DocumentState state; |
550 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); | 578 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); |
551 | 579 |
552 // Navigations to normal HTTP URLs can be handled locally. | 580 // Navigations to normal HTTP URLs can be handled locally. |
553 blink::WebURLRequest request(GURL("http://foo.com")); | 581 blink::WebURLRequest request(GURL("http://foo.com")); |
554 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); | 582 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 FROM_HERE, | 2705 FROM_HERE, |
2678 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2706 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
2679 ExecuteJavaScriptForTests("debugger;"); | 2707 ExecuteJavaScriptForTests("debugger;"); |
2680 | 2708 |
2681 // CloseWhilePaused should resume execution and continue here. | 2709 // CloseWhilePaused should resume execution and continue here. |
2682 EXPECT_FALSE(IsPaused()); | 2710 EXPECT_FALSE(IsPaused()); |
2683 Detach(); | 2711 Detach(); |
2684 } | 2712 } |
2685 | 2713 |
2686 } // namespace content | 2714 } // namespace content |
OLD | NEW |