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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 #include "content/public/renderer/content_renderer_client.h" | 43 #include "content/public/renderer/content_renderer_client.h" |
| 44 #include "content/public/renderer/document_state.h" | 44 #include "content/public/renderer/document_state.h" |
| 45 #include "content/public/renderer/navigation_state.h" | 45 #include "content/public/renderer/navigation_state.h" |
| 46 #include "content/public/test/browser_test_utils.h" | 46 #include "content/public/test/browser_test_utils.h" |
| 47 #include "content/public/test/frame_load_waiter.h" | 47 #include "content/public/test/frame_load_waiter.h" |
| 48 #include "content/public/test/render_view_test.h" | 48 #include "content/public/test/render_view_test.h" |
| 49 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
| 50 #include "content/renderer/accessibility/render_accessibility_impl.h" | 50 #include "content/renderer/accessibility/render_accessibility_impl.h" |
| 51 #include "content/renderer/devtools/devtools_agent.h" | 51 #include "content/renderer/devtools/devtools_agent.h" |
| 52 #include "content/renderer/gpu/render_widget_compositor.h" | 52 #include "content/renderer/gpu/render_widget_compositor.h" |
| 53 #include "content/renderer/history_controller.h" | 53 #include "content/renderer/history_entry.h" |
| 54 #include "content/renderer/history_serialization.h" | 54 #include "content/renderer/history_serialization.h" |
| 55 #include "content/renderer/navigation_state_impl.h" | 55 #include "content/renderer/navigation_state_impl.h" |
| 56 #include "content/renderer/render_frame_proxy.h" | 56 #include "content/renderer/render_frame_proxy.h" |
| 57 #include "content/renderer/render_process.h" | 57 #include "content/renderer/render_process.h" |
| 58 #include "content/renderer/render_view_impl.h" | 58 #include "content/renderer/render_view_impl.h" |
| 59 #include "content/shell/browser/shell.h" | 59 #include "content/shell/browser/shell.h" |
| 60 #include "content/shell/browser/shell_browser_context.h" | 60 #include "content/shell/browser/shell_browser_context.h" |
| 61 #include "content/test/mock_keyboard.h" | 61 #include "content/test/mock_keyboard.h" |
| 62 #include "content/test/test_render_frame.h" | 62 #include "content/test/test_render_frame.h" |
| 63 #include "net/base/net_errors.h" | 63 #include "net/base/net_errors.h" |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 } | 578 } |
| 579 | 579 |
| 580 // Test that we get form state change notifications when input fields change. | 580 // Test that we get form state change notifications when input fields change. |
| 581 TEST_F(RenderViewImplTest, OnNavStateChanged) { | 581 TEST_F(RenderViewImplTest, OnNavStateChanged) { |
| 582 view()->set_send_content_state_immediately(true); | 582 view()->set_send_content_state_immediately(true); |
| 583 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); | 583 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); |
| 584 | 584 |
| 585 // We should NOT have gotten a form state change notification yet. | 585 // We should NOT have gotten a form state change notification yet. |
| 586 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 586 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 587 FrameHostMsg_UpdateState::ID)); | 587 FrameHostMsg_UpdateState::ID)); |
| 588 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | |
| 589 ViewHostMsg_UpdateState::ID)); | |
| 590 render_thread_->sink().ClearMessages(); | 588 render_thread_->sink().ClearMessages(); |
| 591 | 589 |
| 592 // Change the value of the input. We should have gotten an update state | 590 // Change the value of the input. We should have gotten an update state |
| 593 // notification. We need to spin the message loop to catch this update. | 591 // notification. We need to spin the message loop to catch this update. |
| 594 ExecuteJavaScriptForTests( | 592 ExecuteJavaScriptForTests( |
| 595 "document.getElementById('elt_text').value = 'foo';"); | 593 "document.getElementById('elt_text').value = 'foo';"); |
| 596 ProcessPendingMessages(); | 594 ProcessPendingMessages(); |
| 597 | 595 |
| 598 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 596 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
| 599 FrameHostMsg_UpdateState::ID)); | 597 FrameHostMsg_UpdateState::ID)); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 ReconstructReplicationStateForTesting(main_frame)); | 928 ReconstructReplicationStateForTesting(main_frame)); |
| 931 EXPECT_TRUE(view()->webview()->mainFrame()->isWebRemoteFrame()); | 929 EXPECT_TRUE(view()->webview()->mainFrame()->isWebRemoteFrame()); |
| 932 | 930 |
| 933 // This should not cause a crash. | 931 // This should not cause a crash. |
| 934 view()->OnDeviceScaleFactorChanged(); | 932 view()->OnDeviceScaleFactorChanged(); |
| 935 } | 933 } |
| 936 | 934 |
| 937 // Test that we get the correct UpdateState message when we go back twice | 935 // Test that we get the correct UpdateState message when we go back twice |
| 938 // quickly without committing. Regression test for http://crbug.com/58082. | 936 // quickly without committing. Regression test for http://crbug.com/58082. |
| 939 // Disabled: http://crbug.com/157357 . | 937 // Disabled: http://crbug.com/157357 . |
| 940 TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) { | 938 TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) { |
|
Charlie Reis
2017/01/24 17:34:24
This passed for me locally with 100 iterations. M
nasko
2017/01/26 00:56:20
I'd also say try it in ASan build.
| |
| 941 // Load page A. | 939 // Load page A. |
| 942 LoadHTML("<div>Page A</div>"); | 940 LoadHTML("<div>Page A</div>"); |
| 943 | 941 |
| 944 // Load page B, which will trigger an UpdateState message for page A. | 942 // Load page B, which will trigger an UpdateState message for page A. |
| 945 LoadHTML("<div>Page B</div>"); | 943 LoadHTML("<div>Page B</div>"); |
| 946 | 944 |
| 947 // Check for a valid UpdateState message for page A. | 945 // Check for a valid UpdateState message for page A. |
| 948 ProcessPendingMessages(); | 946 ProcessPendingMessages(); |
| 949 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( | 947 const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching( |
| 950 ViewHostMsg_UpdateState::ID); | 948 FrameHostMsg_UpdateState::ID); |
| 951 ASSERT_TRUE(msg_A); | 949 ASSERT_TRUE(msg_A); |
| 952 ViewHostMsg_UpdateState::Param param; | 950 FrameHostMsg_UpdateState::Param param; |
| 953 ViewHostMsg_UpdateState::Read(msg_A, ¶m); | 951 FrameHostMsg_UpdateState::Read(msg_A, ¶m); |
| 954 PageState state_A = std::get<0>(param); | 952 PageState state_A = std::get<0>(param); |
| 955 render_thread_->sink().ClearMessages(); | 953 render_thread_->sink().ClearMessages(); |
| 956 | 954 |
| 957 // Load page C, which will trigger an UpdateState message for page B. | 955 // Load page C, which will trigger an UpdateState message for page B. |
| 958 LoadHTML("<div>Page C</div>"); | 956 LoadHTML("<div>Page C</div>"); |
| 959 | 957 |
| 960 // Check for a valid UpdateState for page B. | 958 // Check for a valid UpdateState for page B. |
| 961 ProcessPendingMessages(); | 959 ProcessPendingMessages(); |
| 962 const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching( | 960 const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching( |
| 963 ViewHostMsg_UpdateState::ID); | 961 FrameHostMsg_UpdateState::ID); |
| 964 ASSERT_TRUE(msg_B); | 962 ASSERT_TRUE(msg_B); |
| 965 ViewHostMsg_UpdateState::Read(msg_B, ¶m); | 963 FrameHostMsg_UpdateState::Read(msg_B, ¶m); |
| 966 PageState state_B = std::get<0>(param); | 964 PageState state_B = std::get<0>(param); |
| 967 EXPECT_NE(state_A, state_B); | 965 EXPECT_NE(state_A, state_B); |
| 968 render_thread_->sink().ClearMessages(); | 966 render_thread_->sink().ClearMessages(); |
| 969 | 967 |
| 970 // Load page D, which will trigger an UpdateState message for page C. | 968 // Load page D, which will trigger an UpdateState message for page C. |
| 971 LoadHTML("<div>Page D</div>"); | 969 LoadHTML("<div>Page D</div>"); |
| 972 | 970 |
| 973 // Check for a valid UpdateState for page C. | 971 // Check for a valid UpdateState for page C. |
| 974 ProcessPendingMessages(); | 972 ProcessPendingMessages(); |
| 975 const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching( | 973 const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching( |
| 976 ViewHostMsg_UpdateState::ID); | 974 FrameHostMsg_UpdateState::ID); |
| 977 ASSERT_TRUE(msg_C); | 975 ASSERT_TRUE(msg_C); |
| 978 ViewHostMsg_UpdateState::Read(msg_C, ¶m); | 976 FrameHostMsg_UpdateState::Read(msg_C, ¶m); |
| 979 PageState state_C = std::get<0>(param); | 977 PageState state_C = std::get<0>(param); |
| 980 EXPECT_NE(state_B, state_C); | 978 EXPECT_NE(state_B, state_C); |
| 981 render_thread_->sink().ClearMessages(); | 979 render_thread_->sink().ClearMessages(); |
| 982 | 980 |
| 983 // Go back to C and commit, preparing for our real test. | 981 // Go back to C and commit, preparing for our real test. |
| 984 CommonNavigationParams common_params_C; | 982 CommonNavigationParams common_params_C; |
| 985 RequestNavigationParams request_params_C; | 983 RequestNavigationParams request_params_C; |
| 986 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 984 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 987 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 985 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 988 request_params_C.current_history_list_length = 4; | 986 request_params_C.current_history_list_length = 4; |
| 989 request_params_C.current_history_list_offset = 3; | 987 request_params_C.current_history_list_offset = 3; |
| 990 request_params_C.pending_history_list_offset = 2; | 988 request_params_C.pending_history_list_offset = 2; |
| 989 request_params_C.nav_entry_id = 3; | |
| 991 request_params_C.page_state = state_C; | 990 request_params_C.page_state = state_C; |
| 992 frame()->Navigate(common_params_C, StartNavigationParams(), request_params_C); | 991 frame()->Navigate(common_params_C, StartNavigationParams(), request_params_C); |
| 993 ProcessPendingMessages(); | 992 ProcessPendingMessages(); |
| 994 render_thread_->sink().ClearMessages(); | 993 render_thread_->sink().ClearMessages(); |
| 995 | 994 |
| 996 // Go back twice quickly, such that page B does not have a chance to commit. | 995 // Go back twice quickly, such that page B does not have a chance to commit. |
| 997 // This leads to two changes to the back/forward list but only one change to | 996 // This leads to two changes to the back/forward list but only one change to |
| 998 // the RenderView's page ID. | 997 // the RenderView's page ID. |
| 999 | 998 |
| 1000 // Back to page B without committing. | 999 // Back to page B without committing. |
| 1001 CommonNavigationParams common_params_B; | 1000 CommonNavigationParams common_params_B; |
| 1002 RequestNavigationParams request_params_B; | 1001 RequestNavigationParams request_params_B; |
| 1003 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1002 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1004 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 1003 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 1005 request_params_B.current_history_list_length = 4; | 1004 request_params_B.current_history_list_length = 4; |
| 1006 request_params_B.current_history_list_offset = 2; | 1005 request_params_B.current_history_list_offset = 2; |
| 1007 request_params_B.pending_history_list_offset = 1; | 1006 request_params_B.pending_history_list_offset = 1; |
| 1007 request_params_B.nav_entry_id = 2; | |
| 1008 request_params_B.page_state = state_B; | 1008 request_params_B.page_state = state_B; |
| 1009 frame()->Navigate(common_params_B, StartNavigationParams(), request_params_B); | 1009 frame()->Navigate(common_params_B, StartNavigationParams(), request_params_B); |
| 1010 | 1010 |
| 1011 // Back to page A and commit. | 1011 // Back to page A and commit. |
| 1012 CommonNavigationParams common_params; | 1012 CommonNavigationParams common_params; |
| 1013 RequestNavigationParams request_params; | 1013 RequestNavigationParams request_params; |
| 1014 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1014 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 1015 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 1015 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 1016 request_params.current_history_list_length = 4; | 1016 request_params.current_history_list_length = 4; |
| 1017 request_params.current_history_list_offset = 2; | 1017 request_params.current_history_list_offset = 2; |
| 1018 request_params.pending_history_list_offset = 0; | 1018 request_params.pending_history_list_offset = 0; |
| 1019 request_params.nav_entry_id = 1; | |
| 1019 request_params.page_state = state_A; | 1020 request_params.page_state = state_A; |
| 1020 frame()->Navigate(common_params, StartNavigationParams(), request_params); | 1021 frame()->Navigate(common_params, StartNavigationParams(), request_params); |
| 1021 ProcessPendingMessages(); | 1022 ProcessPendingMessages(); |
| 1022 | 1023 |
| 1023 // Now ensure that the UpdateState message we receive is consistent | 1024 // Now ensure that the UpdateState message we receive is consistent |
| 1024 // and represents page C in state. | 1025 // and represents page C in state. |
| 1025 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 1026 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
| 1026 ViewHostMsg_UpdateState::ID); | 1027 FrameHostMsg_UpdateState::ID); |
| 1027 ASSERT_TRUE(msg); | 1028 ASSERT_TRUE(msg); |
| 1028 ViewHostMsg_UpdateState::Read(msg, ¶m); | 1029 FrameHostMsg_UpdateState::Read(msg, ¶m); |
| 1029 PageState state = std::get<0>(param); | 1030 PageState state = std::get<0>(param); |
| 1030 EXPECT_NE(state_A, state); | 1031 EXPECT_NE(state_A, state); |
| 1031 EXPECT_NE(state_B, state); | 1032 EXPECT_NE(state_B, state); |
| 1032 EXPECT_EQ(state_C, state); | 1033 EXPECT_EQ(state_C, state); |
| 1033 } | 1034 } |
| 1034 | 1035 |
| 1035 // Test that our IME backend sends a notification message when the input focus | 1036 // Test that our IME backend sends a notification message when the input focus |
| 1036 // changes. | 1037 // changes. |
| 1037 TEST_F(RenderViewImplTest, OnImeTypeChanged) { | 1038 TEST_F(RenderViewImplTest, OnImeTypeChanged) { |
| 1038 // Load an HTML page consisting of two input fields. | 1039 // Load an HTML page consisting of two input fields. |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2565 ExpectPauseAndResume(3); | 2566 ExpectPauseAndResume(3); |
| 2566 blink::WebScriptSource source2( | 2567 blink::WebScriptSource source2( |
| 2567 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2568 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2568 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); | 2569 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); |
| 2569 | 2570 |
| 2570 EXPECT_FALSE(IsPaused()); | 2571 EXPECT_FALSE(IsPaused()); |
| 2571 Detach(); | 2572 Detach(); |
| 2572 } | 2573 } |
| 2573 | 2574 |
| 2574 } // namespace content | 2575 } // namespace content |
| OLD | NEW |