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

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

Issue 1794513003: Don't rely on the pending NavigationEntry for location.replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test for 593153 Created 4 years, 9 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
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 "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 pending_entry->set_should_replace_entry(true); 1502 pending_entry->set_should_replace_entry(true);
1503 pending_entry->set_should_clear_history_list(true); 1503 pending_entry->set_should_clear_history_list(true);
1504 EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData()); 1504 EXPECT_EQ(post_data.get(), pending_entry->GetBrowserInitiatedPostData());
1505 EXPECT_TRUE(pending_entry->is_renderer_initiated()); 1505 EXPECT_TRUE(pending_entry->is_renderer_initiated());
1506 EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id()); 1506 EXPECT_EQ(transfer_id, pending_entry->transferred_global_request_id());
1507 EXPECT_TRUE(pending_entry->should_replace_entry()); 1507 EXPECT_TRUE(pending_entry->should_replace_entry());
1508 EXPECT_TRUE(pending_entry->should_clear_history_list()); 1508 EXPECT_TRUE(pending_entry->should_clear_history_list());
1509 1509
1510 // Fake a commit response. 1510 // Fake a commit response.
1511 main_test_rfh()->PrepareForCommit(); 1511 main_test_rfh()->PrepareForCommit();
1512 main_test_rfh()->SendNavigate(1, entry_id, true, url1); 1512 main_test_rfh()->SendNavigateWithReplacement(1, entry_id, true, url1);
1513 1513
1514 // Certain values that are only used for pending entries get reset after 1514 // Certain values that are only used for pending entries get reset after
1515 // commit. 1515 // commit.
1516 NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry(); 1516 NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry();
1517 EXPECT_FALSE(committed_entry->GetBrowserInitiatedPostData()); 1517 EXPECT_FALSE(committed_entry->GetBrowserInitiatedPostData());
1518 EXPECT_FALSE(committed_entry->is_renderer_initiated()); 1518 EXPECT_FALSE(committed_entry->is_renderer_initiated());
1519 EXPECT_EQ(GlobalRequestID(-1, -1), 1519 EXPECT_EQ(GlobalRequestID(-1, -1),
1520 committed_entry->transferred_global_request_id()); 1520 committed_entry->transferred_global_request_id());
1521 EXPECT_FALSE(committed_entry->should_replace_entry()); 1521 EXPECT_FALSE(committed_entry->should_replace_entry());
1522 EXPECT_FALSE(committed_entry->should_clear_history_list()); 1522 EXPECT_FALSE(committed_entry->should_clear_history_list());
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 // http://crbug.com/308444. 3390 // http://crbug.com/308444.
3391 navigator->DidStartProvisionalLoad(main_test_rfh(), url1, 3391 navigator->DidStartProvisionalLoad(main_test_rfh(), url1,
3392 base::TimeTicks::Now()); 3392 base::TimeTicks::Now());
3393 controller.GetPendingEntry()->set_should_replace_entry(true); 3393 controller.GetPendingEntry()->set_should_replace_entry(true);
3394 3394
3395 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false); 3395 main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, false);
3396 main_test_rfh()->PrepareForCommit(); 3396 main_test_rfh()->PrepareForCommit();
3397 navigator->DidStartProvisionalLoad(main_test_rfh(), url2, 3397 navigator->DidStartProvisionalLoad(main_test_rfh(), url2,
3398 base::TimeTicks::Now()); 3398 base::TimeTicks::Now());
3399 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry()); 3399 EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry());
3400 main_test_rfh()->SendNavigate(0, 0, false, url2); 3400 main_test_rfh()->SendNavigateWithReplacement(0, 0, false, url2);
3401 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL()); 3401 EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
3402 } 3402 }
3403 3403
3404 // Tests that the URLs for renderer-initiated navigations are not displayed to 3404 // Tests that the URLs for renderer-initiated navigations are not displayed to
3405 // the user until the navigation commits, to prevent URL spoof attacks. 3405 // the user until the navigation commits, to prevent URL spoof attacks.
3406 // See http://crbug.com/99016. 3406 // See http://crbug.com/99016.
3407 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) { 3407 TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
3408 NavigationControllerImpl& controller = controller_impl(); 3408 NavigationControllerImpl& controller = controller_impl();
3409 TestNotificationTracker notifications; 3409 TestNotificationTracker notifications;
3410 RegisterForAllNavNotifications(&notifications, &controller); 3410 RegisterForAllNavNotifications(&notifications, &controller);
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
5166 EXPECT_EQ(default_ssl_status.connection_status, 5166 EXPECT_EQ(default_ssl_status.connection_status,
5167 details.ssl_status.connection_status); 5167 details.ssl_status.connection_status);
5168 EXPECT_EQ(default_ssl_status.content_status, 5168 EXPECT_EQ(default_ssl_status.content_status,
5169 details.ssl_status.content_status); 5169 details.ssl_status.content_status);
5170 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); 5170 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size());
5171 5171
5172 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); 5172 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count());
5173 } 5173 }
5174 5174
5175 } // namespace content 5175 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698