Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 static_cast<MockRenderProcessHost*>(rfh->GetProcess()); | 93 static_cast<MockRenderProcessHost*>(rfh->GetProcess()); |
| 94 const FrameMsg_CommitNavigation* commit_message = | 94 const FrameMsg_CommitNavigation* commit_message = |
| 95 static_cast<const FrameMsg_CommitNavigation*>( | 95 static_cast<const FrameMsg_CommitNavigation*>( |
| 96 rph->sink().GetUniqueMessageMatching( | 96 rph->sink().GetUniqueMessageMatching( |
| 97 FrameMsg_CommitNavigation::ID)); | 97 FrameMsg_CommitNavigation::ID)); |
| 98 return commit_message && | 98 return commit_message && |
| 99 rfh->GetRoutingID() == commit_message->routing_id(); | 99 rfh->GetRoutingID() == commit_message->routing_id(); |
| 100 } | 100 } |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // PlzNavigate: Test final state after a complete navigation (to avoid repeating | 103 // PlzNavigate: Test final state after a complete browser-initiated navigation |
| 104 // these checks in other tests). | 104 // (to avoid repeating these checks in other tests). |
| 105 TEST_F(NavigatorTestWithBrowserSideNavigation, NavigationFinishedState) { | 105 TEST_F(NavigatorTestWithBrowserSideNavigation, |
| 106 BrowserInitiatedNavigateAndCommit) { | |
| 106 const GURL kUrl("http://chromium.org/"); | 107 const GURL kUrl("http://chromium.org/"); |
| 108 | |
| 109 EXPECT_FALSE(main_test_rfh()->IsRenderFrameLive()); | |
| 110 | |
| 107 contents()->NavigateAndCommit(kUrl); | 111 contents()->NavigateAndCommit(kUrl); |
| 112 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | |
| 108 ASSERT_TRUE(main_test_rfh()); | 113 ASSERT_TRUE(main_test_rfh()); |
| 109 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); | 114 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); |
| 110 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), | 115 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), |
| 111 main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 116 main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
| 112 EXPECT_EQ(kUrl, contents()->GetLastCommittedURL()); | 117 EXPECT_EQ(kUrl, contents()->GetLastCommittedURL()); |
| 118 EXPECT_FALSE(GetNavigationRequestForFrameTreeNode(node)); | |
| 113 | 119 |
| 114 // After a navigation is finished no speculative RenderFrameHost should | 120 // After a navigation is finished no speculative RenderFrameHost should |
| 115 // exist. | 121 // exist. |
| 116 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | |
| 117 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 122 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 118 | |
|
clamy
2015/02/10 15:41:22
nit: do not remove the empty line here.
carlosk
2015/02/10 18:27:09
Done.
| |
| 119 // With PlzNavigate enabled a pending RenderFrameHost should never exist. | 123 // With PlzNavigate enabled a pending RenderFrameHost should never exist. |
| 120 EXPECT_FALSE(node->render_manager()->pending_frame_host()); | 124 EXPECT_FALSE(node->render_manager()->pending_frame_host()); |
| 121 } | 125 } |
| 122 | 126 |
| 127 // PlzNavigate: Test a simple renderer initiated navigation starting with a | |
|
clamy
2015/02/10 15:41:22
nit: renderer-initiated.
carlosk
2015/02/10 18:27:09
Done.
| |
| 128 // non-live renderer. | |
| 129 TEST_F(NavigatorTestWithBrowserSideNavigation, | |
| 130 SimpleRendererInitiatedNavigation) { | |
|
clamy
2015/02/10 15:41:22
nit: I would rename the test RendererInitiatedNavi
carlosk
2015/02/10 18:27:09
Done. As discussed offline I'm expanding the previ
| |
| 131 const GURL kUrl("http://chromium.org/"); | |
| 132 | |
| 133 EXPECT_FALSE(main_test_rfh()->IsRenderFrameLive()); | |
| 134 | |
| 135 main_test_rfh()->SendBeginNavigationWithURL(kUrl); | |
|
clamy
2015/02/10 15:41:22
nit: Maybe a "// Start a renderer-initiated naviga
carlosk
2015/02/10 18:27:09
Done.
| |
| 136 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | |
| 137 NavigationRequest* request = GetNavigationRequestForFrameTreeNode(node); | |
| 138 ASSERT_TRUE(request); | |
| 139 EXPECT_EQ(kUrl, request->common_params().url); | |
| 140 EXPECT_FALSE(request->browser_initiated()); | |
| 141 EXPECT_EQ(NavigationRequest::STARTED, request->state()); | |
| 142 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | |
| 143 | |
| 144 // Request the RenderFrameHost to commit. | |
|
clamy
2015/02/10 15:41:22
I would rephrase that as: Have the current RenderF
carlosk
2015/02/10 18:27:09
Done.
| |
| 145 scoped_refptr<ResourceResponse> response(new ResourceResponse); | |
| 146 GetLoaderForNavigationRequest(request) | |
| 147 ->CallOnResponseStarted(response, MakeEmptyStream()); | |
| 148 EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); | |
| 149 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state()); | |
| 150 | |
| 151 // And commit provisional load. | |
|
clamy
2015/02/10 15:41:22
nit: maybe rephrase as The navigation commits. ?
carlosk
2015/02/10 18:27:09
Done.
| |
| 152 main_test_rfh()->SendNavigate(0, kUrl); | |
| 153 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); | |
| 154 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), | |
| 155 main_test_rfh()->GetSiteInstance()->GetSiteURL()); | |
| 156 EXPECT_EQ(kUrl, contents()->GetLastCommittedURL()); | |
| 157 EXPECT_FALSE(GetNavigationRequestForFrameTreeNode(node)); | |
| 158 | |
| 159 // After a navigation is finished no speculative RenderFrameHost should | |
| 160 // exist. | |
| 161 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | |
| 162 // With PlzNavigate enabled a pending RenderFrameHost should never exist. | |
|
clamy
2015/02/10 15:41:22
nit: add an empty line above the comment.
carlosk
2015/02/10 18:27:09
Done. In fact moved the comments to the previous t
| |
| 163 EXPECT_FALSE(node->render_manager()->pending_frame_host()); | |
| 164 } | |
| 165 | |
| 166 // PlzNavigate: Test that the renderer can cancel a navigation with a proper | |
| 167 // BeforeUnloadACK. | |
|
clamy
2015/02/10 15:41:22
I would rephrase as: Test that a beforeUnload deni
carlosk
2015/02/10 18:27:09
Done.
| |
| 168 TEST_F(NavigatorTestWithBrowserSideNavigation, | |
| 169 BeforeUnloadCancelledNavigation) { | |
|
clamy
2015/02/10 15:41:22
nit: maybe rename the test to BeforeUnloadDenialCa
carlosk
2015/02/10 18:27:09
Done.
| |
| 170 const GURL kUrl1("http://www.google.com/"); | |
| 171 const GURL kUrl2("http://www.chromium.org/"); | |
| 172 | |
| 173 contents()->NavigateAndCommit(kUrl1); | |
| 174 | |
| 175 // Start a new navigation | |
|
clamy
2015/02/10 15:41:22
nit: add a . at the end of the comment.
carlosk
2015/02/10 18:27:09
Done.
| |
| 176 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | |
| 177 SendRequestNavigation(node, kUrl2); | |
| 178 NavigationRequest* request = GetNavigationRequestForFrameTreeNode(node); | |
| 179 ASSERT_TRUE(request); | |
| 180 EXPECT_TRUE(request->browser_initiated()); | |
| 181 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, request->state()); | |
| 182 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | |
| 183 | |
| 184 // Simulate a BeforeUnloadACK IPC with a signal to NOT proceed. | |
|
clamy
2015/02/10 15:41:22
nit: Simulate a beforeUnload denial.
carlosk
2015/02/10 18:27:09
Done.
| |
| 185 main_test_rfh()->SendBeforeUnloadACK(false); | |
| 186 EXPECT_FALSE(GetNavigationRequestForFrameTreeNode(node)); | |
| 187 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | |
| 188 } | |
| 189 | |
| 123 // PlzNavigate: Test that a proper NavigationRequest is created by | 190 // PlzNavigate: Test that a proper NavigationRequest is created by |
| 124 // BeginNavigation. | 191 // RequestNavigation. |
| 125 // Note that all PlzNavigate methods on the browser side require the use of the | |
| 126 // flag kEnableBrowserSideNavigation. | |
| 127 TEST_F(NavigatorTestWithBrowserSideNavigation, BeginNavigation) { | 192 TEST_F(NavigatorTestWithBrowserSideNavigation, BeginNavigation) { |
| 128 const GURL kUrl1("http://www.google.com/"); | 193 const GURL kUrl1("http://www.google.com/"); |
| 129 const GURL kUrl2("http://www.chromium.org/"); | 194 const GURL kUrl2("http://www.chromium.org/"); |
| 130 const GURL kUrl3("http://www.gmail.com/"); | 195 const GURL kUrl3("http://www.gmail.com/"); |
| 131 | 196 |
| 132 contents()->NavigateAndCommit(kUrl1); | 197 contents()->NavigateAndCommit(kUrl1); |
| 133 | 198 |
| 134 // Add a subframe. | 199 // Add a subframe. |
| 135 FrameTreeNode* root_node = contents()->GetFrameTree()->root(); | 200 FrameTreeNode* root_node = contents()->GetFrameTree()->root(); |
| 136 TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child"); | 201 TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child"); |
| 137 ASSERT_TRUE(subframe_rfh); | 202 ASSERT_TRUE(subframe_rfh); |
| 138 | 203 |
| 204 // Start a navigation at the subframe | |
|
clamy
2015/02/10 15:41:22
nit: add . at the end of the comment.
carlosk
2015/02/10 18:27:09
Done.
| |
| 139 FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node(); | 205 FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node(); |
| 140 SendRequestNavigation(subframe_node, kUrl2); | 206 SendRequestNavigation(subframe_node, kUrl2); |
| 141 // There is no previous renderer in the subframe, so BeginNavigation is | |
| 142 // handled already. | |
| 143 NavigationRequest* subframe_request = | 207 NavigationRequest* subframe_request = |
| 144 GetNavigationRequestForFrameTreeNode(subframe_node); | 208 GetNavigationRequestForFrameTreeNode(subframe_node); |
| 145 TestNavigationURLLoader* subframe_loader = | 209 TestNavigationURLLoader* subframe_loader = |
| 146 GetLoaderForNavigationRequest(subframe_request); | 210 GetLoaderForNavigationRequest(subframe_request); |
| 147 ASSERT_TRUE(subframe_request); | 211 ASSERT_TRUE(subframe_request); |
| 148 EXPECT_EQ(kUrl2, subframe_request->common_params().url); | 212 EXPECT_EQ(kUrl2, subframe_request->common_params().url); |
| 149 EXPECT_EQ(kUrl2, subframe_loader->request_info()->common_params.url); | 213 EXPECT_EQ(kUrl2, subframe_loader->request_info()->common_params.url); |
| 150 // First party for cookies url should be that of the main frame. | 214 // First party for cookies url should be that of the main frame. |
| 151 EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); | 215 EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); |
| 152 EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); | 216 EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); |
| 153 EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); | 217 EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); |
| 218 EXPECT_TRUE(subframe_request->browser_initiated()); | |
| 219 // Subframe navigations should start right away as they don't have to request | |
| 220 // beforeUnload to run at the renderer. | |
|
clamy
2015/02/10 15:41:22
Please move this comment to where the previous rem
carlosk
2015/02/10 18:27:09
Done. But I moved a bit more things around so that
| |
| 221 EXPECT_EQ(NavigationRequest::STARTED, subframe_request->state()); | |
|
clamy
2015/02/10 15:41:22
Please move this expect below the call creating th
carlosk
2015/02/10 18:27:09
Yes, precisely. :)
| |
| 154 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); | 222 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); |
| 155 | 223 |
| 156 // Subframe navigations should never create a speculative RenderFrameHost, | 224 // Subframe navigations should never create a speculative RenderFrameHost, |
| 157 // unless site-per-process is enabled. In that case, as the subframe | 225 // unless site-per-process is enabled. In that case, as the subframe |
| 158 // navigation is to a different site and is still ongoing, it should have one. | 226 // navigation is to a different site and is still ongoing, it should have one. |
| 159 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 227 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 160 switches::kSitePerProcess)) { | 228 switches::kSitePerProcess)) { |
| 161 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); | 229 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); |
| 162 } else { | 230 } else { |
| 163 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); | 231 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); |
| 164 } | 232 } |
| 165 | 233 |
| 234 // Now start a navigation at the root node. | |
| 166 SendRequestNavigation(root_node, kUrl3); | 235 SendRequestNavigation(root_node, kUrl3); |
| 167 // Simulate a BeginNavigation IPC on the main frame. | |
| 168 main_test_rfh()->SendBeginNavigationWithURL(kUrl3); | |
| 169 NavigationRequest* main_request = | 236 NavigationRequest* main_request = |
| 170 GetNavigationRequestForFrameTreeNode(root_node); | 237 GetNavigationRequestForFrameTreeNode(root_node); |
| 238 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, | |
| 239 main_request->state()); | |
| 240 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); | |
| 241 | |
| 242 // Simulate a BeforeUnloadACK IPC on the main frame. | |
| 243 main_test_rfh()->SendBeforeUnloadACK(true); | |
| 171 TestNavigationURLLoader* main_loader = | 244 TestNavigationURLLoader* main_loader = |
| 172 GetLoaderForNavigationRequest(main_request); | 245 GetLoaderForNavigationRequest(main_request); |
| 173 ASSERT_TRUE(main_request); | 246 ASSERT_TRUE(main_request); |
| 174 EXPECT_EQ(kUrl3, main_request->common_params().url); | 247 EXPECT_EQ(kUrl3, main_request->common_params().url); |
| 175 EXPECT_EQ(kUrl3, main_loader->request_info()->common_params.url); | 248 EXPECT_EQ(kUrl3, main_loader->request_info()->common_params.url); |
| 176 EXPECT_EQ(kUrl3, main_loader->request_info()->first_party_for_cookies); | 249 EXPECT_EQ(kUrl3, main_loader->request_info()->first_party_for_cookies); |
| 177 EXPECT_TRUE(main_loader->request_info()->is_main_frame); | 250 EXPECT_TRUE(main_loader->request_info()->is_main_frame); |
| 178 EXPECT_FALSE(main_loader->request_info()->parent_is_main_frame); | 251 EXPECT_FALSE(main_loader->request_info()->parent_is_main_frame); |
| 252 EXPECT_TRUE(main_request->browser_initiated()); | |
| 253 // BeforeUnloadACK was received form the renderer so the navigation should | |
|
clamy
2015/02/10 15:41:22
nit: s/form/from
carlosk
2015/02/10 18:27:09
Done.
| |
| 254 // have started. | |
| 255 EXPECT_EQ(NavigationRequest::STARTED, main_request->state()); | |
| 179 | 256 |
| 180 // Main frame navigation to a different site should use a speculative | 257 // Main frame navigation to a different site should use a speculative |
| 181 // RenderFrameHost. | 258 // RenderFrameHost. |
| 182 EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); | 259 EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); |
| 183 | 260 |
| 184 // As the main frame hasn't yet committed the subframe still exists. Thus, the | 261 // As the main frame hasn't yet committed the subframe still exists. Thus, the |
| 185 // above situation regarding subframe navigations is valid here. | 262 // above situation regarding subframe navigations is valid here. |
| 186 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 263 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 187 switches::kSitePerProcess)) { | 264 switches::kSitePerProcess)) { |
| 188 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); | 265 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); |
| 189 } else { | 266 } else { |
| 190 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); | 267 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); |
| 191 } | 268 } |
| 192 } | 269 } |
| 193 | 270 |
| 194 // PlzNavigate: Test that RequestNavigation creates a NavigationRequest and that | 271 // PlzNavigate: Test that RequestNavigation creates a NavigationRequest and that |
| 195 // RenderFrameHost is not modified when the navigation commits. | 272 // RenderFrameHost is not modified when the navigation commits. |
| 196 TEST_F(NavigatorTestWithBrowserSideNavigation, NoLiveRenderer) { | 273 TEST_F(NavigatorTestWithBrowserSideNavigation, NoLiveRenderer) { |
| 197 const GURL kUrl("http://www.google.com/"); | 274 const GURL kUrl("http://www.google.com/"); |
| 198 | 275 |
| 199 EXPECT_FALSE(main_test_rfh()->render_view_host()->IsRenderViewLive()); | 276 EXPECT_FALSE(main_test_rfh()->render_view_host()->IsRenderViewLive()); |
| 200 RenderFrameHostImpl* rfh = main_test_rfh(); | 277 RenderFrameHostImpl* rfh = main_test_rfh(); |
| 201 FrameTreeNode* node = rfh->frame_tree_node(); | 278 FrameTreeNode* node = rfh->frame_tree_node(); |
| 202 SendRequestNavigation(node, kUrl); | 279 SendRequestNavigation(node, kUrl); |
| 203 | 280 |
| 204 // A NavigationRequest should have been generated. | 281 // A NavigationRequest should have been generated. |
| 205 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); | 282 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); |
| 206 EXPECT_TRUE(main_request != NULL); | 283 EXPECT_TRUE(main_request != NULL); |
| 284 // As there's not live renderer the navigation should not wait for a response | |
|
clamy
2015/02/10 15:41:22
nit: s/not/no
nit: s/response/beforeUnload ACK
carlosk
2015/02/10 18:27:09
Done but mind that this whole test moved into the
| |
| 285 // from the renderer and start right away. | |
| 286 EXPECT_EQ(NavigationRequest::STARTED, main_request->state()); | |
| 207 | 287 |
| 208 // Since we're re-using the current RenderFrameHost, no speculative one should | 288 // Since we're re-using the current RenderFrameHost, no speculative one should |
| 209 // be created. | 289 // be created. |
| 210 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 290 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 211 | 291 |
| 212 // Now return the response without any redirects. This will cause the | 292 // Now return the response without any redirects. This will cause the |
| 213 // navigation to commit at the same URL. | 293 // navigation to commit at the same URL. |
| 214 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 294 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 215 GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted( | 295 GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted( |
| 216 response, MakeEmptyStream()); | 296 response, MakeEmptyStream()); |
| 217 main_request = GetNavigationRequestForFrameTreeNode(node); | 297 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, main_request->state()); |
| 218 | 298 |
| 219 // The main RFH should not have been changed, and the renderer should have | 299 // The main RFH should not have been changed, and the renderer should have |
| 220 // been initialized. | 300 // been initialized. |
| 221 EXPECT_EQ(rfh, main_test_rfh()); | 301 EXPECT_EQ(rfh, main_test_rfh()); |
| 222 EXPECT_TRUE(main_test_rfh()->IsRenderFrameLive()); | 302 EXPECT_TRUE(main_test_rfh()->IsRenderFrameLive()); |
| 223 EXPECT_TRUE(main_test_rfh()->render_view_host()->IsRenderViewLive()); | 303 EXPECT_TRUE(main_test_rfh()->render_view_host()->IsRenderViewLive()); |
| 224 } | 304 } |
| 225 | 305 |
| 226 // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels | 306 // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels |
| 227 // the navigation. | 307 // the navigation. |
| 228 TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) { | 308 TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) { |
| 229 const GURL kUrl1("http://www.chromium.org/"); | 309 const GURL kUrl1("http://www.chromium.org/"); |
| 230 const GURL kUrl2("http://www.google.com/"); | 310 const GURL kUrl2("http://www.google.com/"); |
| 231 | 311 |
| 232 // Load a URL. | 312 // Load a URL. |
| 233 contents()->NavigateAndCommit(kUrl1); | 313 contents()->NavigateAndCommit(kUrl1); |
| 234 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 314 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 235 | 315 |
| 236 // Navigate to a different site. | 316 // Navigate to a different site. |
| 237 process()->sink().ClearMessages(); | 317 process()->sink().ClearMessages(); |
| 238 SendRequestNavigation(node, kUrl2); | 318 SendRequestNavigation(node, kUrl2); |
| 239 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 319 main_test_rfh()->SendBeforeUnloadACK(true); |
| 240 | 320 |
| 241 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); | 321 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); |
| 242 ASSERT_TRUE(main_request); | 322 ASSERT_TRUE(main_request); |
| 243 | 323 |
| 244 // Navigations to a different site do create a speculative RenderFrameHost. | 324 // Navigations to a different site do create a speculative RenderFrameHost. |
| 245 EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); | 325 EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); |
| 246 | 326 |
| 247 // Commit an HTTP 204 response. | 327 // Commit an HTTP 204 response. |
| 248 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 328 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 249 const char kNoContentHeaders[] = "HTTP/1.1 204 No Content\0\0"; | 329 const char kNoContentHeaders[] = "HTTP/1.1 204 No Content\0\0"; |
| 250 response->head.headers = new net::HttpResponseHeaders( | 330 response->head.headers = new net::HttpResponseHeaders( |
| 251 std::string(kNoContentHeaders, arraysize(kNoContentHeaders))); | 331 std::string(kNoContentHeaders, arraysize(kNoContentHeaders))); |
| 252 GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted( | 332 GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted( |
| 253 response, MakeEmptyStream()); | 333 response, MakeEmptyStream()); |
| 254 | 334 |
| 255 // There should be no pending nor speculative RenderFrameHost; the navigation | 335 // There should be no pending nor speculative RenderFrameHost; the navigation |
| 256 // was aborted. | 336 // was aborted. |
| 257 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); | 337 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| 258 EXPECT_FALSE(GetNavigationRequestForFrameTreeNode(node)); | 338 EXPECT_FALSE(GetNavigationRequestForFrameTreeNode(node)); |
| 259 EXPECT_FALSE(node->render_manager()->pending_frame_host()); | 339 EXPECT_FALSE(node->render_manager()->pending_frame_host()); |
| 260 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 340 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 261 | 341 |
| 262 // Now, repeat the test with 205 Reset Content. | 342 // Now, repeat the test with 205 Reset Content. |
| 263 | 343 |
| 264 // Navigate to a different site again. | 344 // Navigate to a different site again. |
| 265 process()->sink().ClearMessages(); | 345 process()->sink().ClearMessages(); |
| 266 SendRequestNavigation(node, kUrl2); | 346 SendRequestNavigation(node, kUrl2); |
| 267 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 347 main_test_rfh()->SendBeforeUnloadACK(true); |
| 268 | 348 |
| 269 main_request = GetNavigationRequestForFrameTreeNode(node); | 349 main_request = GetNavigationRequestForFrameTreeNode(node); |
| 270 ASSERT_TRUE(main_request); | 350 ASSERT_TRUE(main_request); |
| 271 EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); | 351 EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); |
| 272 | 352 |
| 273 // Commit an HTTP 205 response. | 353 // Commit an HTTP 205 response. |
| 274 response = new ResourceResponse; | 354 response = new ResourceResponse; |
| 275 const char kResetContentHeaders[] = "HTTP/1.1 205 Reset Content\0\0"; | 355 const char kResetContentHeaders[] = "HTTP/1.1 205 Reset Content\0\0"; |
| 276 response->head.headers = new net::HttpResponseHeaders( | 356 response->head.headers = new net::HttpResponseHeaders( |
| 277 std::string(kResetContentHeaders, arraysize(kResetContentHeaders))); | 357 std::string(kResetContentHeaders, arraysize(kResetContentHeaders))); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 292 const GURL kUrl1("http://www.chromium.org/"); | 372 const GURL kUrl1("http://www.chromium.org/"); |
| 293 const GURL kUrl2("http://www.google.com/"); | 373 const GURL kUrl2("http://www.google.com/"); |
| 294 | 374 |
| 295 contents()->NavigateAndCommit(kUrl1); | 375 contents()->NavigateAndCommit(kUrl1); |
| 296 RenderFrameHostImpl* initial_rfh = main_test_rfh(); | 376 RenderFrameHostImpl* initial_rfh = main_test_rfh(); |
| 297 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 377 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 298 | 378 |
| 299 // Navigate to a different site. | 379 // Navigate to a different site. |
| 300 process()->sink().ClearMessages(); | 380 process()->sink().ClearMessages(); |
| 301 SendRequestNavigation(node, kUrl2); | 381 SendRequestNavigation(node, kUrl2); |
| 302 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 382 main_test_rfh()->SendBeforeUnloadACK(true); |
| 303 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); | 383 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); |
| 304 ASSERT_TRUE(main_request); | 384 ASSERT_TRUE(main_request); |
| 305 EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); | 385 EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); |
| 306 | 386 |
| 307 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 387 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 308 GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted( | 388 GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted( |
| 309 response, MakeEmptyStream()); | 389 response, MakeEmptyStream()); |
| 310 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); | 390 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 311 ASSERT_TRUE(speculative_rfh); | 391 ASSERT_TRUE(speculative_rfh); |
| 312 EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); | 392 EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 328 const GURL kUrl1("http://www.chromium.org/"); | 408 const GURL kUrl1("http://www.chromium.org/"); |
| 329 const GURL kUrl2("http://www.google.com/"); | 409 const GURL kUrl2("http://www.google.com/"); |
| 330 | 410 |
| 331 contents()->NavigateAndCommit(kUrl1); | 411 contents()->NavigateAndCommit(kUrl1); |
| 332 RenderFrameHostImpl* rfh = main_test_rfh(); | 412 RenderFrameHostImpl* rfh = main_test_rfh(); |
| 333 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 413 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 334 | 414 |
| 335 // Navigate to a URL on the same site. | 415 // Navigate to a URL on the same site. |
| 336 process()->sink().ClearMessages(); | 416 process()->sink().ClearMessages(); |
| 337 SendRequestNavigation(node, kUrl1); | 417 SendRequestNavigation(node, kUrl1); |
| 338 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); | 418 main_test_rfh()->SendBeforeUnloadACK(true); |
| 339 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); | 419 NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node); |
| 340 ASSERT_TRUE(main_request); | 420 ASSERT_TRUE(main_request); |
| 341 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 421 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 342 | 422 |
| 343 // It then redirects to another site. | 423 // It then redirects to another site. |
| 344 net::RedirectInfo redirect_info; | 424 net::RedirectInfo redirect_info; |
| 345 redirect_info.status_code = 302; | 425 redirect_info.status_code = 302; |
| 346 redirect_info.new_method = "GET"; | 426 redirect_info.new_method = "GET"; |
| 347 redirect_info.new_url = kUrl2; | 427 redirect_info.new_url = kUrl2; |
| 348 redirect_info.new_first_party_for_cookies = kUrl2; | 428 redirect_info.new_first_party_for_cookies = kUrl2; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 367 final_speculative_rfh->SendNavigate(0, kUrl2); | 447 final_speculative_rfh->SendNavigate(0, kUrl2); |
| 368 RenderFrameHostImpl* final_rfh = main_test_rfh(); | 448 RenderFrameHostImpl* final_rfh = main_test_rfh(); |
| 369 ASSERT_TRUE(final_rfh); | 449 ASSERT_TRUE(final_rfh); |
| 370 EXPECT_NE(rfh, final_rfh); | 450 EXPECT_NE(rfh, final_rfh); |
| 371 EXPECT_EQ(final_speculative_rfh, final_rfh); | 451 EXPECT_EQ(final_speculative_rfh, final_rfh); |
| 372 EXPECT_TRUE(final_rfh->IsRenderFrameLive()); | 452 EXPECT_TRUE(final_rfh->IsRenderFrameLive()); |
| 373 EXPECT_TRUE(final_rfh->render_view_host()->IsRenderViewLive()); | 453 EXPECT_TRUE(final_rfh->render_view_host()->IsRenderViewLive()); |
| 374 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 454 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 375 } | 455 } |
| 376 | 456 |
| 377 // PlzNavigate: Test that a navigation is canceled if another request has been | 457 // PlzNavigate: Test that a navigation is canceled if another browser-initiated |
| 378 // issued in the meantime. Also confirms that the speculative RenderFrameHost is | 458 // request has been issued in the meantime. Also confirms that the speculative |
| 379 // correctly updated in the process. | 459 // RenderFrameHost is correctly updated in the process. |
| 380 TEST_F(NavigatorTestWithBrowserSideNavigation, ReplacePendingNavigation) { | 460 TEST_F(NavigatorTestWithBrowserSideNavigation, |
| 461 BrowserInitiatedNavigationCancel) { | |
| 381 const GURL kUrl0("http://www.wikipedia.org/"); | 462 const GURL kUrl0("http://www.wikipedia.org/"); |
| 382 const GURL kUrl1("http://www.chromium.org/"); | 463 const GURL kUrl1("http://www.chromium.org/"); |
| 383 const GURL kUrl1_site = SiteInstance::GetSiteForURL(browser_context(), kUrl1); | 464 const GURL kUrl1_site = SiteInstance::GetSiteForURL(browser_context(), kUrl1); |
| 384 const GURL kUrl2("http://www.google.com/"); | 465 const GURL kUrl2("http://www.google.com/"); |
| 385 const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); | 466 const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); |
| 386 | 467 |
| 387 // Initialization. | 468 // Initialization. |
| 388 contents()->NavigateAndCommit(kUrl0); | 469 contents()->NavigateAndCommit(kUrl0); |
| 389 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 470 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 390 | 471 |
| 391 // Request navigation to the 1st URL. | 472 // Request navigation to the 1st URL. |
| 392 process()->sink().ClearMessages(); | 473 process()->sink().ClearMessages(); |
| 393 SendRequestNavigation(node, kUrl1); | 474 SendRequestNavigation(node, kUrl1); |
| 394 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); | 475 main_test_rfh()->SendBeforeUnloadACK(true); |
| 395 NavigationRequest* request1 = GetNavigationRequestForFrameTreeNode(node); | 476 NavigationRequest* request1 = GetNavigationRequestForFrameTreeNode(node); |
| 396 ASSERT_TRUE(request1); | 477 ASSERT_TRUE(request1); |
| 397 EXPECT_EQ(kUrl1, request1->common_params().url); | 478 EXPECT_EQ(kUrl1, request1->common_params().url); |
| 479 EXPECT_TRUE(request1->browser_initiated()); | |
| 398 base::WeakPtr<TestNavigationURLLoader> loader1 = | 480 base::WeakPtr<TestNavigationURLLoader> loader1 = |
| 399 GetLoaderForNavigationRequest(request1)->AsWeakPtr(); | 481 GetLoaderForNavigationRequest(request1)->AsWeakPtr(); |
| 400 | 482 |
| 401 // Confirm a speculative RFH was created. | 483 // Confirm a speculative RFH was created. |
| 402 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); | 484 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 403 ASSERT_TRUE(speculative_rfh); | 485 ASSERT_TRUE(speculative_rfh); |
| 404 int32 site_instance_id_1 = speculative_rfh->GetSiteInstance()->GetId(); | 486 int32 site_instance_id_1 = speculative_rfh->GetSiteInstance()->GetId(); |
| 405 EXPECT_EQ(kUrl1_site, speculative_rfh->GetSiteInstance()->GetSiteURL()); | 487 EXPECT_EQ(kUrl1_site, speculative_rfh->GetSiteInstance()->GetSiteURL()); |
| 406 | 488 |
| 407 // Request navigation to the 2nd URL; the NavigationRequest must have been | 489 // Request navigation to the 2nd URL; the NavigationRequest must have been |
| 408 // replaced by a new one with a different URL. | 490 // replaced by a new one with a different URL. |
| 409 SendRequestNavigation(node, kUrl2); | 491 SendRequestNavigation(node, kUrl2); |
| 410 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 492 main_test_rfh()->SendBeforeUnloadACK(true); |
| 411 NavigationRequest* request2 = GetNavigationRequestForFrameTreeNode(node); | 493 NavigationRequest* request2 = GetNavigationRequestForFrameTreeNode(node); |
| 412 ASSERT_TRUE(request2); | 494 ASSERT_TRUE(request2); |
| 413 EXPECT_EQ(kUrl2, request2->common_params().url); | 495 EXPECT_EQ(kUrl2, request2->common_params().url); |
| 496 EXPECT_TRUE(request2->browser_initiated()); | |
| 414 | 497 |
| 415 // Confirm that the first loader got destroyed. | 498 // Confirm that the first loader got destroyed. |
| 416 EXPECT_FALSE(loader1); | 499 EXPECT_FALSE(loader1); |
| 417 | 500 |
| 418 // Confirm that a new speculative RFH was created. | 501 // Confirm that a new speculative RFH was created. |
| 419 speculative_rfh = GetSpeculativeRenderFrameHost(node); | 502 speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 420 ASSERT_TRUE(speculative_rfh); | 503 ASSERT_TRUE(speculative_rfh); |
| 421 int32 site_instance_id_2 = speculative_rfh->GetSiteInstance()->GetId(); | 504 int32 site_instance_id_2 = speculative_rfh->GetSiteInstance()->GetId(); |
| 422 EXPECT_NE(site_instance_id_1, site_instance_id_2); | 505 EXPECT_NE(site_instance_id_1, site_instance_id_2); |
| 423 | 506 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 SpeculativeRendererWorksBaseCase) { | 565 SpeculativeRendererWorksBaseCase) { |
| 483 // Navigate to an initial site. | 566 // Navigate to an initial site. |
| 484 const GURL kUrlInit("http://wikipedia.org/"); | 567 const GURL kUrlInit("http://wikipedia.org/"); |
| 485 contents()->NavigateAndCommit(kUrlInit); | 568 contents()->NavigateAndCommit(kUrlInit); |
| 486 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 569 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 487 | 570 |
| 488 // Begin navigating to another site. | 571 // Begin navigating to another site. |
| 489 const GURL kUrl("http://google.com/"); | 572 const GURL kUrl("http://google.com/"); |
| 490 process()->sink().ClearMessages(); | 573 process()->sink().ClearMessages(); |
| 491 SendRequestNavigation(node, kUrl); | 574 SendRequestNavigation(node, kUrl); |
| 492 main_test_rfh()->SendBeginNavigationWithURL(kUrl); | 575 main_test_rfh()->SendBeforeUnloadACK(true); |
| 493 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); | 576 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 494 ASSERT_TRUE(speculative_rfh); | 577 ASSERT_TRUE(speculative_rfh); |
| 495 EXPECT_NE(speculative_rfh, main_test_rfh()); | 578 EXPECT_NE(speculative_rfh, main_test_rfh()); |
| 496 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), | 579 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), |
| 497 speculative_rfh->GetSiteInstance()->GetSiteURL()); | 580 speculative_rfh->GetSiteInstance()->GetSiteURL()); |
| 498 EXPECT_FALSE(node->render_manager()->pending_frame_host()); | 581 EXPECT_FALSE(node->render_manager()->pending_frame_host()); |
| 499 int32 site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); | 582 int32 site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); |
| 500 | 583 |
| 501 // Ask Navigator to commit the navigation by simulating a call to | 584 // Ask Navigator to commit the navigation by simulating a call to |
| 502 // OnResponseStarted. | 585 // OnResponseStarted. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 523 // Navigate to an initial site. | 606 // Navigate to an initial site. |
| 524 const GURL kUrlInit("http://wikipedia.org/"); | 607 const GURL kUrlInit("http://wikipedia.org/"); |
| 525 contents()->NavigateAndCommit(kUrlInit); | 608 contents()->NavigateAndCommit(kUrlInit); |
| 526 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 609 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 527 int32 init_site_instance_id = main_test_rfh()->GetSiteInstance()->GetId(); | 610 int32 init_site_instance_id = main_test_rfh()->GetSiteInstance()->GetId(); |
| 528 | 611 |
| 529 // Begin navigating to another site. | 612 // Begin navigating to another site. |
| 530 const GURL kUrl("http://google.com/"); | 613 const GURL kUrl("http://google.com/"); |
| 531 process()->sink().ClearMessages(); | 614 process()->sink().ClearMessages(); |
| 532 SendRequestNavigation(node, kUrl); | 615 SendRequestNavigation(node, kUrl); |
| 533 main_test_rfh()->SendBeginNavigationWithURL(kUrl); | 616 main_test_rfh()->SendBeforeUnloadACK(true); |
| 534 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); | 617 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 535 int32 site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); | 618 int32 site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); |
| 536 EXPECT_NE(init_site_instance_id, site_instance_id); | 619 EXPECT_NE(init_site_instance_id, site_instance_id); |
| 537 EXPECT_EQ(init_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); | 620 EXPECT_EQ(init_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); |
| 538 ASSERT_TRUE(speculative_rfh); | 621 ASSERT_TRUE(speculative_rfh); |
| 539 EXPECT_NE(speculative_rfh, main_test_rfh()); | 622 EXPECT_NE(speculative_rfh, main_test_rfh()); |
| 540 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), | 623 EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), |
| 541 speculative_rfh->GetSiteInstance()->GetSiteURL()); | 624 speculative_rfh->GetSiteInstance()->GetSiteURL()); |
| 542 | 625 |
| 543 // It then redirects to yet another site. | 626 // It then redirects to yet another site. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); | 696 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); |
| 614 EXPECT_TRUE(rfhm->IsOnSwappedOutList(rfh1)); | 697 EXPECT_TRUE(rfhm->IsOnSwappedOutList(rfh1)); |
| 615 | 698 |
| 616 // Now go back to the initial site so that the swapped out RenderFrameHost | 699 // Now go back to the initial site so that the swapped out RenderFrameHost |
| 617 // should be reused. | 700 // should be reused. |
| 618 process()->sink().ClearMessages(); | 701 process()->sink().ClearMessages(); |
| 619 static_cast<MockRenderProcessHost*>(rfh1->GetProcess()) | 702 static_cast<MockRenderProcessHost*>(rfh1->GetProcess()) |
| 620 ->sink() | 703 ->sink() |
| 621 .ClearMessages(); | 704 .ClearMessages(); |
| 622 SendRequestNavigation(node, kUrl1); | 705 SendRequestNavigation(node, kUrl1); |
| 623 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); | 706 main_test_rfh()->SendBeforeUnloadACK(true); |
| 624 EXPECT_EQ(rfh1, GetSpeculativeRenderFrameHost(node)); | 707 EXPECT_EQ(rfh1, GetSpeculativeRenderFrameHost(node)); |
| 625 EXPECT_NE(RenderFrameHostImpl::STATE_DEFAULT, | 708 EXPECT_NE(RenderFrameHostImpl::STATE_DEFAULT, |
| 626 GetSpeculativeRenderFrameHost(node)->rfh_state()); | 709 GetSpeculativeRenderFrameHost(node)->rfh_state()); |
| 627 | 710 |
| 628 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 711 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 629 GetLoaderForNavigationRequest(GetNavigationRequestForFrameTreeNode(node)) | 712 GetLoaderForNavigationRequest(GetNavigationRequestForFrameTreeNode(node)) |
| 630 ->CallOnResponseStarted(response, MakeEmptyStream()); | 713 ->CallOnResponseStarted(response, MakeEmptyStream()); |
| 631 EXPECT_EQ(rfh1, GetSpeculativeRenderFrameHost(node)); | 714 EXPECT_EQ(rfh1, GetSpeculativeRenderFrameHost(node)); |
| 632 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, | 715 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, |
| 633 GetSpeculativeRenderFrameHost(node)->rfh_state()); | 716 GetSpeculativeRenderFrameHost(node)->rfh_state()); |
| 634 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); | 717 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); |
| 635 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); | 718 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
| 636 | 719 |
| 637 rfh1->SendNavigate(1, kUrl1); | 720 rfh1->SendNavigate(1, kUrl1); |
| 638 EXPECT_EQ(rfh1, main_test_rfh()); | 721 EXPECT_EQ(rfh1, main_test_rfh()); |
| 639 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 722 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 640 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); | 723 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); |
| 641 } | 724 } |
| 642 | 725 |
| 643 } // namespace content | 726 } // namespace content |
| OLD | NEW |