OLD | NEW |
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 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/browser/frame_host/cross_site_transferring_request.h" | 23 #include "content/browser/frame_host/cross_site_transferring_request.h" |
24 #include "content/browser/frame_host/frame_navigation_entry.h" | 24 #include "content/browser/frame_host/frame_navigation_entry.h" |
25 #include "content/browser/frame_host/navigation_entry_impl.h" | 25 #include "content/browser/frame_host/navigation_entry_impl.h" |
26 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 26 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
27 #include "content/browser/frame_host/navigation_request.h" | 27 #include "content/browser/frame_host/navigation_request.h" |
28 #include "content/browser/frame_host/navigator.h" | 28 #include "content/browser/frame_host/navigator.h" |
29 #include "content/browser/frame_host/navigator_impl.h" | 29 #include "content/browser/frame_host/navigator_impl.h" |
30 #include "content/browser/site_instance_impl.h" | 30 #include "content/browser/site_instance_impl.h" |
31 #include "content/browser/web_contents/web_contents_impl.h" | 31 #include "content/browser/web_contents/web_contents_impl.h" |
32 #include "content/common/frame_messages.h" | 32 #include "content/common/frame_messages.h" |
| 33 #include "content/common/frame_owner_properties.h" |
33 #include "content/common/site_isolation_policy.h" | 34 #include "content/common/site_isolation_policy.h" |
34 #include "content/common/ssl_status_serialization.h" | 35 #include "content/common/ssl_status_serialization.h" |
35 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
36 #include "content/public/browser/navigation_details.h" | 37 #include "content/public/browser/navigation_details.h" |
37 #include "content/public/browser/notification_registrar.h" | 38 #include "content/public/browser/notification_registrar.h" |
38 #include "content/public/browser/notification_types.h" | 39 #include "content/public/browser/notification_types.h" |
39 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/web_contents_delegate.h" | 41 #include "content/public/browser/web_contents_delegate.h" |
41 #include "content/public/browser/web_contents_observer.h" | 42 #include "content/public/browser/web_contents_observer.h" |
42 #include "content/public/common/browser_side_navigation_policy.h" | 43 #include "content/public/common/browser_side_navigation_policy.h" |
43 #include "content/public/common/page_state.h" | 44 #include "content/public/common/page_state.h" |
44 #include "content/public/common/page_type.h" | 45 #include "content/public/common/page_type.h" |
45 #include "content/public/common/resource_request_body.h" | 46 #include "content/public/common/resource_request_body.h" |
46 #include "content/public/common/url_constants.h" | 47 #include "content/public/common/url_constants.h" |
47 #include "content/public/test/mock_render_process_host.h" | 48 #include "content/public/test/mock_render_process_host.h" |
48 #include "content/public/test/test_notification_tracker.h" | 49 #include "content/public/test/test_notification_tracker.h" |
49 #include "content/public/test/test_utils.h" | 50 #include "content/public/test/test_utils.h" |
50 #include "content/test/browser_side_navigation_test_utils.h" | 51 #include "content/test/browser_side_navigation_test_utils.h" |
51 #include "content/test/test_render_frame_host.h" | 52 #include "content/test/test_render_frame_host.h" |
52 #include "content/test/test_render_view_host.h" | 53 #include "content/test/test_render_view_host.h" |
53 #include "content/test/test_web_contents.h" | 54 #include "content/test/test_web_contents.h" |
54 #include "skia/ext/platform_canvas.h" | 55 #include "skia/ext/platform_canvas.h" |
55 #include "testing/gtest/include/gtest/gtest.h" | 56 #include "testing/gtest/include/gtest/gtest.h" |
56 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" | |
57 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 57 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
58 | 58 |
59 using base::Time; | 59 using base::Time; |
60 | 60 |
61 namespace { | 61 namespace { |
62 | 62 |
63 // Creates an image with a 1x1 SkBitmap of the specified |color|. | 63 // Creates an image with a 1x1 SkBitmap of the specified |color|. |
64 gfx::Image CreateImage(SkColor color) { | 64 gfx::Image CreateImage(SkColor color) { |
65 SkBitmap bitmap; | 65 SkBitmap bitmap; |
66 bitmap.allocN32Pixels(1, 1); | 66 bitmap.allocN32Pixels(1, 1); |
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 const GURL url1("http://foo1"); | 2168 const GURL url1("http://foo1"); |
2169 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2169 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
2170 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2170 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2171 navigation_entry_committed_counter_ = 0; | 2171 navigation_entry_committed_counter_ = 0; |
2172 | 2172 |
2173 // Prereq: add a subframe with an initial auto-subframe navigation. | 2173 // Prereq: add a subframe with an initial auto-subframe navigation. |
2174 std::string unique_name("uniqueName0"); | 2174 std::string unique_name("uniqueName0"); |
2175 main_test_rfh()->OnCreateChildFrame( | 2175 main_test_rfh()->OnCreateChildFrame( |
2176 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2176 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2177 std::string(), unique_name, blink::WebSandboxFlags::None, | 2177 std::string(), unique_name, blink::WebSandboxFlags::None, |
2178 blink::WebFrameOwnerProperties()); | 2178 FrameOwnerProperties()); |
2179 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( | 2179 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
2180 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); | 2180 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
2181 const GURL subframe_url("http://foo1/subframe"); | 2181 const GURL subframe_url("http://foo1/subframe"); |
2182 { | 2182 { |
2183 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2183 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2184 params.page_id = 1; | 2184 params.page_id = 1; |
2185 params.nav_entry_id = 0; | 2185 params.nav_entry_id = 0; |
2186 params.frame_unique_name = unique_name; | 2186 params.frame_unique_name = unique_name; |
2187 params.did_create_new_entry = false; | 2187 params.did_create_new_entry = false; |
2188 params.url = subframe_url; | 2188 params.url = subframe_url; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 const GURL url1("http://foo/1"); | 2255 const GURL url1("http://foo/1"); |
2256 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2256 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
2257 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2257 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2258 navigation_entry_committed_counter_ = 0; | 2258 navigation_entry_committed_counter_ = 0; |
2259 | 2259 |
2260 // Add a subframe and navigate it. | 2260 // Add a subframe and navigate it. |
2261 std::string unique_name0("uniqueName0"); | 2261 std::string unique_name0("uniqueName0"); |
2262 main_test_rfh()->OnCreateChildFrame( | 2262 main_test_rfh()->OnCreateChildFrame( |
2263 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2263 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2264 std::string(), unique_name0, blink::WebSandboxFlags::None, | 2264 std::string(), unique_name0, blink::WebSandboxFlags::None, |
2265 blink::WebFrameOwnerProperties()); | 2265 FrameOwnerProperties()); |
2266 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( | 2266 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
2267 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); | 2267 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
2268 const GURL url2("http://foo/2"); | 2268 const GURL url2("http://foo/2"); |
2269 { | 2269 { |
2270 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2270 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2271 params.page_id = 1; | 2271 params.page_id = 1; |
2272 params.nav_entry_id = 0; | 2272 params.nav_entry_id = 0; |
2273 params.frame_unique_name = unique_name0; | 2273 params.frame_unique_name = unique_name0; |
2274 params.did_create_new_entry = false; | 2274 params.did_create_new_entry = false; |
2275 params.url = url2; | 2275 params.url = url2; |
(...skipping 28 matching lines...) Expand all Loading... |
2304 } else { | 2304 } else { |
2305 // There are no subframe FrameNavigationEntries by default. | 2305 // There are no subframe FrameNavigationEntries by default. |
2306 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2306 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2307 } | 2307 } |
2308 | 2308 |
2309 // Add a second subframe and navigate. | 2309 // Add a second subframe and navigate. |
2310 std::string unique_name1("uniqueName1"); | 2310 std::string unique_name1("uniqueName1"); |
2311 main_test_rfh()->OnCreateChildFrame( | 2311 main_test_rfh()->OnCreateChildFrame( |
2312 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2312 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2313 std::string(), unique_name1, blink::WebSandboxFlags::None, | 2313 std::string(), unique_name1, blink::WebSandboxFlags::None, |
2314 blink::WebFrameOwnerProperties()); | 2314 FrameOwnerProperties()); |
2315 TestRenderFrameHost* subframe2 = static_cast<TestRenderFrameHost*>( | 2315 TestRenderFrameHost* subframe2 = static_cast<TestRenderFrameHost*>( |
2316 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host()); | 2316 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host()); |
2317 const GURL url3("http://foo/3"); | 2317 const GURL url3("http://foo/3"); |
2318 { | 2318 { |
2319 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2319 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2320 params.page_id = 1; | 2320 params.page_id = 1; |
2321 params.nav_entry_id = 0; | 2321 params.nav_entry_id = 0; |
2322 params.frame_unique_name = unique_name1; | 2322 params.frame_unique_name = unique_name1; |
2323 params.did_create_new_entry = false; | 2323 params.did_create_new_entry = false; |
2324 params.url = url3; | 2324 params.url = url3; |
(...skipping 28 matching lines...) Expand all Loading... |
2353 } else { | 2353 } else { |
2354 // There are no subframe FrameNavigationEntries by default. | 2354 // There are no subframe FrameNavigationEntries by default. |
2355 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2355 EXPECT_EQ(0U, entry->root_node()->children.size()); |
2356 } | 2356 } |
2357 | 2357 |
2358 // Add a nested subframe and navigate. | 2358 // Add a nested subframe and navigate. |
2359 std::string unique_name2("uniqueName2"); | 2359 std::string unique_name2("uniqueName2"); |
2360 subframe->OnCreateChildFrame(process()->GetNextRoutingID(), | 2360 subframe->OnCreateChildFrame(process()->GetNextRoutingID(), |
2361 blink::WebTreeScopeType::Document, std::string(), | 2361 blink::WebTreeScopeType::Document, std::string(), |
2362 unique_name2, blink::WebSandboxFlags::None, | 2362 unique_name2, blink::WebSandboxFlags::None, |
2363 blink::WebFrameOwnerProperties()); | 2363 FrameOwnerProperties()); |
2364 TestRenderFrameHost* subframe3 = | 2364 TestRenderFrameHost* subframe3 = |
2365 static_cast<TestRenderFrameHost*>(contents() | 2365 static_cast<TestRenderFrameHost*>(contents() |
2366 ->GetFrameTree() | 2366 ->GetFrameTree() |
2367 ->root() | 2367 ->root() |
2368 ->child_at(0) | 2368 ->child_at(0) |
2369 ->child_at(0) | 2369 ->child_at(0) |
2370 ->current_frame_host()); | 2370 ->current_frame_host()); |
2371 const GURL url4("http://foo/4"); | 2371 const GURL url4("http://foo/4"); |
2372 { | 2372 { |
2373 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2373 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2422 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
2423 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2423 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2424 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); | 2424 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); |
2425 navigation_entry_committed_counter_ = 0; | 2425 navigation_entry_committed_counter_ = 0; |
2426 | 2426 |
2427 // Prereq: add a subframe with an initial auto-subframe navigation. | 2427 // Prereq: add a subframe with an initial auto-subframe navigation. |
2428 std::string unique_name("uniqueName0"); | 2428 std::string unique_name("uniqueName0"); |
2429 main_test_rfh()->OnCreateChildFrame( | 2429 main_test_rfh()->OnCreateChildFrame( |
2430 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 2430 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
2431 std::string(), unique_name, blink::WebSandboxFlags::None, | 2431 std::string(), unique_name, blink::WebSandboxFlags::None, |
2432 blink::WebFrameOwnerProperties()); | 2432 FrameOwnerProperties()); |
2433 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( | 2433 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
2434 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); | 2434 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
2435 const GURL subframe_url("http://foo1/subframe"); | 2435 const GURL subframe_url("http://foo1/subframe"); |
2436 | 2436 |
2437 // Compute the sequence number assigned by Blink. | 2437 // Compute the sequence number assigned by Blink. |
2438 int64_t item_sequence_number1 = base::Time::Now().ToDoubleT() * 1000000; | 2438 int64_t item_sequence_number1 = base::Time::Now().ToDoubleT() * 1000000; |
2439 | 2439 |
2440 { | 2440 { |
2441 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2441 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
2442 params.page_id = 1; | 2442 params.page_id = 1; |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3900 | 3900 |
3901 // We should be at the first navigation entry. | 3901 // We should be at the first navigation entry. |
3902 EXPECT_EQ(controller.GetEntryCount(), 1); | 3902 EXPECT_EQ(controller.GetEntryCount(), 1); |
3903 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 3903 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
3904 | 3904 |
3905 // Add and navigate a subframe that would normally count as in-page. | 3905 // Add and navigate a subframe that would normally count as in-page. |
3906 std::string unique_name("uniqueName0"); | 3906 std::string unique_name("uniqueName0"); |
3907 main_test_rfh()->OnCreateChildFrame( | 3907 main_test_rfh()->OnCreateChildFrame( |
3908 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 3908 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
3909 std::string(), unique_name, blink::WebSandboxFlags::None, | 3909 std::string(), unique_name, blink::WebSandboxFlags::None, |
3910 blink::WebFrameOwnerProperties()); | 3910 FrameOwnerProperties()); |
3911 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( | 3911 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
3912 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); | 3912 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
3913 const GURL subframe_url("http://www.google.com/#"); | 3913 const GURL subframe_url("http://www.google.com/#"); |
3914 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3914 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3915 params.page_id = 0; | 3915 params.page_id = 0; |
3916 params.nav_entry_id = 0; | 3916 params.nav_entry_id = 0; |
3917 params.frame_unique_name = unique_name; | 3917 params.frame_unique_name = unique_name; |
3918 params.did_create_new_entry = false; | 3918 params.did_create_new_entry = false; |
3919 params.url = subframe_url; | 3919 params.url = subframe_url; |
3920 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3920 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4076 const GURL url2("http://bar/"); | 4076 const GURL url2("http://bar/"); |
4077 controller.LoadURL( | 4077 controller.LoadURL( |
4078 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 4078 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
4079 | 4079 |
4080 // Send a subframe update from the first page, as if one had just | 4080 // Send a subframe update from the first page, as if one had just |
4081 // automatically loaded. Auto subframes don't increment the page ID. | 4081 // automatically loaded. Auto subframes don't increment the page ID. |
4082 std::string unique_name("uniqueName0"); | 4082 std::string unique_name("uniqueName0"); |
4083 main_test_rfh()->OnCreateChildFrame( | 4083 main_test_rfh()->OnCreateChildFrame( |
4084 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, | 4084 process()->GetNextRoutingID(), blink::WebTreeScopeType::Document, |
4085 std::string(), unique_name, blink::WebSandboxFlags::None, | 4085 std::string(), unique_name, blink::WebSandboxFlags::None, |
4086 blink::WebFrameOwnerProperties()); | 4086 FrameOwnerProperties()); |
4087 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( | 4087 TestRenderFrameHost* subframe = static_cast<TestRenderFrameHost*>( |
4088 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); | 4088 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host()); |
4089 const GURL url1_sub("http://foo/subframe"); | 4089 const GURL url1_sub("http://foo/subframe"); |
4090 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4090 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4091 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); | 4091 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); |
4092 params.nav_entry_id = 0; | 4092 params.nav_entry_id = 0; |
4093 params.frame_unique_name = unique_name; | 4093 params.frame_unique_name = unique_name; |
4094 params.did_create_new_entry = false; | 4094 params.did_create_new_entry = false; |
4095 params.url = url1_sub; | 4095 params.url = url1_sub; |
4096 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 4096 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5335 observer.details().ssl_status.num_unknown_scts); | 5335 observer.details().ssl_status.num_unknown_scts); |
5336 EXPECT_EQ(default_ssl_status.num_invalid_scts, | 5336 EXPECT_EQ(default_ssl_status.num_invalid_scts, |
5337 observer.details().ssl_status.num_invalid_scts); | 5337 observer.details().ssl_status.num_invalid_scts); |
5338 EXPECT_EQ(default_ssl_status.num_valid_scts, | 5338 EXPECT_EQ(default_ssl_status.num_valid_scts, |
5339 observer.details().ssl_status.num_valid_scts); | 5339 observer.details().ssl_status.num_valid_scts); |
5340 | 5340 |
5341 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5341 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5342 } | 5342 } |
5343 | 5343 |
5344 } // namespace content | 5344 } // namespace content |
OLD | NEW |