OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 3577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3588 entries.push_back(std::move(restored_entry)); | 3588 entries.push_back(std::move(restored_entry)); |
3589 Shell* new_shell = Shell::CreateNewWindow( | 3589 Shell* new_shell = Shell::CreateNewWindow( |
3590 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); | 3590 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); |
3591 FrameTreeNode* new_root = | 3591 FrameTreeNode* new_root = |
3592 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 3592 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
3593 ->GetFrameTree() | 3593 ->GetFrameTree() |
3594 ->root(); | 3594 ->root(); |
3595 NavigationControllerImpl& new_controller = | 3595 NavigationControllerImpl& new_controller = |
3596 static_cast<NavigationControllerImpl&>( | 3596 static_cast<NavigationControllerImpl&>( |
3597 new_shell->web_contents()->GetController()); | 3597 new_shell->web_contents()->GetController()); |
3598 new_controller.Restore( | 3598 new_controller.Restore(entries.size() - 1, |
3599 entries.size() - 1, | 3599 RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); |
3600 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | |
3601 ASSERT_EQ(0u, entries.size()); | 3600 ASSERT_EQ(0u, entries.size()); |
3602 { | 3601 { |
3603 TestNavigationObserver restore_observer(new_shell->web_contents()); | 3602 TestNavigationObserver restore_observer(new_shell->web_contents()); |
3604 new_controller.LoadIfNecessary(); | 3603 new_controller.LoadIfNecessary(); |
3605 restore_observer.Wait(); | 3604 restore_observer.Wait(); |
3606 } | 3605 } |
3607 ASSERT_EQ(1U, new_root->child_count()); | 3606 ASSERT_EQ(1U, new_root->child_count()); |
3608 EXPECT_EQ(main_url_a, new_root->current_url()); | 3607 EXPECT_EQ(main_url_a, new_root->current_url()); |
3609 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url()); | 3608 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url()); |
3610 | 3609 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4068 entries.push_back(std::move(restored_entry)); | 4067 entries.push_back(std::move(restored_entry)); |
4069 Shell* new_shell = Shell::CreateNewWindow( | 4068 Shell* new_shell = Shell::CreateNewWindow( |
4070 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); | 4069 controller.GetBrowserContext(), GURL::EmptyGURL(), nullptr, gfx::Size()); |
4071 FrameTreeNode* new_root = | 4070 FrameTreeNode* new_root = |
4072 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 4071 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
4073 ->GetFrameTree() | 4072 ->GetFrameTree() |
4074 ->root(); | 4073 ->root(); |
4075 NavigationControllerImpl& new_controller = | 4074 NavigationControllerImpl& new_controller = |
4076 static_cast<NavigationControllerImpl&>( | 4075 static_cast<NavigationControllerImpl&>( |
4077 new_shell->web_contents()->GetController()); | 4076 new_shell->web_contents()->GetController()); |
4078 new_controller.Restore( | 4077 new_controller.Restore(entries.size() - 1, |
4079 entries.size() - 1, | 4078 RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); |
4080 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); | |
4081 ASSERT_EQ(0u, entries.size()); | 4079 ASSERT_EQ(0u, entries.size()); |
4082 { | 4080 { |
4083 TestNavigationObserver restore_observer(new_shell->web_contents()); | 4081 TestNavigationObserver restore_observer(new_shell->web_contents()); |
4084 new_controller.LoadIfNecessary(); | 4082 new_controller.LoadIfNecessary(); |
4085 restore_observer.Wait(); | 4083 restore_observer.Wait(); |
4086 } | 4084 } |
4087 ASSERT_EQ(1U, new_root->child_count()); | 4085 ASSERT_EQ(1U, new_root->child_count()); |
4088 EXPECT_EQ(main_url_a, new_root->current_url()); | 4086 EXPECT_EQ(main_url_a, new_root->current_url()); |
4089 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url()); | 4087 EXPECT_EQ(frame_url_b, new_root->child_at(0)->current_url()); |
4090 | 4088 |
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5917 &headers)); | 5915 &headers)); |
5918 | 5916 |
5919 // Verify the Origin and Referer headers. | 5917 // Verify the Origin and Referer headers. |
5920 EXPECT_THAT(headers, ::testing::HasSubstr("Origin: null")); | 5918 EXPECT_THAT(headers, ::testing::HasSubstr("Origin: null")); |
5921 EXPECT_THAT(headers, | 5919 EXPECT_THAT(headers, |
5922 ::testing::ContainsRegex( | 5920 ::testing::ContainsRegex( |
5923 "Referer: http://a.com:.*/form_that_posts_cross_site.html")); | 5921 "Referer: http://a.com:.*/form_that_posts_cross_site.html")); |
5924 } | 5922 } |
5925 | 5923 |
5926 } // namespace content | 5924 } // namespace content |
OLD | NEW |