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 "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 <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2232 " +--Site A -- proxies for B\n" | 2232 " +--Site A -- proxies for B\n" |
| 2233 "Where A = http://127.0.0.1/\n" | 2233 "Where A = http://127.0.0.1/\n" |
| 2234 " B = http://foo.com/", | 2234 " B = http://foo.com/", |
| 2235 visualizer.DepictFrameTree(root)); | 2235 visualizer.DepictFrameTree(root)); |
| 2236 } | 2236 } |
| 2237 } | 2237 } |
| 2238 | 2238 |
| 2239 // Verify the tree of FrameNavigationEntries after NAVIGATION_TYPE_NEW_SUBFRAME | 2239 // Verify the tree of FrameNavigationEntries after NAVIGATION_TYPE_NEW_SUBFRAME |
| 2240 // commits. | 2240 // commits. |
| 2241 // Disabled due to flakes; see https://crbug.com/646836. | 2241 // Disabled due to flakes; see https://crbug.com/646836. |
| 2242 #if defined(OS_ANDROID) || defined(OS_LINUX) | |
| 2243 #define MAYBE_FrameNavigationEntry_NewSubframe \ | |
| 2244 DISABLED_FrameNavigationEntry_NewSubframe | |
| 2245 #else | |
| 2246 #define MAYBE_FrameNavigationEntry_NewSubframe FrameNavigationEntry_NewSubframe | |
| 2247 #endif | |
| 2248 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 2242 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 2249 MAYBE_FrameNavigationEntry_NewSubframe) { | 2243 FrameNavigationEntry_NewSubframe) { |
| 2250 GURL main_url(embedded_test_server()->GetURL( | 2244 GURL main_url(embedded_test_server()->GetURL( |
| 2251 "/navigation_controller/simple_page_1.html")); | 2245 "/navigation_controller/simple_page_1.html")); |
| 2252 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2246 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 2253 const NavigationControllerImpl& controller = | 2247 const NavigationControllerImpl& controller = |
| 2254 static_cast<const NavigationControllerImpl&>( | 2248 static_cast<const NavigationControllerImpl&>( |
| 2255 shell()->web_contents()->GetController()); | 2249 shell()->web_contents()->GetController()); |
| 2256 FrameTreeNode* root = | 2250 FrameTreeNode* root = |
| 2257 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 2251 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 2258 GetFrameTree()->root(); | 2252 GetFrameTree()->root(); |
| 2259 | 2253 |
| 2260 // 1. Create a same-site iframe. | 2254 // 1. Create a same-site iframe. |
| 2261 GURL frame_url(embedded_test_server()->GetURL( | 2255 GURL frame_url(embedded_test_server()->GetURL( |
| 2262 "/navigation_controller/simple_page_2.html")); | 2256 "/navigation_controller/simple_page_2.html")); |
| 2263 { | 2257 { |
| 2264 LoadCommittedCapturer capturer(shell()->web_contents()); | 2258 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2265 std::string script = "var iframe = document.createElement('iframe');" | 2259 std::string script = "var iframe = document.createElement('iframe');" |
| 2266 "iframe.src = '" + frame_url.spec() + "';" | 2260 "iframe.src = '" + frame_url.spec() + "';" |
| 2267 "document.body.appendChild(iframe);"; | 2261 "document.body.appendChild(iframe);"; |
| 2268 EXPECT_TRUE(ExecuteScript(root, script)); | 2262 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2269 capturer.Wait(); | 2263 capturer.Wait(); |
| 2270 } | 2264 } |
| 2271 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); | 2265 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 2272 | 2266 |
| 2273 // 2. Navigate in the subframe same-site. | 2267 // 2. Navigate in the subframe same-site. |
| 2274 GURL frame_url2(embedded_test_server()->GetURL( | 2268 GURL frame_url2(embedded_test_server()->GetURL( |
| 2275 "/navigation_controller/page_with_links.html")); | 2269 "/navigation_controller/page_with_links.html")); |
| 2276 { | 2270 { |
| 2277 FrameNavigateParamsCapturer capturer(root->child_at(0)); | 2271 FrameNavigateParamsCapturer capturer(root->child_at(0)); |
| 2278 NavigateFrameToURL(root->child_at(0), frame_url2); | 2272 NavigateFrameToURL(root->child_at(0), frame_url2); |
|
Łukasz Anforowicz
2016/11/07 22:13:25
No need for RenderFrameDeletedObserver here? Is t
Charlie Reis
2016/11/07 22:54:51
Correct. The RenderFrame won't be deleted on same
| |
| 2279 capturer.Wait(); | 2273 capturer.Wait(); |
| 2280 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2274 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
| 2281 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); | 2275 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
| 2282 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 2276 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 2283 } | 2277 } |
| 2284 | 2278 |
| 2285 // We should have created a new NavigationEntry with the same main frame URL. | 2279 // We should have created a new NavigationEntry with the same main frame URL. |
| 2286 EXPECT_EQ(2, controller.GetEntryCount()); | 2280 EXPECT_EQ(2, controller.GetEntryCount()); |
| 2287 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 2281 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 2288 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); | 2282 NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2307 { | 2301 { |
| 2308 LoadCommittedCapturer capturer(shell()->web_contents()); | 2302 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2309 std::string script = "var iframe = document.createElement('iframe');" | 2303 std::string script = "var iframe = document.createElement('iframe');" |
| 2310 "iframe.src = '" + foo_url.spec() + "';" | 2304 "iframe.src = '" + foo_url.spec() + "';" |
| 2311 "document.body.appendChild(iframe);"; | 2305 "document.body.appendChild(iframe);"; |
| 2312 EXPECT_TRUE(ExecuteScript(root, script)); | 2306 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2313 capturer.Wait(); | 2307 capturer.Wait(); |
| 2314 } | 2308 } |
| 2315 | 2309 |
| 2316 // 4. Create a nested same-site iframe in the second subframe, wait for it to | 2310 // 4. Create a nested same-site iframe in the second subframe, wait for it to |
| 2317 // commit, then navigate it again. | 2311 // commit, then navigate it again cross-site. |
| 2318 { | 2312 { |
| 2319 LoadCommittedCapturer capturer(shell()->web_contents()); | 2313 LoadCommittedCapturer capturer(shell()->web_contents()); |
| 2320 std::string script = "var iframe = document.createElement('iframe');" | 2314 std::string script = "var iframe = document.createElement('iframe');" |
| 2321 "iframe.src = '" + foo_url.spec() + "';" | 2315 "iframe.src = '" + foo_url.spec() + "';" |
| 2322 "document.body.appendChild(iframe);"; | 2316 "document.body.appendChild(iframe);"; |
| 2323 EXPECT_TRUE(ExecuteScript(root->child_at(1), script)); | 2317 EXPECT_TRUE(ExecuteScript(root->child_at(1), script)); |
| 2324 capturer.Wait(); | 2318 capturer.Wait(); |
| 2325 } | 2319 } |
| 2326 GURL bar_url(embedded_test_server()->GetURL( | 2320 GURL bar_url(embedded_test_server()->GetURL( |
| 2327 "bar.com", "/navigation_controller/simple_page_1.html")); | 2321 "bar.com", "/navigation_controller/simple_page_1.html")); |
| 2328 { | 2322 { |
| 2329 FrameNavigateParamsCapturer capturer(root->child_at(1)->child_at(0)); | 2323 FrameNavigateParamsCapturer capturer(root->child_at(1)->child_at(0)); |
| 2324 RenderFrameDeletedObserver deleted_observer( | |
| 2325 root->child_at(1)->child_at(0)->current_frame_host()); | |
| 2330 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url); | 2326 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url); |
| 2327 // Wait for the RenderFrame to go away, if this will be cross-process. | |
| 2328 if (AreAllSitesIsolatedForTesting()) | |
| 2329 deleted_observer.WaitUntilDeleted(); | |
| 2331 capturer.Wait(); | 2330 capturer.Wait(); |
| 2332 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2331 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
| 2333 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); | 2332 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
| 2334 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 2333 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 2335 } | 2334 } |
| 2336 | 2335 |
| 2337 // We should have created a new NavigationEntry with the same main frame URL. | 2336 // We should have created a new NavigationEntry with the same main frame URL. |
| 2338 EXPECT_EQ(3, controller.GetEntryCount()); | 2337 EXPECT_EQ(3, controller.GetEntryCount()); |
| 2339 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 2338 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 2340 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); | 2339 NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2356 } else { | 2355 } else { |
| 2357 // There are no subframe FrameNavigationEntries by default. | 2356 // There are no subframe FrameNavigationEntries by default. |
| 2358 EXPECT_EQ(0U, entry3->root_node()->children.size()); | 2357 EXPECT_EQ(0U, entry3->root_node()->children.size()); |
| 2359 } | 2358 } |
| 2360 | 2359 |
| 2361 // 6. Navigate the second subframe cross-site, clearing its existing subtree. | 2360 // 6. Navigate the second subframe cross-site, clearing its existing subtree. |
| 2362 GURL baz_url(embedded_test_server()->GetURL( | 2361 GURL baz_url(embedded_test_server()->GetURL( |
| 2363 "baz.com", "/navigation_controller/simple_page_1.html")); | 2362 "baz.com", "/navigation_controller/simple_page_1.html")); |
| 2364 { | 2363 { |
| 2365 FrameNavigateParamsCapturer capturer(root->child_at(1)); | 2364 FrameNavigateParamsCapturer capturer(root->child_at(1)); |
| 2365 RenderFrameDeletedObserver deleted_observer( | |
| 2366 root->child_at(1)->current_frame_host()); | |
| 2366 std::string script = "var frames = document.getElementsByTagName('iframe');" | 2367 std::string script = "var frames = document.getElementsByTagName('iframe');" |
| 2367 "frames[1].src = '" + baz_url.spec() + "';"; | 2368 "frames[1].src = '" + baz_url.spec() + "';"; |
| 2368 EXPECT_TRUE(ExecuteScript(root, script)); | 2369 EXPECT_TRUE(ExecuteScript(root, script)); |
| 2370 // Wait for the RenderFrame to go away, if this will be cross-process. | |
| 2371 if (AreAllSitesIsolatedForTesting()) | |
| 2372 deleted_observer.WaitUntilDeleted(); | |
| 2369 capturer.Wait(); | 2373 capturer.Wait(); |
| 2370 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( | 2374 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( |
| 2371 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); | 2375 capturer.params().transition, ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
| 2372 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); | 2376 EXPECT_EQ(NAVIGATION_TYPE_NEW_SUBFRAME, capturer.details().type); |
| 2373 } | 2377 } |
| 2374 | 2378 |
| 2375 // We should have created a new NavigationEntry with the same main frame URL. | 2379 // We should have created a new NavigationEntry with the same main frame URL. |
| 2376 EXPECT_EQ(4, controller.GetEntryCount()); | 2380 EXPECT_EQ(4, controller.GetEntryCount()); |
| 2377 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); | 2381 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 2378 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); | 2382 NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); |
| (...skipping 4524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6903 // Verify that the extra header was NOT present for the subresource. | 6907 // Verify that the extra header was NOT present for the subresource. |
| 6904 const net::test_server::HttpRequest* image_request = | 6908 const net::test_server::HttpRequest* image_request = |
| 6905 FindAccumulatedRequest(image_url); | 6909 FindAccumulatedRequest(image_url); |
| 6906 ASSERT_TRUE(image_request); | 6910 ASSERT_TRUE(image_request); |
| 6907 EXPECT_THAT(image_request->headers, | 6911 EXPECT_THAT(image_request->headers, |
| 6908 testing::Not(testing::Contains( | 6912 testing::Not(testing::Contains( |
| 6909 testing::Key("X-ExtraHeadersVsSubresources")))); | 6913 testing::Key("X-ExtraHeadersVsSubresources")))); |
| 6910 } | 6914 } |
| 6911 | 6915 |
| 6912 } // namespace content | 6916 } // namespace content |
| OLD | NEW |