| 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 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { |
| 546 CommonNavigationParams common_params; |
| 547 common_params.url = GURL("data:text/html,ignored"); |
| 548 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 549 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
| 550 common_params.base_url_for_data_url = GURL("about:blank"); |
| 551 common_params.history_url_for_data_url = GURL("about:blank"); |
| 552 common_params.data_url_as_string = |
| 553 "data:text/html,<html><head><title>Data page</title></head></html>"; |
| 554 |
| 555 frame()->Navigate(common_params, StartNavigationParams(), |
| 556 RequestNavigationParams()); |
| 557 const IPC::Message* frame_title_msg = nullptr; |
| 558 do { |
| 559 ProcessPendingMessages(); |
| 560 frame_title_msg = render_thread_->sink().GetUniqueMessageMatching( |
| 561 FrameHostMsg_UpdateTitle::ID); |
| 562 } while (!frame_title_msg); |
| 563 |
| 564 // Check post data sent to browser matches |
| 565 FrameHostMsg_UpdateTitle::Param title_params; |
| 566 EXPECT_TRUE(FrameHostMsg_UpdateTitle::Read(frame_title_msg, &title_params)); |
| 567 EXPECT_EQ(base::ASCIIToUTF16("Data page"), base::get<0>(title_params)); |
| 568 } |
| 569 |
| 545 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { | 570 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { |
| 546 WebUITestWebUIControllerFactory factory; | 571 WebUITestWebUIControllerFactory factory; |
| 547 WebUIControllerFactory::RegisterFactory(&factory); | 572 WebUIControllerFactory::RegisterFactory(&factory); |
| 548 | 573 |
| 549 DocumentState state; | 574 DocumentState state; |
| 550 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); | 575 state.set_navigation_state(NavigationStateImpl::CreateContentInitiated()); |
| 551 | 576 |
| 552 // Navigations to normal HTTP URLs can be handled locally. | 577 // Navigations to normal HTTP URLs can be handled locally. |
| 553 blink::WebURLRequest request(GURL("http://foo.com")); | 578 blink::WebURLRequest request(GURL("http://foo.com")); |
| 554 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); | 579 blink::WebFrameClient::NavigationPolicyInfo policy_info(request); |
| (...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 FROM_HERE, | 2548 FROM_HERE, |
| 2524 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2549 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
| 2525 ExecuteJavaScriptForTests("debugger;"); | 2550 ExecuteJavaScriptForTests("debugger;"); |
| 2526 | 2551 |
| 2527 // CloseWhilePaused should resume execution and continue here. | 2552 // CloseWhilePaused should resume execution and continue here. |
| 2528 EXPECT_FALSE(IsPaused()); | 2553 EXPECT_FALSE(IsPaused()); |
| 2529 Detach(); | 2554 Detach(); |
| 2530 } | 2555 } |
| 2531 | 2556 |
| 2532 } // namespace content | 2557 } // namespace content |
| OLD | NEW |