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

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

Issue 384503009: Amend sanitization of browser-side navigationStart override. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a browsertest for the navigationStart override. Created 6 years, 5 months 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 | Annotate | Revision Log
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/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "net/cert/cert_status_flags.h" 42 #include "net/cert/cert_status_flags.h"
43 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
44 #include "third_party/WebKit/public/platform/WebData.h" 44 #include "third_party/WebKit/public/platform/WebData.h"
45 #include "third_party/WebKit/public/platform/WebHTTPBody.h" 45 #include "third_party/WebKit/public/platform/WebHTTPBody.h"
46 #include "third_party/WebKit/public/platform/WebString.h" 46 #include "third_party/WebKit/public/platform/WebString.h"
47 #include "third_party/WebKit/public/platform/WebURLResponse.h" 47 #include "third_party/WebKit/public/platform/WebURLResponse.h"
48 #include "third_party/WebKit/public/web/WebDataSource.h" 48 #include "third_party/WebKit/public/web/WebDataSource.h"
49 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 49 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
50 #include "third_party/WebKit/public/web/WebHistoryItem.h" 50 #include "third_party/WebKit/public/web/WebHistoryItem.h"
51 #include "third_party/WebKit/public/web/WebLocalFrame.h" 51 #include "third_party/WebKit/public/web/WebLocalFrame.h"
52 #include "third_party/WebKit/public/web/WebPerformance.h"
52 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 53 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
53 #include "third_party/WebKit/public/web/WebView.h" 54 #include "third_party/WebKit/public/web/WebView.h"
54 #include "third_party/WebKit/public/web/WebWindowFeatures.h" 55 #include "third_party/WebKit/public/web/WebWindowFeatures.h"
55 #include "ui/events/keycodes/keyboard_codes.h" 56 #include "ui/events/keycodes/keyboard_codes.h"
56 #include "ui/gfx/codec/jpeg_codec.h" 57 #include "ui/gfx/codec/jpeg_codec.h"
57 #include "ui/gfx/range/range.h" 58 #include "ui/gfx/range/range.h"
58 59
59 #if defined(USE_AURA) 60 #if defined(USE_AURA)
60 #include "ui/events/event.h" 61 #include "ui/events/event.h"
61 #endif 62 #endif
(...skipping 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 EXPECT_EQ(params.viewSize.width, width); 2383 EXPECT_EQ(params.viewSize.width, width);
2383 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height)); 2384 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height));
2384 EXPECT_EQ(params.viewSize.height, height); 2385 EXPECT_EQ(params.viewSize.height, height);
2385 2386
2386 view()->DisableScreenMetricsEmulation(); 2387 view()->DisableScreenMetricsEmulation();
2387 2388
2388 view()->EnableScreenMetricsEmulation(params); 2389 view()->EnableScreenMetricsEmulation(params);
2389 // Don't disable here to test that emulation is being shutdown properly. 2390 // Don't disable here to test that emulation is being shutdown properly.
2390 } 2391 }
2391 2392
2393 // Sanity checks for the Navigation Timing API |navigationStart| override. We
2394 // are asserting only most basic constraints, as TimeTicks (passed as the
2395 // override) are not comparable with the wall time (returned by the Blink API).
2396 TEST_F(RenderViewImplTest, NavigationStartOverride) {
2397 // Verify that a navigation that claims to have started at the earliest
2398 // possible TimeTicks is indeed reported as one that started before
2399 // OnNavigate() is called.
2400 base::Time before_navigation = base::Time::Now();
2401 FrameMsg_Navigate_Params early_nav_params;
2402 early_nav_params.url = GURL("data:text/html,<div>Page</div>");
2403 early_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2404 early_nav_params.transition = PAGE_TRANSITION_TYPED;
2405 early_nav_params.page_id = -1;
2406 early_nav_params.is_post = true;
2407 early_nav_params.browser_navigation_start =
2408 base::TimeTicks::FromInternalValue(1);
2409
2410 frame()->OnNavigate(early_nav_params);
2411 ProcessPendingMessages();
2412
2413 base::Time early_nav_reported_start =
2414 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2415 EXPECT_LT(early_nav_reported_start, before_navigation);
2416
2417 // Verify that a navigation that claims to have started in the future - 42
2418 // days from now is *not* reported as one that starts in the future; as we
2419 // sanitize the override allowing a maximum of ::Now().
2420 FrameMsg_Navigate_Params late_nav_params;
2421 late_nav_params.url = GURL("data:text/html,<div>Another page</div>");
2422 late_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2423 late_nav_params.transition = PAGE_TRANSITION_TYPED;
2424 late_nav_params.page_id = -1;
2425 late_nav_params.is_post = true;
2426 late_nav_params.browser_navigation_start =
2427 base::TimeTicks::Now() + base::TimeDelta::FromDays(42);
2428
2429 frame()->OnNavigate(late_nav_params);
2430 ProcessPendingMessages();
2431 base::Time after_navigation =
2432 base::Time::Now() + base::TimeDelta::FromDays(1);
2433
2434 base::Time late_nav_reported_start =
2435 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2436 EXPECT_LE(late_nav_reported_start, after_navigation);
2437 }
2438
2392 } // namespace content 2439 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698