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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 1427633004: Send navigation_start to the browser in DidStartProvisionalLoad IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation_start_renderer
Patch Set: Remove public method from NavigationHandle until consumers need it 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 3264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 contents()->GetFrameTree()->root()->navigator(); 3275 contents()->GetFrameTree()->root()->navigator();
3276 3276
3277 const GURL url1("nonexistent:12121"); 3277 const GURL url1("nonexistent:12121");
3278 const GURL url1_fixed("http://nonexistent:12121/"); 3278 const GURL url1_fixed("http://nonexistent:12121/");
3279 const GURL url2("http://foo"); 3279 const GURL url2("http://foo");
3280 3280
3281 // We create pending entries for renderer-initiated navigations so that we 3281 // We create pending entries for renderer-initiated navigations so that we
3282 // can show them in new tabs when it is safe. 3282 // can show them in new tabs when it is safe.
3283 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false); 3283 main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, false);
3284 main_test_rfh()->PrepareForCommit(); 3284 main_test_rfh()->PrepareForCommit();
3285 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); 3285 navigator->DidStartProvisionalLoad(main_test_rfh(), url1,
3286 base::TimeTicks::Now());
3286 3287
3287 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing 3288 // Simulate what happens if a BrowserURLHandler rewrites the URL, causing
3288 // the virtual URL to differ from the URL. 3289 // the virtual URL to differ from the URL.
3289 controller.GetPendingEntry()->SetURL(url1_fixed); 3290 controller.GetPendingEntry()->SetURL(url1_fixed);
3290 controller.GetPendingEntry()->SetVirtualURL(url1); 3291 controller.GetPendingEntry()->SetVirtualURL(url1);
3291 3292
3292 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL()); 3293 EXPECT_EQ(url1_fixed, controller.GetPendingEntry()->GetURL());
3293 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL()); 3294 EXPECT_EQ(url1, controller.GetPendingEntry()->GetVirtualURL());
3294 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated()); 3295 EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated());
3295 3296
3296 // If the user clicks another link, we should replace the pending entry. 3297 // If the user clicks another link, we should replace the pending entry.
3297 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); 3298 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
3298 main_test_rfh()->PrepareForCommit(); 3299 main_test_rfh()->PrepareForCommit();
3299 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); 3300 navigator->DidStartProvisionalLoad(main_test_rfh(), url2,
3301 base::TimeTicks::Now());
3300 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL()); 3302 EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL());
3301 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL()); 3303 EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL());
3302 3304
3303 // Once it commits, the URL and virtual URL should reflect the actual page. 3305 // Once it commits, the URL and virtual URL should reflect the actual page.
3304 main_test_rfh()->SendNavigate(0, 0, true, url2); 3306 main_test_rfh()->SendNavigate(0, 0, true, url2);
3305 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); 3307 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
3306 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL()); 3308 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL());
3307 3309
3308 // We should not replace the pending entry for an error URL. 3310 // We should not replace the pending entry for an error URL.
3309 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); 3311 navigator->DidStartProvisionalLoad(main_test_rfh(), url1,
3312 base::TimeTicks::Now());
3310 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); 3313 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
3311 navigator->DidStartProvisionalLoad(main_test_rfh(), 3314 navigator->DidStartProvisionalLoad(
3312 GURL(kUnreachableWebDataURL)); 3315 main_test_rfh(), GURL(kUnreachableWebDataURL), base::TimeTicks::Now());
3313 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL()); 3316 EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
3314 3317
3315 // We should remember if the pending entry will replace the current one. 3318 // We should remember if the pending entry will replace the current one.
3316 // http://crbug.com/308444. 3319 // http://crbug.com/308444.
3317 navigator->DidStartProvisionalLoad(main_test_rfh(), url1); 3320 navigator->DidStartProvisionalLoad(main_test_rfh(), url1,
3321 base::TimeTicks::Now());
3318 controller.GetPendingEntry()->set_should_replace_entry(true); 3322 controller.GetPendingEntry()->set_should_replace_entry(true);
3319 3323
3320 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); 3324 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
3321 main_test_rfh()->PrepareForCommit(); 3325 main_test_rfh()->PrepareForCommit();
3322 navigator->DidStartProvisionalLoad(main_test_rfh(), url2); 3326 navigator->DidStartProvisionalLoad(main_test_rfh(), url2,
3327 base::TimeTicks::Now());
3323 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry()); 3328 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry());
3324 main_test_rfh()->SendNavigate(0, 0, false, url2); 3329 main_test_rfh()->SendNavigate(0, 0, false, url2);
3325 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); 3330 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
3326 } 3331 }
3327 3332
3328 // Tests that the URLs for renderer-initiated navigations are not displayed to 3333 // Tests that the URLs for renderer-initiated navigations are not displayed to
3329 // the user until the navigation commits, to prevent URL spoof attacks. 3334 // the user until the navigation commits, to prevent URL spoof attacks.
3330 // See http://crbug.com/99016. 3335 // See http://crbug.com/99016.
3331 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { 3336 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
3332 NavigationControllerImpl& controller = controller_impl(); 3337 NavigationControllerImpl& controller = controller_impl();
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
5051 EXPECT_EQ(default_ssl_status.connection_status, 5056 EXPECT_EQ(default_ssl_status.connection_status,
5052 details.ssl_status.connection_status); 5057 details.ssl_status.connection_status);
5053 EXPECT_EQ(default_ssl_status.content_status, 5058 EXPECT_EQ(default_ssl_status.content_status,
5054 details.ssl_status.content_status); 5059 details.ssl_status.content_status);
5055 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); 5060 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size());
5056 5061
5057 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); 5062 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count());
5058 } 5063 }
5059 5064
5060 } // namespace content 5065 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698