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

Side by Side Diff: content/browser/web_contents/render_view_host_manager_unittest.cc

Issue 16162003: Introduce content::PageState (again). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "content/browser/browser_thread_impl.h" 6 #include "content/browser/browser_thread_impl.h"
7 #include "content/browser/renderer_host/test_render_view_host.h" 7 #include "content/browser/renderer_host/test_render_view_host.h"
8 #include "content/browser/site_instance_impl.h" 8 #include "content/browser/site_instance_impl.h"
9 #include "content/browser/web_contents/navigation_controller_impl.h" 9 #include "content/browser/web_contents/navigation_controller_impl.h"
10 #include "content/browser/web_contents/navigation_entry_impl.h" 10 #include "content/browser/web_contents/navigation_entry_impl.h"
11 #include "content/browser/web_contents/render_view_host_manager.h" 11 #include "content/browser/web_contents/render_view_host_manager.h"
12 #include "content/browser/webui/web_ui_controller_factory_registry.h" 12 #include "content/browser/webui/web_ui_controller_factory_registry.h"
13 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
14 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/web_ui_controller.h" 17 #include "content/public/browser/web_ui_controller.h"
18 #include "content/public/common/bindings_policy.h" 18 #include "content/public/common/bindings_policy.h"
19 #include "content/public/common/javascript_message_type.h" 19 #include "content/public/common/javascript_message_type.h"
20 #include "content/public/common/page_transition_types.h" 20 #include "content/public/common/page_transition_types.h"
21 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
22 #include "content/public/common/url_utils.h" 22 #include "content/public/common/url_utils.h"
23 #include "content/public/test/mock_render_process_host.h" 23 #include "content/public/test/mock_render_process_host.h"
24 #include "content/public/test/test_browser_context.h" 24 #include "content/public/test/test_browser_context.h"
25 #include "content/public/test/test_notification_tracker.h" 25 #include "content/public/test/test_notification_tracker.h"
26 #include "content/test/test_content_browser_client.h" 26 #include "content/test/test_content_browser_client.h"
27 #include "content/test/test_content_client.h" 27 #include "content/test/test_content_client.h"
28 #include "content/test/test_web_contents.h" 28 #include "content/test/test_web_contents.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "webkit/glue/glue_serialize.h"
31 30
32 namespace content { 31 namespace content {
33 namespace { 32 namespace {
34 33
35 class RenderViewHostManagerTestWebUIControllerFactory 34 class RenderViewHostManagerTestWebUIControllerFactory
36 : public WebUIControllerFactory { 35 : public WebUIControllerFactory {
37 public: 36 public:
38 RenderViewHostManagerTestWebUIControllerFactory() 37 RenderViewHostManagerTestWebUIControllerFactory()
39 : should_create_webui_(false) { 38 : should_create_webui_(false) {
40 } 39 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 718
720 // Before that RVH has committed, the evil page reloads itself. 719 // Before that RVH has committed, the evil page reloads itself.
721 ViewHostMsg_FrameNavigate_Params params; 720 ViewHostMsg_FrameNavigate_Params params;
722 params.page_id = 1; 721 params.page_id = 1;
723 params.url = kUrl2; 722 params.url = kUrl2;
724 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; 723 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT;
725 params.should_update_history = false; 724 params.should_update_history = false;
726 params.gesture = NavigationGestureAuto; 725 params.gesture = NavigationGestureAuto;
727 params.was_within_same_page = false; 726 params.was_within_same_page = false;
728 params.is_post = false; 727 params.is_post = false;
729 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(kUrl2)); 728 params.page_state = PageState::CreateFromURL(kUrl2);
730 contents()->DidNavigate(evil_rvh, params); 729 contents()->DidNavigate(evil_rvh, params);
731 730
732 // That should have cancelled the pending RVH, and the evil RVH should be the 731 // That should have cancelled the pending RVH, and the evil RVH should be the
733 // current one. 732 // current one.
734 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> 733 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->
735 pending_render_view_host() == NULL); 734 pending_render_view_host() == NULL);
736 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); 735 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host());
737 736
738 // Also we should not have a pending navigation entry. 737 // Also we should not have a pending navigation entry.
739 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); 738 NavigationEntry* entry = contents()->GetController().GetActiveEntry();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 942
944 // Commit. 943 // Commit.
945 manager.DidNavigateMainFrame(host); 944 manager.DidNavigateMainFrame(host);
946 EXPECT_EQ(host, manager.current_host()); 945 EXPECT_EQ(host, manager.current_host());
947 ASSERT_TRUE(host); 946 ASSERT_TRUE(host);
948 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), 947 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()),
949 instance); 948 instance);
950 } 949 }
951 950
952 } // namespace content 951 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698