| 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/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; | 296 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; |
| 297 | 297 |
| 298 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url)); | 298 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url)); |
| 299 ProcessPendingMessages(); | 299 ProcessPendingMessages(); |
| 300 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( | 300 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( |
| 301 ViewHostMsg_SaveImageFromDataURL::ID); | 301 ViewHostMsg_SaveImageFromDataURL::ID); |
| 302 EXPECT_TRUE(msg2); | 302 EXPECT_TRUE(msg2); |
| 303 | 303 |
| 304 ViewHostMsg_SaveImageFromDataURL::Param param1; | 304 ViewHostMsg_SaveImageFromDataURL::Param param1; |
| 305 ViewHostMsg_SaveImageFromDataURL::Read(msg2, ¶m1); | 305 ViewHostMsg_SaveImageFromDataURL::Read(msg2, ¶m1); |
| 306 EXPECT_EQ(param1.b.length(), image_data_url.length()); | 306 EXPECT_EQ(get<1>(param1).length(), image_data_url.length()); |
| 307 EXPECT_EQ(param1.b, image_data_url); | 307 EXPECT_EQ(get<1>(param1), image_data_url); |
| 308 | 308 |
| 309 ProcessPendingMessages(); | 309 ProcessPendingMessages(); |
| 310 render_thread_->sink().ClearMessages(); | 310 render_thread_->sink().ClearMessages(); |
| 311 | 311 |
| 312 const std::string large_data_url(1024 * 1024 * 10 - 1, 'd'); | 312 const std::string large_data_url(1024 * 1024 * 10 - 1, 'd'); |
| 313 | 313 |
| 314 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url)); | 314 view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url)); |
| 315 ProcessPendingMessages(); | 315 ProcessPendingMessages(); |
| 316 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 316 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
| 317 ViewHostMsg_SaveImageFromDataURL::ID); | 317 ViewHostMsg_SaveImageFromDataURL::ID); |
| 318 EXPECT_TRUE(msg3); | 318 EXPECT_TRUE(msg3); |
| 319 | 319 |
| 320 ViewHostMsg_SaveImageFromDataURL::Param param2; | 320 ViewHostMsg_SaveImageFromDataURL::Param param2; |
| 321 ViewHostMsg_SaveImageFromDataURL::Read(msg3, ¶m2); | 321 ViewHostMsg_SaveImageFromDataURL::Read(msg3, ¶m2); |
| 322 EXPECT_EQ(param2.b.length(), large_data_url.length()); | 322 EXPECT_EQ(get<1>(param2).length(), large_data_url.length()); |
| 323 EXPECT_EQ(param2.b, large_data_url); | 323 EXPECT_EQ(get<1>(param2), large_data_url); |
| 324 | 324 |
| 325 ProcessPendingMessages(); | 325 ProcessPendingMessages(); |
| 326 render_thread_->sink().ClearMessages(); | 326 render_thread_->sink().ClearMessages(); |
| 327 | 327 |
| 328 const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd'); | 328 const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd'); |
| 329 | 329 |
| 330 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); | 330 view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); |
| 331 ProcessPendingMessages(); | 331 ProcessPendingMessages(); |
| 332 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( | 332 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( |
| 333 ViewHostMsg_SaveImageFromDataURL::ID); | 333 ViewHostMsg_SaveImageFromDataURL::ID); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 ProcessPendingMessages(); | 379 ProcessPendingMessages(); |
| 380 | 380 |
| 381 const IPC::Message* frame_navigate_msg = | 381 const IPC::Message* frame_navigate_msg = |
| 382 render_thread_->sink().GetUniqueMessageMatching( | 382 render_thread_->sink().GetUniqueMessageMatching( |
| 383 FrameHostMsg_DidCommitProvisionalLoad::ID); | 383 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 384 EXPECT_TRUE(frame_navigate_msg); | 384 EXPECT_TRUE(frame_navigate_msg); |
| 385 | 385 |
| 386 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 386 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
| 387 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 387 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 388 &host_nav_params); | 388 &host_nav_params); |
| 389 EXPECT_TRUE(host_nav_params.a.is_post); | 389 EXPECT_TRUE(get<0>(host_nav_params).is_post); |
| 390 | 390 |
| 391 // Check post data sent to browser matches | 391 // Check post data sent to browser matches |
| 392 EXPECT_TRUE(host_nav_params.a.page_state.IsValid()); | 392 EXPECT_TRUE(get<0>(host_nav_params).page_state.IsValid()); |
| 393 scoped_ptr<HistoryEntry> entry = | 393 scoped_ptr<HistoryEntry> entry = |
| 394 PageStateToHistoryEntry(host_nav_params.a.page_state); | 394 PageStateToHistoryEntry(get<0>(host_nav_params).page_state); |
| 395 blink::WebHTTPBody body = entry->root().httpBody(); | 395 blink::WebHTTPBody body = entry->root().httpBody(); |
| 396 blink::WebHTTPBody::Element element; | 396 blink::WebHTTPBody::Element element; |
| 397 bool successful = body.elementAt(0, element); | 397 bool successful = body.elementAt(0, element); |
| 398 EXPECT_TRUE(successful); | 398 EXPECT_TRUE(successful); |
| 399 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); | 399 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); |
| 400 EXPECT_EQ(length, element.data.size()); | 400 EXPECT_EQ(length, element.data.size()); |
| 401 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | 401 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); |
| 402 } | 402 } |
| 403 | 403 |
| 404 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { | 404 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // Load page B, which will trigger an UpdateState message for page A. | 593 // Load page B, which will trigger an UpdateState message for page A. |
| 594 LoadHTML("<div>Page B</div>"); | 594 LoadHTML("<div>Page B</div>"); |
| 595 | 595 |
| 596 // Check for a valid UpdateState message for page A. | 596 // Check for a valid UpdateState message for page A. |
| 597 ProcessPendingMessages(); | 597 ProcessPendingMessages(); |
| 598 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( | 598 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( |
| 599 ViewHostMsg_UpdateState::ID); | 599 ViewHostMsg_UpdateState::ID); |
| 600 ASSERT_TRUE(msg_A); | 600 ASSERT_TRUE(msg_A); |
| 601 ViewHostMsg_UpdateState::Param params; | 601 ViewHostMsg_UpdateState::Param params; |
| 602 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); | 602 ViewHostMsg_UpdateState::Read(msg_A, ¶ms); |
| 603 int page_id_A = params.a; | 603 int page_id_A = get<0>(params); |
| 604 PageState state_A = params.b; | 604 PageState state_A = get<1>(params); |
| 605 EXPECT_EQ(1, page_id_A); | 605 EXPECT_EQ(1, page_id_A); |
| 606 render_thread_->sink().ClearMessages(); | 606 render_thread_->sink().ClearMessages(); |
| 607 | 607 |
| 608 // Back to page A (page_id 1) and commit. | 608 // Back to page A (page_id 1) and commit. |
| 609 FrameMsg_Navigate_Params params_A; | 609 FrameMsg_Navigate_Params params_A; |
| 610 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 610 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 611 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 611 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 612 params_A.current_history_list_length = 2; | 612 params_A.current_history_list_length = 2; |
| 613 params_A.current_history_list_offset = 1; | 613 params_A.current_history_list_offset = 1; |
| 614 params_A.pending_history_list_offset = 0; | 614 params_A.pending_history_list_offset = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 // Verify page A committed, not swappedout://. | 650 // Verify page A committed, not swappedout://. |
| 651 const IPC::Message* frame_navigate_msg = | 651 const IPC::Message* frame_navigate_msg = |
| 652 render_thread_->sink().GetUniqueMessageMatching( | 652 render_thread_->sink().GetUniqueMessageMatching( |
| 653 FrameHostMsg_DidCommitProvisionalLoad::ID); | 653 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 654 EXPECT_TRUE(frame_navigate_msg); | 654 EXPECT_TRUE(frame_navigate_msg); |
| 655 | 655 |
| 656 // Read URL out of the parent trait of the params object. | 656 // Read URL out of the parent trait of the params object. |
| 657 FrameHostMsg_DidCommitProvisionalLoad::Param commit_params; | 657 FrameHostMsg_DidCommitProvisionalLoad::Param commit_params; |
| 658 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 658 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 659 &commit_params); | 659 &commit_params); |
| 660 EXPECT_NE(GURL("swappedout://"), commit_params.a.url); | 660 EXPECT_NE(GURL("swappedout://"), get<0>(commit_params).url); |
| 661 } | 661 } |
| 662 | 662 |
| 663 // Verify that security origins are replicated properly to RenderFrameProxies | 663 // Verify that security origins are replicated properly to RenderFrameProxies |
| 664 // when swapping out. | 664 // when swapping out. |
| 665 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { | 665 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { |
| 666 // This test should only run with --site-per-process, since origin | 666 // This test should only run with --site-per-process, since origin |
| 667 // replication only happens in that mode. | 667 // replication only happens in that mode. |
| 668 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) | 668 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) |
| 669 return; | 669 return; |
| 670 | 670 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 // Load page B, which will trigger an UpdateState message for page A. | 709 // Load page B, which will trigger an UpdateState message for page A. |
| 710 LoadHTML("<div>Page B</div>"); | 710 LoadHTML("<div>Page B</div>"); |
| 711 | 711 |
| 712 // Check for a valid UpdateState message for page A. | 712 // Check for a valid UpdateState message for page A. |
| 713 ProcessPendingMessages(); | 713 ProcessPendingMessages(); |
| 714 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( | 714 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( |
| 715 ViewHostMsg_UpdateState::ID); | 715 ViewHostMsg_UpdateState::ID); |
| 716 ASSERT_TRUE(msg_A); | 716 ASSERT_TRUE(msg_A); |
| 717 ViewHostMsg_UpdateState::Param param; | 717 ViewHostMsg_UpdateState::Param param; |
| 718 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 718 ViewHostMsg_UpdateState::Read(msg_A, ¶m); |
| 719 int page_id_A = param.a; | 719 int page_id_A = get<0>(param); |
| 720 PageState state_A = param.b; | 720 PageState state_A = get<1>(param); |
| 721 EXPECT_EQ(1, page_id_A); | 721 EXPECT_EQ(1, page_id_A); |
| 722 render_thread_->sink().ClearMessages(); | 722 render_thread_->sink().ClearMessages(); |
| 723 | 723 |
| 724 // Load page C, which will trigger an UpdateState message for page B. | 724 // Load page C, which will trigger an UpdateState message for page B. |
| 725 LoadHTML("<div>Page C</div>"); | 725 LoadHTML("<div>Page C</div>"); |
| 726 | 726 |
| 727 // Check for a valid UpdateState for page B. | 727 // Check for a valid UpdateState for page B. |
| 728 ProcessPendingMessages(); | 728 ProcessPendingMessages(); |
| 729 const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching( | 729 const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching( |
| 730 ViewHostMsg_UpdateState::ID); | 730 ViewHostMsg_UpdateState::ID); |
| 731 ASSERT_TRUE(msg_B); | 731 ASSERT_TRUE(msg_B); |
| 732 ViewHostMsg_UpdateState::Read(msg_B, ¶m); | 732 ViewHostMsg_UpdateState::Read(msg_B, ¶m); |
| 733 int page_id_B = param.a; | 733 int page_id_B = get<0>(param); |
| 734 PageState state_B = param.b; | 734 PageState state_B = get<1>(param); |
| 735 EXPECT_EQ(2, page_id_B); | 735 EXPECT_EQ(2, page_id_B); |
| 736 EXPECT_NE(state_A, state_B); | 736 EXPECT_NE(state_A, state_B); |
| 737 render_thread_->sink().ClearMessages(); | 737 render_thread_->sink().ClearMessages(); |
| 738 | 738 |
| 739 // Load page D, which will trigger an UpdateState message for page C. | 739 // Load page D, which will trigger an UpdateState message for page C. |
| 740 LoadHTML("<div>Page D</div>"); | 740 LoadHTML("<div>Page D</div>"); |
| 741 | 741 |
| 742 // Check for a valid UpdateState for page C. | 742 // Check for a valid UpdateState for page C. |
| 743 ProcessPendingMessages(); | 743 ProcessPendingMessages(); |
| 744 const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching( | 744 const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching( |
| 745 ViewHostMsg_UpdateState::ID); | 745 ViewHostMsg_UpdateState::ID); |
| 746 ASSERT_TRUE(msg_C); | 746 ASSERT_TRUE(msg_C); |
| 747 ViewHostMsg_UpdateState::Read(msg_C, ¶m); | 747 ViewHostMsg_UpdateState::Read(msg_C, ¶m); |
| 748 int page_id_C = param.a; | 748 int page_id_C = get<0>(param); |
| 749 PageState state_C = param.b; | 749 PageState state_C = get<1>(param); |
| 750 EXPECT_EQ(3, page_id_C); | 750 EXPECT_EQ(3, page_id_C); |
| 751 EXPECT_NE(state_B, state_C); | 751 EXPECT_NE(state_B, state_C); |
| 752 render_thread_->sink().ClearMessages(); | 752 render_thread_->sink().ClearMessages(); |
| 753 | 753 |
| 754 // Go back to C and commit, preparing for our real test. | 754 // Go back to C and commit, preparing for our real test. |
| 755 FrameMsg_Navigate_Params params_C; | 755 FrameMsg_Navigate_Params params_C; |
| 756 params_C.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 756 params_C.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 757 params_C.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 757 params_C.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 758 params_C.current_history_list_length = 4; | 758 params_C.current_history_list_length = 4; |
| 759 params_C.current_history_list_offset = 3; | 759 params_C.current_history_list_offset = 3; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 base::TimeTicks::FromInternalValue(1); | 796 base::TimeTicks::FromInternalValue(1); |
| 797 frame()->OnNavigate(params); | 797 frame()->OnNavigate(params); |
| 798 ProcessPendingMessages(); | 798 ProcessPendingMessages(); |
| 799 | 799 |
| 800 // Now ensure that the UpdateState message we receive is consistent | 800 // Now ensure that the UpdateState message we receive is consistent |
| 801 // and represents page C in both page_id and state. | 801 // and represents page C in both page_id and state. |
| 802 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 802 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 803 ViewHostMsg_UpdateState::ID); | 803 ViewHostMsg_UpdateState::ID); |
| 804 ASSERT_TRUE(msg); | 804 ASSERT_TRUE(msg); |
| 805 ViewHostMsg_UpdateState::Read(msg, ¶m); | 805 ViewHostMsg_UpdateState::Read(msg, ¶m); |
| 806 int page_id = param.a; | 806 int page_id = get<0>(param); |
| 807 PageState state = param.b; | 807 PageState state = get<1>(param); |
| 808 EXPECT_EQ(page_id_C, page_id); | 808 EXPECT_EQ(page_id_C, page_id); |
| 809 EXPECT_NE(state_A, state); | 809 EXPECT_NE(state_A, state); |
| 810 EXPECT_NE(state_B, state); | 810 EXPECT_NE(state_B, state); |
| 811 EXPECT_EQ(state_C, state); | 811 EXPECT_EQ(state_C, state); |
| 812 } | 812 } |
| 813 | 813 |
| 814 // Test that stale back/forward navigations arriving from the browser are | 814 // Test that stale back/forward navigations arriving from the browser are |
| 815 // ignored. See http://crbug.com/86758. | 815 // ignored. See http://crbug.com/86758. |
| 816 TEST_F(RenderViewImplTest, StaleNavigationsIgnored) { | 816 TEST_F(RenderViewImplTest, StaleNavigationsIgnored) { |
| 817 // Load page A. | 817 // Load page A. |
| 818 LoadHTML("<div>Page A</div>"); | 818 LoadHTML("<div>Page A</div>"); |
| 819 EXPECT_EQ(1, view()->history_list_length_); | 819 EXPECT_EQ(1, view()->history_list_length_); |
| 820 EXPECT_EQ(0, view()->history_list_offset_); | 820 EXPECT_EQ(0, view()->history_list_offset_); |
| 821 | 821 |
| 822 // Load page B, which will trigger an UpdateState message for page A. | 822 // Load page B, which will trigger an UpdateState message for page A. |
| 823 LoadHTML("<div>Page B</div>"); | 823 LoadHTML("<div>Page B</div>"); |
| 824 EXPECT_EQ(2, view()->history_list_length_); | 824 EXPECT_EQ(2, view()->history_list_length_); |
| 825 EXPECT_EQ(1, view()->history_list_offset_); | 825 EXPECT_EQ(1, view()->history_list_offset_); |
| 826 | 826 |
| 827 // Check for a valid UpdateState message for page A. | 827 // Check for a valid UpdateState message for page A. |
| 828 ProcessPendingMessages(); | 828 ProcessPendingMessages(); |
| 829 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( | 829 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( |
| 830 ViewHostMsg_UpdateState::ID); | 830 ViewHostMsg_UpdateState::ID); |
| 831 ASSERT_TRUE(msg_A); | 831 ASSERT_TRUE(msg_A); |
| 832 ViewHostMsg_UpdateState::Param param; | 832 ViewHostMsg_UpdateState::Param param; |
| 833 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 833 ViewHostMsg_UpdateState::Read(msg_A, ¶m); |
| 834 int page_id_A = param.a; | 834 int page_id_A = get<0>(param); |
| 835 PageState state_A = param.b; | 835 PageState state_A = get<1>(param); |
| 836 EXPECT_EQ(1, page_id_A); | 836 EXPECT_EQ(1, page_id_A); |
| 837 render_thread_->sink().ClearMessages(); | 837 render_thread_->sink().ClearMessages(); |
| 838 | 838 |
| 839 // Back to page A (page_id 1) and commit. | 839 // Back to page A (page_id 1) and commit. |
| 840 FrameMsg_Navigate_Params params_A; | 840 FrameMsg_Navigate_Params params_A; |
| 841 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 841 params_A.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 842 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 842 params_A.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 843 params_A.current_history_list_length = 2; | 843 params_A.current_history_list_length = 2; |
| 844 params_A.current_history_list_offset = 1; | 844 params_A.current_history_list_offset = 1; |
| 845 params_A.pending_history_list_offset = 0; | 845 params_A.pending_history_list_offset = 0; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 render_thread_->sink().ClearMessages(); | 946 render_thread_->sink().ClearMessages(); |
| 947 | 947 |
| 948 // Update the IME status and verify if our IME backend sends an IPC message | 948 // Update the IME status and verify if our IME backend sends an IPC message |
| 949 // to activate IMEs. | 949 // to activate IMEs. |
| 950 view()->UpdateTextInputType(); | 950 view()->UpdateTextInputType(); |
| 951 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 951 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
| 952 EXPECT_TRUE(msg != NULL); | 952 EXPECT_TRUE(msg != NULL); |
| 953 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 953 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); |
| 954 ViewHostMsg_TextInputTypeChanged::Param params; | 954 ViewHostMsg_TextInputTypeChanged::Param params; |
| 955 ViewHostMsg_TextInputTypeChanged::Read(msg, ¶ms); | 955 ViewHostMsg_TextInputTypeChanged::Read(msg, ¶ms); |
| 956 ui::TextInputType type = params.a; | 956 ui::TextInputType type = get<0>(params); |
| 957 ui::TextInputMode input_mode = params.b; | 957 ui::TextInputMode input_mode = get<1>(params); |
| 958 bool can_compose_inline = params.c; | 958 bool can_compose_inline = get<2>(params); |
| 959 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); | 959 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); |
| 960 EXPECT_EQ(true, can_compose_inline); | 960 EXPECT_EQ(true, can_compose_inline); |
| 961 | 961 |
| 962 // Move the input focus to the second <input> element, where we should | 962 // Move the input focus to the second <input> element, where we should |
| 963 // de-activate IMEs. | 963 // de-activate IMEs. |
| 964 ExecuteJavaScript("document.getElementById('test2').focus();"); | 964 ExecuteJavaScript("document.getElementById('test2').focus();"); |
| 965 ProcessPendingMessages(); | 965 ProcessPendingMessages(); |
| 966 render_thread_->sink().ClearMessages(); | 966 render_thread_->sink().ClearMessages(); |
| 967 | 967 |
| 968 // Update the IME status and verify if our IME backend sends an IPC message | 968 // Update the IME status and verify if our IME backend sends an IPC message |
| 969 // to de-activate IMEs. | 969 // to de-activate IMEs. |
| 970 view()->UpdateTextInputType(); | 970 view()->UpdateTextInputType(); |
| 971 msg = render_thread_->sink().GetMessageAt(0); | 971 msg = render_thread_->sink().GetMessageAt(0); |
| 972 EXPECT_TRUE(msg != NULL); | 972 EXPECT_TRUE(msg != NULL); |
| 973 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 973 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); |
| 974 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); | 974 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); |
| 975 type = params.a; | 975 type = get<0>(params); |
| 976 input_mode = params.b; | 976 input_mode = get<1>(params); |
| 977 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); | 977 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); |
| 978 | 978 |
| 979 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { | 979 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { |
| 980 const InputModeTestCase* test_case = &kInputModeTestCases[i]; | 980 const InputModeTestCase* test_case = &kInputModeTestCases[i]; |
| 981 std::string javascript = | 981 std::string javascript = |
| 982 base::StringPrintf("document.getElementById('%s').focus();", | 982 base::StringPrintf("document.getElementById('%s').focus();", |
| 983 test_case->input_id); | 983 test_case->input_id); |
| 984 // Move the input focus to the target <input> element, where we should | 984 // Move the input focus to the target <input> element, where we should |
| 985 // activate IMEs. | 985 // activate IMEs. |
| 986 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); | 986 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); |
| 987 ProcessPendingMessages(); | 987 ProcessPendingMessages(); |
| 988 render_thread_->sink().ClearMessages(); | 988 render_thread_->sink().ClearMessages(); |
| 989 | 989 |
| 990 // Update the IME status and verify if our IME backend sends an IPC | 990 // Update the IME status and verify if our IME backend sends an IPC |
| 991 // message to activate IMEs. | 991 // message to activate IMEs. |
| 992 view()->UpdateTextInputType(); | 992 view()->UpdateTextInputType(); |
| 993 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 993 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
| 994 EXPECT_TRUE(msg != NULL); | 994 EXPECT_TRUE(msg != NULL); |
| 995 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 995 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); |
| 996 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); | 996 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); |
| 997 type = params.a; | 997 type = get<0>(params); |
| 998 input_mode = params.b; | 998 input_mode = get<1>(params); |
| 999 EXPECT_EQ(test_case->expected_mode, input_mode); | 999 EXPECT_EQ(test_case->expected_mode, input_mode); |
| 1000 } | 1000 } |
| 1001 } | 1001 } |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 // Test that our IME backend can compose CJK words. | 1004 // Test that our IME backend can compose CJK words. |
| 1005 // Our IME front-end sends many platform-independent messages to the IME backend | 1005 // Our IME front-end sends many platform-independent messages to the IME backend |
| 1006 // while it composes CJK words. This test sends the minimal messages captured | 1006 // while it composes CJK words. This test sends the minimal messages captured |
| 1007 // on my local environment directly to the IME backend to verify if the backend | 1007 // on my local environment directly to the IME backend to verify if the backend |
| 1008 // can compose CJK words without any problems. | 1008 // can compose CJK words without any problems. |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 LoadHTML("<input id='test1' value='hello1'></input>" | 2117 LoadHTML("<input id='test1' value='hello1'></input>" |
| 2118 "<input id='test2' value='hello2'></input>"); | 2118 "<input id='test2' value='hello2'></input>"); |
| 2119 | 2119 |
| 2120 ExecuteJavaScript("document.getElementById('test1').focus();"); | 2120 ExecuteJavaScript("document.getElementById('test1').focus();"); |
| 2121 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( | 2121 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( |
| 2122 ViewHostMsg_FocusedNodeChanged::ID); | 2122 ViewHostMsg_FocusedNodeChanged::ID); |
| 2123 EXPECT_TRUE(msg1); | 2123 EXPECT_TRUE(msg1); |
| 2124 | 2124 |
| 2125 ViewHostMsg_FocusedNodeChanged::Param params; | 2125 ViewHostMsg_FocusedNodeChanged::Param params; |
| 2126 ViewHostMsg_FocusedNodeChanged::Read(msg1, ¶ms); | 2126 ViewHostMsg_FocusedNodeChanged::Read(msg1, ¶ms); |
| 2127 EXPECT_TRUE(params.a); | 2127 EXPECT_TRUE(get<0>(params)); |
| 2128 render_thread_->sink().ClearMessages(); | 2128 render_thread_->sink().ClearMessages(); |
| 2129 | 2129 |
| 2130 ExecuteJavaScript("document.getElementById('test2').focus();"); | 2130 ExecuteJavaScript("document.getElementById('test2').focus();"); |
| 2131 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( | 2131 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( |
| 2132 ViewHostMsg_FocusedNodeChanged::ID); | 2132 ViewHostMsg_FocusedNodeChanged::ID); |
| 2133 EXPECT_TRUE(msg2); | 2133 EXPECT_TRUE(msg2); |
| 2134 ViewHostMsg_FocusedNodeChanged::Read(msg2, ¶ms); | 2134 ViewHostMsg_FocusedNodeChanged::Read(msg2, ¶ms); |
| 2135 EXPECT_TRUE(params.a); | 2135 EXPECT_TRUE(get<0>(params)); |
| 2136 render_thread_->sink().ClearMessages(); | 2136 render_thread_->sink().ClearMessages(); |
| 2137 | 2137 |
| 2138 view()->webview()->clearFocusedElement(); | 2138 view()->webview()->clearFocusedElement(); |
| 2139 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 2139 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
| 2140 ViewHostMsg_FocusedNodeChanged::ID); | 2140 ViewHostMsg_FocusedNodeChanged::ID); |
| 2141 EXPECT_TRUE(msg3); | 2141 EXPECT_TRUE(msg3); |
| 2142 ViewHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); | 2142 ViewHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); |
| 2143 EXPECT_FALSE(params.a); | 2143 EXPECT_FALSE(get<0>(params)); |
| 2144 render_thread_->sink().ClearMessages(); | 2144 render_thread_->sink().ClearMessages(); |
| 2145 } | 2145 } |
| 2146 | 2146 |
| 2147 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) { | 2147 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) { |
| 2148 ServiceWorkerNetworkProvider* provider = NULL; | 2148 ServiceWorkerNetworkProvider* provider = NULL; |
| 2149 RequestExtraData* extra_data = NULL; | 2149 RequestExtraData* extra_data = NULL; |
| 2150 | 2150 |
| 2151 // Make sure each new document has a new provider and | 2151 // Make sure each new document has a new provider and |
| 2152 // that the main request is tagged with the provider's id. | 2152 // that the main request is tagged with the provider's id. |
| 2153 LoadHTML("<b>A Document</b>"); | 2153 LoadHTML("<b>A Document</b>"); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 | 2311 |
| 2312 gfx::Size size = GetPreferredSize(); | 2312 gfx::Size size = GetPreferredSize(); |
| 2313 EXPECT_EQ(gfx::Size(400, 400), size); | 2313 EXPECT_EQ(gfx::Size(400, 400), size); |
| 2314 | 2314 |
| 2315 SetZoomLevel(ZoomFactorToZoomLevel(2.0)); | 2315 SetZoomLevel(ZoomFactorToZoomLevel(2.0)); |
| 2316 size = GetPreferredSize(); | 2316 size = GetPreferredSize(); |
| 2317 EXPECT_EQ(gfx::Size(800, 800), size); | 2317 EXPECT_EQ(gfx::Size(800, 800), size); |
| 2318 } | 2318 } |
| 2319 | 2319 |
| 2320 } // namespace content | 2320 } // namespace content |
| OLD | NEW |