Chromium Code Reviews| 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/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/common/intents_messages.h" | 10 #include "content/common/intents_messages.h" |
| 11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
| 12 #include "content/public/browser/native_web_keyboard_event.h" | 12 #include "content/public/browser/native_web_keyboard_event.h" |
| 13 #include "content/public/browser/web_ui_controller_factory.h" | 13 #include "content/public/browser/web_ui_controller_factory.h" |
| 14 #include "content/public/common/bindings_policy.h" | 14 #include "content/public/common/bindings_policy.h" |
| 15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 16 #include "content/public/test/render_view_test.h" | 16 #include "content/public/test/render_view_test.h" |
| 17 #include "content/renderer/render_view_impl.h" | 17 #include "content/renderer/render_view_impl.h" |
| 18 #include "content/shell/shell_content_client.h" | 18 #include "content/shell/shell_content_client.h" |
| 19 #include "content/shell/shell_content_browser_client.h" | 19 #include "content/shell/shell_content_browser_client.h" |
| 20 #include "content/shell/shell_main_delegate.h" | 20 #include "content/shell/shell_main_delegate.h" |
| 21 #include "content/test/mock_keyboard.h" | 21 #include "content/test/mock_keyboard.h" |
| 22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" | |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody. h" | |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" | |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo. h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo. h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
| 29 #include "ui/base/keycodes/keyboard_codes.h" | 32 #include "ui/base/keycodes/keyboard_codes.h" |
| 30 #include "ui/base/range/range.h" | 33 #include "ui/base/range/range.h" |
| 31 #include "ui/gfx/codec/jpeg_codec.h" | 34 #include "ui/gfx/codec/jpeg_codec.h" |
| 35 #include "webkit/glue/glue_serialize.h" | |
| 32 #include "webkit/glue/web_io_operators.h" | 36 #include "webkit/glue/web_io_operators.h" |
| 33 | 37 |
| 34 #if defined(OS_LINUX) && !defined(USE_AURA) | 38 #if defined(OS_LINUX) && !defined(USE_AURA) |
| 35 #include "ui/base/gtk/event_synthesis_gtk.h" | 39 #include "ui/base/gtk/event_synthesis_gtk.h" |
| 36 #endif | 40 #endif |
| 37 | 41 |
| 38 #if defined(USE_AURA) | 42 #if defined(USE_AURA) |
| 39 #include "ui/aura/event.h" | 43 #include "ui/aura/event.h" |
| 40 #endif | 44 #endif |
| 41 | 45 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 render_thread_->sink().ClearMessages(); | 297 render_thread_->sink().ClearMessages(); |
| 294 | 298 |
| 295 // Change the value of the input. We should have gotten an update state | 299 // Change the value of the input. We should have gotten an update state |
| 296 // notification. We need to spin the message loop to catch this update. | 300 // notification. We need to spin the message loop to catch this update. |
| 297 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); | 301 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); |
| 298 ProcessPendingMessages(); | 302 ProcessPendingMessages(); |
| 299 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 303 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
| 300 ViewHostMsg_UpdateState::ID)); | 304 ViewHostMsg_UpdateState::ID)); |
| 301 } | 305 } |
| 302 | 306 |
| 307 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { | |
| 308 ViewMsg_Navigate_Params nav_params; | |
| 309 | |
| 310 // An http url will trigger a resource load so cannot be used here. | |
| 311 nav_params.url = GURL("data:text/html,<div>Page</div>"); | |
| 312 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | |
| 313 nav_params.transition = content::PAGE_TRANSITION_TYPED; | |
| 314 nav_params.page_id = -1; | |
| 315 nav_params.is_post = true; | |
| 316 | |
| 317 // Set up post ata | |
|
jam
2012/07/27 23:36:15
nit; data
| |
| 318 const char* raw_data = "post \0\ndata"; | |
| 319 const int length = 11; | |
| 320 const std::vector<char> post_data(raw_data, raw_data + length); | |
| 321 nav_params.browser_initiated_post_data = post_data; | |
| 322 | |
| 323 view()->OnNavigate(nav_params); | |
| 324 ProcessPendingMessages(); | |
| 325 | |
| 326 const IPC::Message* frame_navigate_msg = | |
| 327 render_thread_->sink().GetUniqueMessageMatching( | |
| 328 ViewHostMsg_FrameNavigate::ID); | |
| 329 EXPECT_TRUE(frame_navigate_msg); | |
| 330 | |
| 331 ViewHostMsg_FrameNavigate::Param host_nav_params; | |
| 332 ViewHostMsg_FrameNavigate::Read(frame_navigate_msg, &host_nav_params); | |
| 333 EXPECT_TRUE(host_nav_params.a.is_post); | |
| 334 | |
| 335 // Check post data sent to browser matches | |
| 336 EXPECT_FALSE(host_nav_params.a.content_state.empty()); | |
| 337 const WebKit::WebHistoryItem item = webkit_glue::HistoryItemFromString( | |
| 338 host_nav_params.a.content_state); | |
| 339 WebKit::WebHTTPBody body = item.httpBody(); | |
| 340 WebKit::WebHTTPBody::Element element; | |
| 341 bool successful = body.elementAt(0, element); | |
| 342 EXPECT_TRUE(successful); | |
| 343 EXPECT_EQ(WebKit::WebHTTPBody::Element::TypeData, element.type); | |
| 344 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | |
| 345 } | |
| 346 | |
| 303 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { | 347 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { |
| 304 WebUITestClient client; | 348 WebUITestClient client; |
| 305 WebUITestBrowserClient browser_client; | 349 WebUITestBrowserClient browser_client; |
| 306 content::ContentClient* old_client = content::GetContentClient(); | 350 content::ContentClient* old_client = content::GetContentClient(); |
| 307 content::ContentBrowserClient* old_browser_client = | 351 content::ContentBrowserClient* old_browser_client = |
| 308 content::GetContentClient()->browser(); | 352 content::GetContentClient()->browser(); |
| 309 | 353 |
| 310 content::SetContentClient(&client); | 354 content::SetContentClient(&client); |
| 311 content::GetContentClient()->set_browser_for_testing(&browser_client); | 355 content::GetContentClient()->set_browser_for_testing(&browser_client); |
| 312 client.set_renderer_for_testing(old_client->renderer()); | 356 client.set_renderer_for_testing(old_client->renderer()); |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1645 ASSERT_EQ(utf16_length, bounds.size()); | 1689 ASSERT_EQ(utf16_length, bounds.size()); |
| 1646 for (size_t i = 0; i < utf16_length; ++i) { | 1690 for (size_t i = 0; i < utf16_length; ++i) { |
| 1647 if (is_surrogate_pair_empty_rect[i]) { | 1691 if (is_surrogate_pair_empty_rect[i]) { |
| 1648 EXPECT_EQ(0, bounds[i].width()); | 1692 EXPECT_EQ(0, bounds[i].width()); |
| 1649 } else { | 1693 } else { |
| 1650 EXPECT_LT(0, bounds[i].width()); | 1694 EXPECT_LT(0, bounds[i].width()); |
| 1651 } | 1695 } |
| 1652 } | 1696 } |
| 1653 view()->OnImeConfirmComposition(empty_string, ui::Range::InvalidRange()); | 1697 view()->OnImeConfirmComposition(empty_string, ui::Range::InvalidRange()); |
| 1654 } | 1698 } |
| OLD | NEW |