| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 #include "ui/events/test/events_test_utils.h" | 90 #include "ui/events/test/events_test_utils.h" |
| 91 #include "ui/events/test/events_test_utils_x11.h" | 91 #include "ui/events/test/events_test_utils_x11.h" |
| 92 #endif | 92 #endif |
| 93 | 93 |
| 94 #if defined(USE_OZONE) | 94 #if defined(USE_OZONE) |
| 95 #include "ui/events/keycodes/keyboard_code_conversion.h" | 95 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 #include "url/url_constants.h" | 98 #include "url/url_constants.h" |
| 99 | 99 |
| 100 using base::TimeDelta; |
| 100 using blink::WebFrame; | 101 using blink::WebFrame; |
| 101 using blink::WebFrameContentDumper; | 102 using blink::WebFrameContentDumper; |
| 102 using blink::WebInputEvent; | 103 using blink::WebInputEvent; |
| 103 using blink::WebLocalFrame; | 104 using blink::WebLocalFrame; |
| 104 using blink::WebMouseEvent; | 105 using blink::WebMouseEvent; |
| 105 using blink::WebRuntimeFeatures; | 106 using blink::WebRuntimeFeatures; |
| 106 using blink::WebString; | 107 using blink::WebString; |
| 107 using blink::WebTextDirection; | 108 using blink::WebTextDirection; |
| 108 using blink::WebURLError; | 109 using blink::WebURLError; |
| 109 | 110 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 result.unique_name = | 183 result.unique_name = |
| 183 base::UTF16ToUTF8(base::StringPiece16(frame->uniqueName())); | 184 base::UTF16ToUTF8(base::StringPiece16(frame->uniqueName())); |
| 184 result.sandbox_flags = frame->effectiveSandboxFlags(); | 185 result.sandbox_flags = frame->effectiveSandboxFlags(); |
| 185 // result.should_enforce_strict_mixed_content_checking is calculated in the | 186 // result.should_enforce_strict_mixed_content_checking is calculated in the |
| 186 // browser... | 187 // browser... |
| 187 result.origin = frame->getSecurityOrigin(); | 188 result.origin = frame->getSecurityOrigin(); |
| 188 | 189 |
| 189 return result; | 190 return result; |
| 190 } | 191 } |
| 191 | 192 |
| 193 // Returns CommonNavigationParams for a normal navigation to a data: url, with |
| 194 // navigation_start set to Now() plus the given offset. |
| 195 CommonNavigationParams MakeCommonNavigationParams( |
| 196 TimeDelta navigation_start_offset) { |
| 197 CommonNavigationParams params; |
| 198 params.url = GURL("data:text/html,<div>Page</div>"); |
| 199 params.navigation_start = base::TimeTicks::Now() + navigation_start_offset; |
| 200 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 201 params.transition = ui::PAGE_TRANSITION_TYPED; |
| 202 return params; |
| 203 } |
| 204 |
| 192 } // namespace | 205 } // namespace |
| 193 | 206 |
| 194 class RenderViewImplTest : public RenderViewTest { | 207 class RenderViewImplTest : public RenderViewTest { |
| 195 public: | 208 public: |
| 196 RenderViewImplTest() { | 209 RenderViewImplTest() { |
| 197 // Attach a pseudo keyboard device to this object. | 210 // Attach a pseudo keyboard device to this object. |
| 198 mock_keyboard_.reset(new MockKeyboard()); | 211 mock_keyboard_.reset(new MockKeyboard()); |
| 199 } | 212 } |
| 200 | 213 |
| 201 ~RenderViewImplTest() override {} | 214 ~RenderViewImplTest() override {} |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // the pending continuation. | 253 // the pending continuation. |
| 241 FrameLoadWaiter(frame()).Wait(); | 254 FrameLoadWaiter(frame()).Wait(); |
| 242 } | 255 } |
| 243 | 256 |
| 244 template<class T> | 257 template<class T> |
| 245 typename T::Param ProcessAndReadIPC() { | 258 typename T::Param ProcessAndReadIPC() { |
| 246 ProcessPendingMessages(); | 259 ProcessPendingMessages(); |
| 247 const IPC::Message* message = | 260 const IPC::Message* message = |
| 248 render_thread_->sink().GetUniqueMessageMatching(T::ID); | 261 render_thread_->sink().GetUniqueMessageMatching(T::ID); |
| 249 typename T::Param param; | 262 typename T::Param param; |
| 250 T::Read(message, ¶m); | 263 EXPECT_TRUE(message); |
| 264 if (message) |
| 265 T::Read(message, ¶m); |
| 251 return param; | 266 return param; |
| 252 } | 267 } |
| 253 | 268 |
| 254 // Sends IPC messages that emulates a key-press event. | 269 // Sends IPC messages that emulates a key-press event. |
| 255 int SendKeyEvent(MockKeyboard::Layout layout, | 270 int SendKeyEvent(MockKeyboard::Layout layout, |
| 256 int key_code, | 271 int key_code, |
| 257 MockKeyboard::Modifiers modifiers, | 272 MockKeyboard::Modifiers modifiers, |
| 258 base::string16* output) { | 273 base::string16* output) { |
| 259 #if defined(OS_WIN) | 274 #if defined(OS_WIN) |
| 260 // Retrieve the Unicode character for the given tuple (keyboard-layout, | 275 // Retrieve the Unicode character for the given tuple (keyboard-layout, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 const gfx::Size& GetPreferredSize() { | 384 const gfx::Size& GetPreferredSize() { |
| 370 view()->CheckPreferredSize(); | 385 view()->CheckPreferredSize(); |
| 371 return view()->preferred_size_; | 386 return view()->preferred_size_; |
| 372 } | 387 } |
| 373 | 388 |
| 374 void SetZoomLevel(double level) { | 389 void SetZoomLevel(double level) { |
| 375 view()->OnSetZoomLevel( | 390 view()->OnSetZoomLevel( |
| 376 PageMsg_SetZoomLevel_Command::USE_CURRENT_TEMPORARY_MODE, level); | 391 PageMsg_SetZoomLevel_Command::USE_CURRENT_TEMPORARY_MODE, level); |
| 377 } | 392 } |
| 378 | 393 |
| 394 // Closes a view created during the test, i.e. not the |view()|. Checks that |
| 395 // the main frame is detached and deleted, and makes sure the view does not |
| 396 // leak. |
| 397 void CloseRenderView(RenderViewImpl* new_view) { |
| 398 new_view->Close(); |
| 399 EXPECT_FALSE(new_view->GetMainRenderFrame()); |
| 400 |
| 401 new_view->Release(); |
| 402 } |
| 403 |
| 379 private: | 404 private: |
| 380 std::unique_ptr<MockKeyboard> mock_keyboard_; | 405 std::unique_ptr<MockKeyboard> mock_keyboard_; |
| 381 }; | 406 }; |
| 382 | 407 |
| 383 class DevToolsAgentTest : public RenderViewImplTest { | 408 class DevToolsAgentTest : public RenderViewImplTest { |
| 384 public: | 409 public: |
| 385 void Attach() { | 410 void Attach() { |
| 386 notifications_ = std::vector<std::string>(); | 411 notifications_ = std::vector<std::string>(); |
| 387 expecting_pause_ = false; | 412 expecting_pause_ = false; |
| 388 std::string host_id = "host_id"; | 413 std::string host_id = "host_id"; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // after closing it. | 560 // after closing it. |
| 536 TEST_F(RenderViewImplTest, RenderFrameClearedAfterClose) { | 561 TEST_F(RenderViewImplTest, RenderFrameClearedAfterClose) { |
| 537 // Create a new main frame RenderFrame so that we don't interfere with the | 562 // Create a new main frame RenderFrame so that we don't interfere with the |
| 538 // shutdown of frame() in RenderViewTest.TearDown. | 563 // shutdown of frame() in RenderViewTest.TearDown. |
| 539 blink::WebURLRequest popup_request(GURL("http://foo.com")); | 564 blink::WebURLRequest popup_request(GURL("http://foo.com")); |
| 540 blink::WebView* new_web_view = view()->createView( | 565 blink::WebView* new_web_view = view()->createView( |
| 541 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", | 566 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", |
| 542 blink::WebNavigationPolicyNewForegroundTab, false); | 567 blink::WebNavigationPolicyNewForegroundTab, false); |
| 543 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); | 568 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); |
| 544 | 569 |
| 545 // Close the view, causing the main RenderFrame to be detached and deleted. | 570 // Checks that the frame is deleted properly and cleans up the view. |
| 546 new_view->Close(); | 571 CloseRenderView(new_view); |
| 547 EXPECT_FALSE(new_view->GetMainRenderFrame()); | |
| 548 | |
| 549 // Clean up after the new view so we don't leak it. | |
| 550 new_view->Release(); | |
| 551 } | 572 } |
| 552 | 573 |
| 553 // Test that we get form state change notifications when input fields change. | 574 // Test that we get form state change notifications when input fields change. |
| 554 TEST_F(RenderViewImplTest, OnNavStateChanged) { | 575 TEST_F(RenderViewImplTest, OnNavStateChanged) { |
| 555 view()->set_send_content_state_immediately(true); | 576 view()->set_send_content_state_immediately(true); |
| 556 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); | 577 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); |
| 557 | 578 |
| 558 // We should NOT have gotten a form state change notification yet. | 579 // We should NOT have gotten a form state change notification yet. |
| 559 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 580 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 560 FrameHostMsg_UpdateState::ID)); | 581 FrameHostMsg_UpdateState::ID)); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", | 838 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", |
| 818 blink::WebNavigationPolicyNewForegroundTab, false); | 839 blink::WebNavigationPolicyNewForegroundTab, false); |
| 819 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); | 840 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); |
| 820 blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request); | 841 blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request); |
| 821 popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked; | 842 popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked; |
| 822 popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab; | 843 popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab; |
| 823 policy = static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame())-> | 844 policy = static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame())-> |
| 824 decidePolicyForNavigation(popup_policy_info); | 845 decidePolicyForNavigation(popup_policy_info); |
| 825 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); | 846 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
| 826 | 847 |
| 827 // Clean up after the new view so we don't leak it. | 848 CloseRenderView(new_view); |
| 828 new_view->Close(); | |
| 829 new_view->Release(); | |
| 830 } | 849 } |
| 831 | 850 |
| 832 // Verify that security origins are replicated properly to RenderFrameProxies | 851 // Verify that security origins are replicated properly to RenderFrameProxies |
| 833 // when swapping out. | 852 // when swapping out. |
| 834 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { | 853 TEST_F(RenderViewImplTest, OriginReplicationForSwapOut) { |
| 835 // This test should only run with --site-per-process, since origin | 854 // This test should only run with --site-per-process, since origin |
| 836 // replication only happens in that mode. | 855 // replication only happens in that mode. |
| 837 if (!AreAllSitesIsolatedForTesting()) | 856 if (!AreAllSitesIsolatedForTesting()) |
| 838 return; | 857 return; |
| 839 | 858 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 // Respond to a swap out request. | 966 // Respond to a swap out request. |
| 948 TestRenderFrame* new_main_frame = | 967 TestRenderFrame* new_main_frame = |
| 949 static_cast<TestRenderFrame*>(new_view->GetMainRenderFrame()); | 968 static_cast<TestRenderFrame*>(new_view->GetMainRenderFrame()); |
| 950 new_main_frame->SwapOut( | 969 new_main_frame->SwapOut( |
| 951 kProxyRoutingId, true, | 970 kProxyRoutingId, true, |
| 952 ReconstructReplicationStateForTesting(new_main_frame)); | 971 ReconstructReplicationStateForTesting(new_main_frame)); |
| 953 | 972 |
| 954 // Simulate getting painted after swapping out. | 973 // Simulate getting painted after swapping out. |
| 955 new_view->DidFlushPaint(); | 974 new_view->DidFlushPaint(); |
| 956 | 975 |
| 957 new_view->Close(); | 976 CloseRenderView(new_view); |
| 958 new_view->Release(); | |
| 959 } | 977 } |
| 960 | 978 |
| 961 // Verify that the renderer process doesn't crash when device scale factor | 979 // Verify that the renderer process doesn't crash when device scale factor |
| 962 // changes after a cross-process navigation has commited. | 980 // changes after a cross-process navigation has commited. |
| 963 // See https://crbug.com/571603. | 981 // See https://crbug.com/571603. |
| 964 TEST_F(RenderViewImplTest, SetZoomLevelAfterCrossProcessNavigation) { | 982 TEST_F(RenderViewImplTest, SetZoomLevelAfterCrossProcessNavigation) { |
| 965 // This test should only run with out-of-process iframes enabled. | 983 // This test should only run with out-of-process iframes enabled. |
| 966 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 984 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 967 return; | 985 return; |
| 968 | 986 |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 | 2037 |
| 2020 frame()->SetAccessibilityMode(AccessibilityModeOff); | 2038 frame()->SetAccessibilityMode(AccessibilityModeOff); |
| 2021 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); | 2039 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); |
| 2022 ASSERT_FALSE(frame()->render_accessibility()); | 2040 ASSERT_FALSE(frame()->render_accessibility()); |
| 2023 | 2041 |
| 2024 frame()->SetAccessibilityMode(AccessibilityModeComplete); | 2042 frame()->SetAccessibilityMode(AccessibilityModeComplete); |
| 2025 ASSERT_EQ(AccessibilityModeComplete, frame()->accessibility_mode()); | 2043 ASSERT_EQ(AccessibilityModeComplete, frame()->accessibility_mode()); |
| 2026 ASSERT_TRUE(frame()->render_accessibility()); | 2044 ASSERT_TRUE(frame()->render_accessibility()); |
| 2027 } | 2045 } |
| 2028 | 2046 |
| 2047 // Checks that when a navigation starts in the renderer, |navigation_start| is |
| 2048 // recorded at an appropriate time and is passed in the corresponding message. |
| 2049 TEST_F(RenderViewImplTest, RendererNavigationStartTransmittedToBrowser) { |
| 2050 base::TimeTicks lower_bound_navigation_start(base::TimeTicks::Now()); |
| 2051 frame()->GetWebFrame()->loadHTMLString( |
| 2052 "hello world", blink::WebURL(GURL("data:text/html,"))); |
| 2053 |
| 2054 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = |
| 2055 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2056 base::TimeTicks transmitted_start = std::get<1>(host_nav_params); |
| 2057 EXPECT_FALSE(transmitted_start.is_null()); |
| 2058 EXPECT_LT(lower_bound_navigation_start, transmitted_start); |
| 2059 } |
| 2060 |
| 2061 // Checks that a browser-initiated navigation in an initial document that was |
| 2062 // not accessed uses browser-side timestamp. |
| 2063 // This test assumes that |frame()| contains an unaccessed initial document at |
| 2064 // start. |
| 2065 TEST_F(RenderViewImplTest, BrowserNavigationStart) { |
| 2066 auto common_params = MakeCommonNavigationParams(-TimeDelta::FromSeconds(1)); |
| 2067 |
| 2068 frame()->Navigate(common_params, StartNavigationParams(), |
| 2069 RequestNavigationParams()); |
| 2070 FrameHostMsg_DidStartProvisionalLoad::Param nav_params = |
| 2071 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2072 EXPECT_EQ(common_params.navigation_start, std::get<1>(nav_params)); |
| 2073 } |
| 2074 |
| 2029 // Sanity check for the Navigation Timing API |navigationStart| override. We | 2075 // Sanity check for the Navigation Timing API |navigationStart| override. We |
| 2030 // are asserting only most basic constraints, as TimeTicks (passed as the | 2076 // are asserting only most basic constraints, as TimeTicks (passed as the |
| 2031 // override) are not comparable with the wall time (returned by the Blink API). | 2077 // override) are not comparable with the wall time (returned by the Blink API). |
| 2032 TEST_F(RenderViewImplTest, NavigationStartOverride) { | 2078 TEST_F(RenderViewImplTest, BrowserNavigationStartSanitized) { |
| 2033 // Verify that a navigation that claims to have started in the future - 42 | 2079 // Verify that a navigation that claims to have started in the future - 42 |
| 2034 // days from now is *not* reported as one that starts in the future; as we | 2080 // days from now is *not* reported as one that starts in the future; as we |
| 2035 // sanitize the override allowing a maximum of ::Now(). | 2081 // sanitize the override allowing a maximum of ::Now(). |
| 2036 CommonNavigationParams late_common_params; | 2082 auto late_common_params = MakeCommonNavigationParams(TimeDelta::FromDays(42)); |
| 2037 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); | |
| 2038 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
| 2039 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; | |
| 2040 late_common_params.navigation_start = | |
| 2041 base::TimeTicks::Now() + base::TimeDelta::FromDays(42); | |
| 2042 late_common_params.method = "POST"; | 2083 late_common_params.method = "POST"; |
| 2043 | 2084 |
| 2044 frame()->Navigate(late_common_params, StartNavigationParams(), | 2085 frame()->Navigate(late_common_params, StartNavigationParams(), |
| 2045 RequestNavigationParams()); | 2086 RequestNavigationParams()); |
| 2046 ProcessPendingMessages(); | 2087 ProcessPendingMessages(); |
| 2047 base::Time after_navigation = | 2088 base::Time after_navigation = |
| 2048 base::Time::Now() + base::TimeDelta::FromDays(1); | 2089 base::Time::Now() + base::TimeDelta::FromDays(1); |
| 2049 | 2090 |
| 2050 base::Time late_nav_reported_start = | 2091 base::Time late_nav_reported_start = |
| 2051 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2092 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
| 2052 EXPECT_LE(late_nav_reported_start, after_navigation); | 2093 EXPECT_LE(late_nav_reported_start, after_navigation); |
| 2053 } | 2094 } |
| 2054 | 2095 |
| 2055 TEST_F(RenderViewImplTest, RendererNavigationStartTransmittedToBrowser) { | 2096 // Checks that a browser-initiated navigation in an initial document that has |
| 2056 base::TimeTicks lower_bound_navigation_start; | 2097 // been accessed does not use browser-side timestamp (there may be arbitrary |
| 2057 frame()->GetWebFrame()->loadHTMLString( | 2098 // content and/or scripts injected, including beforeunload handler that shows |
| 2058 "hello world", blink::WebURL(GURL("data:text/html,"))); | 2099 // a confirmation dialog). |
| 2059 ProcessPendingMessages(); | 2100 // If PlzNavigate is enabled, browser-side timestamp is always used. |
| 2060 const IPC::Message* frame_navigate_msg = | 2101 TEST_F(RenderViewImplTest, NavigationStartWhenInitialDocumentWasAccessed) { |
| 2061 render_thread_->sink().GetUniqueMessageMatching( | 2102 // Trigger a didAccessInitialDocument notification. |
| 2062 FrameHostMsg_DidStartProvisionalLoad::ID); | 2103 ExecuteJavaScriptForTests("document.title = 'Hi!';"); |
| 2063 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params; | 2104 |
| 2064 FrameHostMsg_DidStartProvisionalLoad::Read(frame_navigate_msg, | 2105 auto common_params = MakeCommonNavigationParams(-TimeDelta::FromSeconds(1)); |
| 2065 &host_nav_params); | 2106 frame()->Navigate(common_params, StartNavigationParams(), |
| 2066 base::TimeTicks transmitted_start = std::get<1>(host_nav_params); | 2107 RequestNavigationParams()); |
| 2067 EXPECT_FALSE(transmitted_start.is_null()); | 2108 |
| 2068 EXPECT_LT(lower_bound_navigation_start, transmitted_start); | 2109 FrameHostMsg_DidStartProvisionalLoad::Param nav_params = |
| 2110 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2111 if (!IsBrowserSideNavigationEnabled()) |
| 2112 EXPECT_GT(std::get<1>(nav_params), common_params.navigation_start); |
| 2113 else |
| 2114 EXPECT_EQ(common_params.navigation_start, std::get<1>(nav_params)); |
| 2069 } | 2115 } |
| 2070 | 2116 |
| 2071 TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForReload) { | 2117 TEST_F(RenderViewImplTest, NavigationStartForReload) { |
| 2072 const char url_string[] = "data:text/html,<div>Page</div>"; | 2118 const char url_string[] = "data:text/html,<div>Page</div>"; |
| 2073 // Navigate once, then reload. | 2119 // Navigate once, then reload. |
| 2074 LoadHTML(url_string); | 2120 LoadHTML(url_string); |
| 2075 ProcessPendingMessages(); | 2121 ProcessPendingMessages(); |
| 2076 render_thread_->sink().ClearMessages(); | 2122 render_thread_->sink().ClearMessages(); |
| 2077 | 2123 |
| 2078 CommonNavigationParams common_params; | 2124 CommonNavigationParams common_params; |
| 2079 common_params.url = GURL(url_string); | 2125 common_params.url = GURL(url_string); |
| 2080 common_params.navigation_type = | 2126 common_params.navigation_type = |
| 2081 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 2127 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
| 2082 common_params.transition = ui::PAGE_TRANSITION_RELOAD; | 2128 common_params.transition = ui::PAGE_TRANSITION_RELOAD; |
| 2083 | 2129 |
| 2130 // The browser navigation_start should not be used because beforeunload will |
| 2131 // be fired during Navigate. |
| 2084 frame()->Navigate(common_params, StartNavigationParams(), | 2132 frame()->Navigate(common_params, StartNavigationParams(), |
| 2085 RequestNavigationParams()); | 2133 RequestNavigationParams()); |
| 2086 | 2134 |
| 2087 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = | 2135 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = |
| 2088 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); | 2136 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2089 // The true timestamp is later than the browser initiated one. | 2137 |
| 2090 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params), | 2138 if (!IsBrowserSideNavigationEnabled()) { |
| 2091 common_params.navigation_start); | 2139 // The browser navigation_start should not be used because beforeunload was |
| 2140 // fired during Navigate. |
| 2141 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params), |
| 2142 common_params.navigation_start); |
| 2143 } else { |
| 2144 // PlzNavigate: the browser navigation_start is always used. |
| 2145 EXPECT_EQ(common_params.navigation_start, std::get<1>(host_nav_params)); |
| 2146 } |
| 2092 } | 2147 } |
| 2093 | 2148 |
| 2094 TEST_F(RenderViewImplTest, BrowserNavigationStartNotUsedForHistoryNavigation) { | 2149 TEST_F(RenderViewImplTest, NavigationStartForSameProcessHistoryNavigation) { |
| 2095 LoadHTML("<div id=pagename>Page A</div>"); | 2150 LoadHTML("<div id=pagename>Page A</div>"); |
| 2096 LoadHTML("<div id=pagename>Page B</div>"); | 2151 LoadHTML("<div id=pagename>Page B</div>"); |
| 2097 PageState back_state = GetCurrentPageState(); | 2152 PageState back_state = GetCurrentPageState(); |
| 2098 LoadHTML("<div id=pagename>Page C</div>"); | 2153 LoadHTML("<div id=pagename>Page C</div>"); |
| 2099 PageState forward_state = GetCurrentPageState(); | 2154 PageState forward_state = GetCurrentPageState(); |
| 2100 ProcessPendingMessages(); | 2155 ProcessPendingMessages(); |
| 2101 render_thread_->sink().ClearMessages(); | 2156 render_thread_->sink().ClearMessages(); |
| 2102 | 2157 |
| 2103 // Go back. | 2158 // Go back. |
| 2104 CommonNavigationParams common_params_back; | 2159 CommonNavigationParams common_params_back; |
| 2105 common_params_back.url = | 2160 common_params_back.url = |
| 2106 GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"); | 2161 GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"); |
| 2107 common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 2162 common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 2108 GoToOffsetWithParams(-1, back_state, common_params_back, | 2163 GoToOffsetWithParams(-1, back_state, common_params_back, |
| 2109 StartNavigationParams(), RequestNavigationParams()); | 2164 StartNavigationParams(), RequestNavigationParams()); |
| 2110 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = | 2165 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = |
| 2111 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); | 2166 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2112 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params), | 2167 if (!IsBrowserSideNavigationEnabled()) { |
| 2113 common_params_back.navigation_start); | 2168 // The browser navigation_start should not be used because beforeunload was |
| 2169 // fired during GoToOffsetWithParams. |
| 2170 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params), |
| 2171 common_params_back.navigation_start); |
| 2172 } else { |
| 2173 // PlzNavigate: the browser navigation_start is always used. |
| 2174 EXPECT_EQ(common_params_back.navigation_start, |
| 2175 std::get<1>(host_nav_params)); |
| 2176 } |
| 2114 render_thread_->sink().ClearMessages(); | 2177 render_thread_->sink().ClearMessages(); |
| 2115 | 2178 |
| 2116 // Go forward. | 2179 // Go forward. |
| 2117 CommonNavigationParams common_params_forward; | 2180 CommonNavigationParams common_params_forward; |
| 2118 common_params_forward.url = | 2181 common_params_forward.url = |
| 2119 GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>"); | 2182 GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>"); |
| 2120 common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 2183 common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 2121 GoToOffsetWithParams(1, forward_state, common_params_forward, | 2184 GoToOffsetWithParams(1, forward_state, common_params_forward, |
| 2122 StartNavigationParams(), RequestNavigationParams()); | 2185 StartNavigationParams(), RequestNavigationParams()); |
| 2123 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 = | 2186 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 = |
| 2124 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); | 2187 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2125 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params2), | 2188 if (!IsBrowserSideNavigationEnabled()) { |
| 2126 common_params_forward.navigation_start); | 2189 EXPECT_PRED2(TimeTicksGT, std::get<1>(host_nav_params2), |
| 2190 common_params_forward.navigation_start); |
| 2191 } else { |
| 2192 EXPECT_EQ(common_params_forward.navigation_start, |
| 2193 std::get<1>(host_nav_params2)); |
| 2194 } |
| 2127 } | 2195 } |
| 2128 | 2196 |
| 2129 TEST_F(RenderViewImplTest, BrowserNavigationStartSuccessfullyTransmitted) { | 2197 TEST_F(RenderViewImplTest, NavigationStartForCrossProcessHistoryNavigation) { |
| 2130 CommonNavigationParams common_params; | 2198 auto common_params = MakeCommonNavigationParams(-TimeDelta::FromSeconds(1)); |
| 2131 common_params.url = GURL("data:text/html,<div>Page</div>"); | 2199 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 2132 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
| 2133 common_params.transition = ui::PAGE_TRANSITION_TYPED; | |
| 2134 | 2200 |
| 2135 frame()->Navigate(common_params, StartNavigationParams(), | 2201 RequestNavigationParams request_params; |
| 2136 RequestNavigationParams()); | 2202 request_params.page_state = |
| 2203 PageState::CreateForTesting(common_params.url, false, nullptr, nullptr); |
| 2204 request_params.page_id = 1; |
| 2205 request_params.nav_entry_id = 42; |
| 2206 request_params.pending_history_list_offset = 1; |
| 2207 request_params.current_history_list_offset = 0; |
| 2208 request_params.current_history_list_length = 1; |
| 2209 frame()->Navigate(common_params, StartNavigationParams(), request_params); |
| 2137 | 2210 |
| 2138 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = | 2211 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = |
| 2139 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); | 2212 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
| 2140 EXPECT_EQ(std::get<1>(host_nav_params), common_params.navigation_start); | 2213 EXPECT_EQ(std::get<1>(host_nav_params), common_params.navigation_start); |
| 2141 } | 2214 } |
| 2142 | 2215 |
| 2143 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { | 2216 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { |
| 2144 LoadHTML("<body style='margin:0;'><div style='display:inline-block; " | 2217 LoadHTML("<body style='margin:0;'><div style='display:inline-block; " |
| 2145 "width:400px; height:400px;'/></body>"); | 2218 "width:400px; height:400px;'/></body>"); |
| 2146 view()->webview()->mainFrame()->setCanHaveScrollbars(false); | 2219 view()->webview()->mainFrame()->setCanHaveScrollbars(false); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 ExpectPauseAndResume(3); | 2556 ExpectPauseAndResume(3); |
| 2484 blink::WebScriptSource source2( | 2557 blink::WebScriptSource source2( |
| 2485 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2558 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2486 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); | 2559 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); |
| 2487 | 2560 |
| 2488 EXPECT_FALSE(IsPaused()); | 2561 EXPECT_FALSE(IsPaused()); |
| 2489 Detach(); | 2562 Detach(); |
| 2490 } | 2563 } |
| 2491 | 2564 |
| 2492 } // namespace content | 2565 } // namespace content |
| OLD | NEW |