| 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 "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 26 matching lines...) Expand all Loading... |
| 37 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
| 38 #include "content/public/test/mock_render_process_host.h" | 38 #include "content/public/test/mock_render_process_host.h" |
| 39 #include "content/public/test/test_notification_tracker.h" | 39 #include "content/public/test/test_notification_tracker.h" |
| 40 #include "content/public/test/test_utils.h" | 40 #include "content/public/test/test_utils.h" |
| 41 #include "content/test/test_render_frame_host.h" | 41 #include "content/test/test_render_frame_host.h" |
| 42 #include "content/test/test_render_view_host.h" | 42 #include "content/test/test_render_view_host.h" |
| 43 #include "content/test/test_web_contents.h" | 43 #include "content/test/test_web_contents.h" |
| 44 #include "net/base/net_util.h" | 44 #include "net/base/net_util.h" |
| 45 #include "skia/ext/platform_canvas.h" | 45 #include "skia/ext/platform_canvas.h" |
| 46 #include "testing/gtest/include/gtest/gtest.h" | 46 #include "testing/gtest/include/gtest/gtest.h" |
| 47 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
| 47 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 48 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 48 | 49 |
| 49 using base::Time; | 50 using base::Time; |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 // Creates an image with a 1x1 SkBitmap of the specified |color|. | 54 // Creates an image with a 1x1 SkBitmap of the specified |color|. |
| 54 gfx::Image CreateImage(SkColor color) { | 55 gfx::Image CreateImage(SkColor color) { |
| 55 SkBitmap bitmap; | 56 SkBitmap bitmap; |
| 56 bitmap.allocN32Pixels(1, 1); | 57 bitmap.allocN32Pixels(1, 1); |
| (...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 RegisterForAllNavNotifications(¬ifications, &controller); | 2020 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2020 | 2021 |
| 2021 const GURL url1("http://foo1"); | 2022 const GURL url1("http://foo1"); |
| 2022 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2023 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
| 2023 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2024 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2024 navigation_entry_committed_counter_ = 0; | 2025 navigation_entry_committed_counter_ = 0; |
| 2025 | 2026 |
| 2026 // Prereq: add a subframe with an initial auto-subframe navigation. | 2027 // Prereq: add a subframe with an initial auto-subframe navigation. |
| 2027 main_test_rfh()->OnCreateChildFrame( | 2028 main_test_rfh()->OnCreateChildFrame( |
| 2028 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), | 2029 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), |
| 2029 blink::WebSandboxFlags::None); | 2030 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); |
| 2030 RenderFrameHostImpl* subframe = | 2031 RenderFrameHostImpl* subframe = |
| 2031 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 2032 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); |
| 2032 const GURL subframe_url("http://foo1/subframe"); | 2033 const GURL subframe_url("http://foo1/subframe"); |
| 2033 { | 2034 { |
| 2034 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2035 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2035 params.page_id = 1; | 2036 params.page_id = 1; |
| 2036 params.nav_entry_id = 0; | 2037 params.nav_entry_id = 0; |
| 2037 params.did_create_new_entry = false; | 2038 params.did_create_new_entry = false; |
| 2038 params.url = subframe_url; | 2039 params.url = subframe_url; |
| 2039 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2040 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 RegisterForAllNavNotifications(¬ifications, &controller); | 2100 RegisterForAllNavNotifications(¬ifications, &controller); |
| 2100 | 2101 |
| 2101 const GURL url1("http://foo/1"); | 2102 const GURL url1("http://foo/1"); |
| 2102 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2103 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
| 2103 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2104 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2104 navigation_entry_committed_counter_ = 0; | 2105 navigation_entry_committed_counter_ = 0; |
| 2105 | 2106 |
| 2106 // Add a subframe and navigate it. | 2107 // Add a subframe and navigate it. |
| 2107 main_test_rfh()->OnCreateChildFrame( | 2108 main_test_rfh()->OnCreateChildFrame( |
| 2108 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), | 2109 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), |
| 2109 blink::WebSandboxFlags::None); | 2110 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); |
| 2110 RenderFrameHostImpl* subframe = | 2111 RenderFrameHostImpl* subframe = |
| 2111 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 2112 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); |
| 2112 const GURL url2("http://foo/2"); | 2113 const GURL url2("http://foo/2"); |
| 2113 { | 2114 { |
| 2114 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2115 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2115 params.page_id = 1; | 2116 params.page_id = 1; |
| 2116 params.nav_entry_id = 0; | 2117 params.nav_entry_id = 0; |
| 2117 params.did_create_new_entry = false; | 2118 params.did_create_new_entry = false; |
| 2118 params.url = url2; | 2119 params.url = url2; |
| 2119 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2120 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2144 entry->root_node()->children[0]->frame_entry.get(); | 2145 entry->root_node()->children[0]->frame_entry.get(); |
| 2145 EXPECT_EQ(url2, frame_entry->url()); | 2146 EXPECT_EQ(url2, frame_entry->url()); |
| 2146 } else { | 2147 } else { |
| 2147 // There are no subframe FrameNavigationEntries by default. | 2148 // There are no subframe FrameNavigationEntries by default. |
| 2148 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2149 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 2149 } | 2150 } |
| 2150 | 2151 |
| 2151 // Add a second subframe and navigate. | 2152 // Add a second subframe and navigate. |
| 2152 main_test_rfh()->OnCreateChildFrame( | 2153 main_test_rfh()->OnCreateChildFrame( |
| 2153 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), | 2154 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), |
| 2154 blink::WebSandboxFlags::None); | 2155 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); |
| 2155 RenderFrameHostImpl* subframe2 = | 2156 RenderFrameHostImpl* subframe2 = |
| 2156 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host(); | 2157 contents()->GetFrameTree()->root()->child_at(1)->current_frame_host(); |
| 2157 const GURL url3("http://foo/3"); | 2158 const GURL url3("http://foo/3"); |
| 2158 { | 2159 { |
| 2159 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2160 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2160 params.page_id = 1; | 2161 params.page_id = 1; |
| 2161 params.nav_entry_id = 0; | 2162 params.nav_entry_id = 0; |
| 2162 params.did_create_new_entry = false; | 2163 params.did_create_new_entry = false; |
| 2163 params.url = url3; | 2164 params.url = url3; |
| 2164 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2165 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2189 entry->root_node()->children[1]->frame_entry.get(); | 2190 entry->root_node()->children[1]->frame_entry.get(); |
| 2190 EXPECT_EQ(url3, new_frame_entry->url()); | 2191 EXPECT_EQ(url3, new_frame_entry->url()); |
| 2191 } else { | 2192 } else { |
| 2192 // There are no subframe FrameNavigationEntries by default. | 2193 // There are no subframe FrameNavigationEntries by default. |
| 2193 EXPECT_EQ(0U, entry->root_node()->children.size()); | 2194 EXPECT_EQ(0U, entry->root_node()->children.size()); |
| 2194 } | 2195 } |
| 2195 | 2196 |
| 2196 // Add a nested subframe and navigate. | 2197 // Add a nested subframe and navigate. |
| 2197 subframe->OnCreateChildFrame(MSG_ROUTING_NONE, | 2198 subframe->OnCreateChildFrame(MSG_ROUTING_NONE, |
| 2198 blink::WebTreeScopeType::Document, std::string(), | 2199 blink::WebTreeScopeType::Document, std::string(), |
| 2199 blink::WebSandboxFlags::None); | 2200 blink::WebSandboxFlags::None, |
| 2201 blink::WebFrameOwnerProperties()); |
| 2200 RenderFrameHostImpl* subframe3 = contents() | 2202 RenderFrameHostImpl* subframe3 = contents() |
| 2201 ->GetFrameTree() | 2203 ->GetFrameTree() |
| 2202 ->root() | 2204 ->root() |
| 2203 ->child_at(0) | 2205 ->child_at(0) |
| 2204 ->child_at(0) | 2206 ->child_at(0) |
| 2205 ->current_frame_host(); | 2207 ->current_frame_host(); |
| 2206 const GURL url4("http://foo/4"); | 2208 const GURL url4("http://foo/4"); |
| 2207 { | 2209 { |
| 2208 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2210 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2209 params.page_id = 1; | 2211 params.page_id = 1; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 // Main page. | 2255 // Main page. |
| 2254 const GURL url1("http://foo1"); | 2256 const GURL url1("http://foo1"); |
| 2255 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); | 2257 main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); |
| 2256 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2258 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
| 2257 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); | 2259 NavigationEntry* entry1 = controller.GetLastCommittedEntry(); |
| 2258 navigation_entry_committed_counter_ = 0; | 2260 navigation_entry_committed_counter_ = 0; |
| 2259 | 2261 |
| 2260 // Prereq: add a subframe with an initial auto-subframe navigation. | 2262 // Prereq: add a subframe with an initial auto-subframe navigation. |
| 2261 main_test_rfh()->OnCreateChildFrame( | 2263 main_test_rfh()->OnCreateChildFrame( |
| 2262 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), | 2264 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), |
| 2263 blink::WebSandboxFlags::None); | 2265 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); |
| 2264 RenderFrameHostImpl* subframe = | 2266 RenderFrameHostImpl* subframe = |
| 2265 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 2267 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); |
| 2266 const GURL subframe_url("http://foo1/subframe"); | 2268 const GURL subframe_url("http://foo1/subframe"); |
| 2267 { | 2269 { |
| 2268 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 2270 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 2269 params.page_id = 1; | 2271 params.page_id = 1; |
| 2270 params.nav_entry_id = 0; | 2272 params.nav_entry_id = 0; |
| 2271 params.did_create_new_entry = false; | 2273 params.did_create_new_entry = false; |
| 2272 params.url = subframe_url; | 2274 params.url = subframe_url; |
| 2273 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2275 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3644 const GURL url("http://www.google.com/"); | 3646 const GURL url("http://www.google.com/"); |
| 3645 main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url); | 3647 main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url); |
| 3646 | 3648 |
| 3647 // We should be at the first navigation entry. | 3649 // We should be at the first navigation entry. |
| 3648 EXPECT_EQ(controller.GetEntryCount(), 1); | 3650 EXPECT_EQ(controller.GetEntryCount(), 1); |
| 3649 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 3651 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
| 3650 | 3652 |
| 3651 // Add and navigate a subframe that would normally count as in-page. | 3653 // Add and navigate a subframe that would normally count as in-page. |
| 3652 main_test_rfh()->OnCreateChildFrame( | 3654 main_test_rfh()->OnCreateChildFrame( |
| 3653 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), | 3655 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), |
| 3654 blink::WebSandboxFlags::None); | 3656 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); |
| 3655 RenderFrameHostImpl* subframe = | 3657 RenderFrameHostImpl* subframe = |
| 3656 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 3658 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); |
| 3657 const GURL subframe_url("http://www.google.com/#"); | 3659 const GURL subframe_url("http://www.google.com/#"); |
| 3658 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3660 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 3659 params.page_id = 0; | 3661 params.page_id = 0; |
| 3660 params.nav_entry_id = 0; | 3662 params.nav_entry_id = 0; |
| 3661 params.did_create_new_entry = false; | 3663 params.did_create_new_entry = false; |
| 3662 params.url = subframe_url; | 3664 params.url = subframe_url; |
| 3663 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3665 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 3664 params.should_update_history = false; | 3666 params.should_update_history = false; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3810 | 3812 |
| 3811 // Now start a pending load to a totally different page, but don't commit it. | 3813 // Now start a pending load to a totally different page, but don't commit it. |
| 3812 const GURL url2("http://bar/"); | 3814 const GURL url2("http://bar/"); |
| 3813 controller.LoadURL( | 3815 controller.LoadURL( |
| 3814 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 3816 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 3815 | 3817 |
| 3816 // Send a subframe update from the first page, as if one had just | 3818 // Send a subframe update from the first page, as if one had just |
| 3817 // automatically loaded. Auto subframes don't increment the page ID. | 3819 // automatically loaded. Auto subframes don't increment the page ID. |
| 3818 main_test_rfh()->OnCreateChildFrame( | 3820 main_test_rfh()->OnCreateChildFrame( |
| 3819 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), | 3821 MSG_ROUTING_NONE, blink::WebTreeScopeType::Document, std::string(), |
| 3820 blink::WebSandboxFlags::None); | 3822 blink::WebSandboxFlags::None, blink::WebFrameOwnerProperties()); |
| 3821 RenderFrameHostImpl* subframe = | 3823 RenderFrameHostImpl* subframe = |
| 3822 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); | 3824 contents()->GetFrameTree()->root()->child_at(0)->current_frame_host(); |
| 3823 const GURL url1_sub("http://foo/subframe"); | 3825 const GURL url1_sub("http://foo/subframe"); |
| 3824 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3826 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 3825 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); | 3827 params.page_id = controller.GetLastCommittedEntry()->GetPageID(); |
| 3826 params.nav_entry_id = 0; | 3828 params.nav_entry_id = 0; |
| 3827 params.did_create_new_entry = false; | 3829 params.did_create_new_entry = false; |
| 3828 params.url = url1_sub; | 3830 params.url = url1_sub; |
| 3829 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3831 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 3830 params.should_update_history = false; | 3832 params.should_update_history = false; |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5049 EXPECT_EQ(default_ssl_status.connection_status, | 5051 EXPECT_EQ(default_ssl_status.connection_status, |
| 5050 details.ssl_status.connection_status); | 5052 details.ssl_status.connection_status); |
| 5051 EXPECT_EQ(default_ssl_status.content_status, | 5053 EXPECT_EQ(default_ssl_status.content_status, |
| 5052 details.ssl_status.content_status); | 5054 details.ssl_status.content_status); |
| 5053 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5055 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
| 5054 | 5056 |
| 5055 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5057 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
| 5056 } | 5058 } |
| 5057 | 5059 |
| 5058 } // namespace content | 5060 } // namespace content |
| OLD | NEW |