Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1425823002: (DEPRECATED) Send navigation_start to browser process in DidStartProvisionalLoad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop calling didCreateDataSource for same-page navs Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 TEST_F(RenderViewImplTest, NavigateSubframe) { 1904 TEST_F(RenderViewImplTest, NavigateSubframe) {
1905 // Load page A. 1905 // Load page A.
1906 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); 1906 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>");
1907 1907
1908 // Navigate the frame only. 1908 // Navigate the frame only.
1909 CommonNavigationParams common_params; 1909 CommonNavigationParams common_params;
1910 RequestNavigationParams request_params; 1910 RequestNavigationParams request_params;
1911 common_params.url = GURL("data:text/html,world"); 1911 common_params.url = GURL("data:text/html,world");
1912 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1912 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1913 common_params.transition = ui::PAGE_TRANSITION_TYPED; 1913 common_params.transition = ui::PAGE_TRANSITION_TYPED;
1914 common_params.navigation_start = base::TimeTicks::FromInternalValue(1);
1914 request_params.current_history_list_length = 1; 1915 request_params.current_history_list_length = 1;
1915 request_params.current_history_list_offset = 0; 1916 request_params.current_history_list_offset = 0;
1916 request_params.pending_history_list_offset = 1; 1917 request_params.pending_history_list_offset = 1;
1917 request_params.page_id = -1; 1918 request_params.page_id = -1;
1918 request_params.browser_navigation_start =
1919 base::TimeTicks::FromInternalValue(1);
1920 1919
1921 TestRenderFrame* subframe = 1920 TestRenderFrame* subframe =
1922 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( 1921 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame(
1923 view()->webview()->findFrameByName("frame"))); 1922 view()->webview()->findFrameByName("frame")));
1924 subframe->Navigate(common_params, StartNavigationParams(), request_params); 1923 subframe->Navigate(common_params, StartNavigationParams(), request_params);
1925 FrameLoadWaiter(subframe).Wait(); 1924 FrameLoadWaiter(subframe).Wait();
1926 1925
1927 // Copy the document content to std::wstring and compare with the 1926 // Copy the document content to std::wstring and compare with the
1928 // expected result. 1927 // expected result.
1929 const int kMaxOutputCharacters = 256; 1928 const int kMaxOutputCharacters = 256;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 // Verify that a navigation that claims to have started at the earliest 2269 // Verify that a navigation that claims to have started at the earliest
2271 // possible TimeTicks is indeed reported as one that started before 2270 // possible TimeTicks is indeed reported as one that started before
2272 // OnNavigate() is called. 2271 // OnNavigate() is called.
2273 base::Time before_navigation = base::Time::Now(); 2272 base::Time before_navigation = base::Time::Now();
2274 CommonNavigationParams early_common_params; 2273 CommonNavigationParams early_common_params;
2275 StartNavigationParams early_start_params; 2274 StartNavigationParams early_start_params;
2276 RequestNavigationParams early_request_params; 2275 RequestNavigationParams early_request_params;
2277 early_common_params.url = GURL("data:text/html,<div>Page</div>"); 2276 early_common_params.url = GURL("data:text/html,<div>Page</div>");
2278 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2277 early_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2279 early_common_params.transition = ui::PAGE_TRANSITION_TYPED; 2278 early_common_params.transition = ui::PAGE_TRANSITION_TYPED;
2279 early_common_params.navigation_start = base::TimeTicks::FromInternalValue(1);
2280 early_start_params.is_post = true; 2280 early_start_params.is_post = true;
2281 early_request_params.browser_navigation_start =
2282 base::TimeTicks::FromInternalValue(1);
2283 2281
2284 frame()->Navigate(early_common_params, early_start_params, 2282 frame()->Navigate(early_common_params, early_start_params,
2285 early_request_params); 2283 early_request_params);
2286 ProcessPendingMessages(); 2284 ProcessPendingMessages();
2287 2285
2288 base::Time early_nav_reported_start = 2286 base::Time early_nav_reported_start =
2289 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2287 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2290 EXPECT_LT(early_nav_reported_start, before_navigation); 2288 EXPECT_LT(early_nav_reported_start, before_navigation);
2291 2289
2292 // Verify that a navigation that claims to have started in the future - 42 2290 // Verify that a navigation that claims to have started in the future - 42
2293 // days from now is *not* reported as one that starts in the future; as we 2291 // days from now is *not* reported as one that starts in the future; as we
2294 // sanitize the override allowing a maximum of ::Now(). 2292 // sanitize the override allowing a maximum of ::Now().
2295 CommonNavigationParams late_common_params; 2293 CommonNavigationParams late_common_params;
2296 RequestNavigationParams late_request_params; 2294 RequestNavigationParams late_request_params;
2297 StartNavigationParams late_start_params; 2295 StartNavigationParams late_start_params;
2298 late_common_params.url = GURL("data:text/html,<div>Another page</div>"); 2296 late_common_params.url = GURL("data:text/html,<div>Another page</div>");
2299 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2297 late_common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2300 late_common_params.transition = ui::PAGE_TRANSITION_TYPED; 2298 late_common_params.transition = ui::PAGE_TRANSITION_TYPED;
2299 late_common_params.navigation_start =
2300 base::TimeTicks::Now() + base::TimeDelta::FromDays(42);
2301 late_start_params.is_post = true; 2301 late_start_params.is_post = true;
2302 late_request_params.browser_navigation_start =
2303 base::TimeTicks::Now() + base::TimeDelta::FromDays(42);
2304 2302
2305 frame()->Navigate(late_common_params, late_start_params, late_request_params); 2303 frame()->Navigate(late_common_params, late_start_params, late_request_params);
2306 ProcessPendingMessages(); 2304 ProcessPendingMessages();
2307 base::Time after_navigation = 2305 base::Time after_navigation =
2308 base::Time::Now() + base::TimeDelta::FromDays(1); 2306 base::Time::Now() + base::TimeDelta::FromDays(1);
2309 2307
2310 base::Time late_nav_reported_start = 2308 base::Time late_nav_reported_start =
2311 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2309 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2312 EXPECT_LE(late_nav_reported_start, after_navigation); 2310 EXPECT_LE(late_nav_reported_start, after_navigation);
2313 } 2311 }
2314 2312
2313 TEST_F(RenderViewImplTest, BrowserNavigationStartSuccessfullyTransmitted) {
2314 CommonNavigationParams common_params;
2315 StartNavigationParams start_params;
2316 RequestNavigationParams request_params;
2317 common_params.url = GURL("data:text/html,<div>Page</div>");
2318 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2319 common_params.transition = ui::PAGE_TRANSITION_TYPED;
2320 start_params.is_post = true;
2321
2322 // Data munching to simulate what we do in blink: convert navigation_start to
2323 // a double for DocumentLoadTiming, then back to a TimeTicks to send back to
2324 // the browser in FrameHostMsg_DidStartProvisionalLoadForFrame.
2325 double navigation_start_seconds =
2326 (common_params.navigation_start - base::TimeTicks()).InSecondsF();
2327 base::TimeTicks adjusted_navigation_start =
2328 base::TimeTicks::FromInternalValue(navigation_start_seconds *
2329 base::Time::kMicrosecondsPerSecond);
2330
2331 frame()->Navigate(common_params, start_params, request_params);
2332 ProcessPendingMessages();
2333
2334 const IPC::Message* frame_navigate_msg =
2335 render_thread_->sink().GetUniqueMessageMatching(
2336 FrameHostMsg_DidStartProvisionalLoadForFrame::ID);
2337 FrameHostMsg_DidStartProvisionalLoadForFrame::Param host_nav_params;
2338 FrameHostMsg_DidStartProvisionalLoadForFrame::Read(frame_navigate_msg,
2339 &host_nav_params);
2340 EXPECT_EQ(base::get<1>(host_nav_params), adjusted_navigation_start);
2341 }
2342
2315 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { 2343 TEST_F(RenderViewImplTest, PreferredSizeZoomed) {
2316 LoadHTML("<body style='margin:0;'><div style='display:inline-block; " 2344 LoadHTML("<body style='margin:0;'><div style='display:inline-block; "
2317 "width:400px; height:400px;'/></body>"); 2345 "width:400px; height:400px;'/></body>");
2318 view()->webview()->mainFrame()->setCanHaveScrollbars(false); 2346 view()->webview()->mainFrame()->setCanHaveScrollbars(false);
2319 EnablePreferredSizeMode(); 2347 EnablePreferredSizeMode();
2320 2348
2321 gfx::Size size = GetPreferredSize(); 2349 gfx::Size size = GetPreferredSize();
2322 EXPECT_EQ(gfx::Size(400, 400), size); 2350 EXPECT_EQ(gfx::Size(400, 400), size);
2323 2351
2324 SetZoomLevel(ZoomFactorToZoomLevel(2.0)); 2352 SetZoomLevel(ZoomFactorToZoomLevel(2.0));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 FROM_HERE, 2410 FROM_HERE,
2383 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2411 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2384 ExecuteJavaScriptForTests("debugger;"); 2412 ExecuteJavaScriptForTests("debugger;");
2385 2413
2386 // CloseWhilePaused should resume execution and continue here. 2414 // CloseWhilePaused should resume execution and continue here.
2387 EXPECT_FALSE(IsPaused()); 2415 EXPECT_FALSE(IsPaused());
2388 Detach(); 2416 Detach();
2389 } 2417 }
2390 2418
2391 } // namespace content 2419 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698