| 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 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 host_nav_params.a.page_state); | 320 host_nav_params.a.page_state); |
| 321 blink::WebHTTPBody body = item.httpBody(); | 321 blink::WebHTTPBody body = item.httpBody(); |
| 322 blink::WebHTTPBody::Element element; | 322 blink::WebHTTPBody::Element element; |
| 323 bool successful = body.elementAt(0, element); | 323 bool successful = body.elementAt(0, element); |
| 324 EXPECT_TRUE(successful); | 324 EXPECT_TRUE(successful); |
| 325 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); | 325 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); |
| 326 EXPECT_EQ(length, element.data.size()); | 326 EXPECT_EQ(length, element.data.size()); |
| 327 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | 327 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { |
| 331 ViewMsg_Navigate_Params nav_params; |
| 332 |
| 333 nav_params.url = GURL("data:text/html,ignored"); |
| 334 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
| 335 nav_params.transition = PAGE_TRANSITION_TYPED; |
| 336 nav_params.page_id = -1; |
| 337 nav_params.base_url_for_data_url = GURL("about:blank"); |
| 338 const char kHtml[] = "<html><head><title>Data page</title></head></html>"; |
| 339 nav_params.data_for_data_url = new base::RefCountedStaticMemory( |
| 340 reinterpret_cast<const uint8*>(kHtml), arraysize(kHtml)); |
| 341 |
| 342 view()->OnNavigate(nav_params); |
| 343 ProcessPendingMessages(); |
| 344 |
| 345 const IPC::Message* frame_title_msg = |
| 346 render_thread_->sink().GetUniqueMessageMatching( |
| 347 ViewHostMsg_UpdateTitle::ID); |
| 348 EXPECT_TRUE(frame_title_msg); |
| 349 |
| 350 ViewHostMsg_UpdateTitle::Param title_params; |
| 351 ViewHostMsg_UpdateTitle::Read(frame_title_msg, &title_params); |
| 352 |
| 353 // Check post data sent to browser matches |
| 354 EXPECT_EQ(ASCIIToUTF16("Data page"), title_params.b); |
| 355 } |
| 356 |
| 330 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { | 357 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { |
| 331 WebUITestWebUIControllerFactory factory; | 358 WebUITestWebUIControllerFactory factory; |
| 332 WebUIControllerFactory::RegisterFactory(&factory); | 359 WebUIControllerFactory::RegisterFactory(&factory); |
| 333 | 360 |
| 334 DocumentState state; | 361 DocumentState state; |
| 335 state.set_navigation_state(NavigationState::CreateContentInitiated()); | 362 state.set_navigation_state(NavigationState::CreateContentInitiated()); |
| 336 | 363 |
| 337 // Navigations to normal HTTP URLs can be handled locally. | 364 // Navigations to normal HTTP URLs can be handled locally. |
| 338 blink::WebURLRequest request(GURL("http://foo.com")); | 365 blink::WebURLRequest request(GURL("http://foo.com")); |
| 339 blink::WebNavigationPolicy policy = view()->decidePolicyForNavigation( | 366 blink::WebNavigationPolicy policy = view()->decidePolicyForNavigation( |
| (...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 | 2095 |
| 2069 // An error occurred. | 2096 // An error occurred. |
| 2070 view()->didFailProvisionalLoad(web_frame, error); | 2097 view()->didFailProvisionalLoad(web_frame, error); |
| 2071 ProcessPendingMessages(); | 2098 ProcessPendingMessages(); |
| 2072 const int kMaxOutputCharacters = 22; | 2099 const int kMaxOutputCharacters = 22; |
| 2073 EXPECT_EQ("A suffusion of yellow.", | 2100 EXPECT_EQ("A suffusion of yellow.", |
| 2074 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2101 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
| 2075 } | 2102 } |
| 2076 | 2103 |
| 2077 } // namespace content | 2104 } // namespace content |
| OLD | NEW |