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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2161393002: Clone children of FrameNavigationEntries for in-page navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 #endif 290 #endif
291 same_tab_observer.Wait(); 291 same_tab_observer.Wait();
292 EXPECT_EQ(1, controller.GetEntryCount()); 292 EXPECT_EQ(1, controller.GetEntryCount());
293 const GURL data_url = controller.GetLastCommittedEntry()->GetURL(); 293 const GURL data_url = controller.GetLastCommittedEntry()->GetURL();
294 294
295 // Perform a fragment navigation using a javascript: URL. 295 // Perform a fragment navigation using a javascript: URL.
296 GURL js_url("javascript:document.location = '#frag';"); 296 GURL js_url("javascript:document.location = '#frag';");
297 NavigateToURL(shell(), js_url); 297 NavigateToURL(shell(), js_url);
298 EXPECT_EQ(2, controller.GetEntryCount()); 298 EXPECT_EQ(2, controller.GetEntryCount());
299 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); 299 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
300 // TODO(boliu): These expectations maybe incorrect due to crbug.com/561034. 300 EXPECT_EQ(base_url, entry->GetBaseURLForDataURL());
Charlie Reis 2016/07/26 14:53:15 boliu@: These were fixed by cloning the last commi
301 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty()); 301 EXPECT_EQ(history_url, entry->GetVirtualURL());
302 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty()); 302 EXPECT_EQ(history_url, entry->GetVirtualURL());
boliu 2016/07/26 15:17:27 this is repeated twice?
Charlie Reis 2016/07/26 15:30:46 Oops, that was supposed to be GetHistoryURLForData
303 EXPECT_EQ(data_url, entry->GetVirtualURL());
304 EXPECT_EQ(data_url, entry->GetURL()); 303 EXPECT_EQ(data_url, entry->GetURL());
305 304
306 // Passes if renderer is still alive. 305 // Passes if renderer is still alive.
307 EXPECT_TRUE(ExecuteScript(shell(), "console.log('Success');")); 306 EXPECT_TRUE(ExecuteScript(shell(), "console.log('Success');"));
308 } 307 }
309 308
310 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { 309 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) {
311 const NavigationControllerImpl& controller = 310 const NavigationControllerImpl& controller =
312 static_cast<const NavigationControllerImpl&>( 311 static_cast<const NavigationControllerImpl&>(
313 shell()->web_contents()->GetController()); 312 shell()->web_contents()->GetController());
(...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 } 2367 }
2369 2368
2370 // Ensure that we don't crash when navigating subframes after in-page 2369 // Ensure that we don't crash when navigating subframes after in-page
2371 // navigations. See https://crbug.com/522193. 2370 // navigations. See https://crbug.com/522193.
2372 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 2371 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
2373 FrameNavigationEntry_SubframeAfterInPage) { 2372 FrameNavigationEntry_SubframeAfterInPage) {
2374 // 1. Start on a page with a subframe. 2373 // 1. Start on a page with a subframe.
2375 GURL main_url(embedded_test_server()->GetURL( 2374 GURL main_url(embedded_test_server()->GetURL(
2376 "/navigation_controller/page_with_iframe.html")); 2375 "/navigation_controller/page_with_iframe.html"));
2377 NavigateToURL(shell(), main_url); 2376 NavigateToURL(shell(), main_url);
2377 const NavigationControllerImpl& controller =
2378 static_cast<const NavigationControllerImpl&>(
2379 shell()->web_contents()->GetController());
2378 FrameTreeNode* root = 2380 FrameTreeNode* root =
2379 static_cast<WebContentsImpl*>(shell()->web_contents())-> 2381 static_cast<WebContentsImpl*>(shell()->web_contents())->
2380 GetFrameTree()->root(); 2382 GetFrameTree()->root();
2381 2383
2382 ASSERT_EQ(1U, root->child_count()); 2384 ASSERT_EQ(1U, root->child_count());
2383 ASSERT_NE(nullptr, root->child_at(0)); 2385 ASSERT_NE(nullptr, root->child_at(0));
2384 2386
2385 // Navigate to a real page in the subframe, so that the next navigation will 2387 // Navigate to a real page in the subframe, so that the next navigation will
2386 // be MANUAL_SUBFRAME. 2388 // be MANUAL_SUBFRAME.
2387 GURL subframe_url(embedded_test_server()->GetURL( 2389 GURL subframe_url(embedded_test_server()->GetURL(
2388 "/navigation_controller/simple_page_1.html")); 2390 "/navigation_controller/simple_page_1.html"));
2389 { 2391 {
2390 LoadCommittedCapturer capturer(root->child_at(0)); 2392 LoadCommittedCapturer capturer(root->child_at(0));
2391 NavigateFrameToURL(root->child_at(0), subframe_url); 2393 NavigateFrameToURL(root->child_at(0), subframe_url);
2392 capturer.Wait(); 2394 capturer.Wait();
2393 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( 2395 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
2394 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); 2396 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME));
2395 } 2397 }
2396 2398
2397 // 2. In-page navigation in the main frame. 2399 // 2. In-page navigation in the main frame.
2398 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')"; 2400 std::string push_script = "history.pushState({}, 'page 2', 'page_2.html')";
2399 EXPECT_TRUE(ExecuteScript(root, push_script)); 2401 EXPECT_TRUE(ExecuteScript(root, push_script));
2400 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 2402 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
2401 2403
2402 // TODO(creis): Verify subframe entries. https://crbug.com/522193. 2404 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
2405 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
2406 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
2407 // The entry should have a FrameNavigationEntry for the subframe.
2408 ASSERT_EQ(1U, entry->root_node()->children.size());
2409 EXPECT_EQ(subframe_url,
2410 entry->root_node()->children[0]->frame_entry->url());
2411 } else {
2412 // There are no subframe FrameNavigationEntries by default.
2413 EXPECT_EQ(0U, entry->root_node()->children.size());
2414 }
2403 2415
2404 // 3. Add a nested subframe. 2416 // 3. Add a nested subframe.
2405 { 2417 {
2406 LoadCommittedCapturer capturer(shell()->web_contents()); 2418 LoadCommittedCapturer capturer(shell()->web_contents());
2407 std::string script = "var iframe = document.createElement('iframe');" 2419 std::string script = "var iframe = document.createElement('iframe');"
2408 "iframe.src = '" + subframe_url.spec() + "';" 2420 "iframe.src = '" + subframe_url.spec() + "';"
2409 "document.body.appendChild(iframe);"; 2421 "document.body.appendChild(iframe);";
2410 EXPECT_TRUE(ExecuteScript(root->child_at(0), script)); 2422 EXPECT_TRUE(ExecuteScript(root->child_at(0), script));
2411 capturer.Wait(); 2423 capturer.Wait();
2412 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs( 2424 EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
2413 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); 2425 capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME));
2414 } 2426 }
2415 2427
2416 // TODO(creis): Verify subframe entries. https://crbug.com/522193. 2428 // Verify subframe entries if they're enabled (e.g. in --site-per-process).
2429 entry = controller.GetLastCommittedEntry();
2430 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
2431 // The entry should have a FrameNavigationEntry for the subframe.
2432 ASSERT_EQ(1U, entry->root_node()->children.size());
2433 EXPECT_EQ(subframe_url,
2434 entry->root_node()->children[0]->frame_entry->url());
2435 ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
2436 EXPECT_EQ(subframe_url,
2437 entry->root_node()->children[0]->children[0]->frame_entry->url());
2438 } else {
2439 // There are no subframe FrameNavigationEntries by default.
2440 EXPECT_EQ(0U, entry->root_node()->children.size());
2441 }
2417 } 2442 }
2418 2443
2419 // Verify the tree of FrameNavigationEntries after back/forward navigations in a 2444 // Verify the tree of FrameNavigationEntries after back/forward navigations in a
2420 // cross-site subframe. 2445 // cross-site subframe.
2421 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 2446 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
2422 FrameNavigationEntry_SubframeBackForward) { 2447 FrameNavigationEntry_SubframeBackForward) {
2423 GURL main_url(embedded_test_server()->GetURL( 2448 GURL main_url(embedded_test_server()->GetURL(
2424 "/navigation_controller/simple_page_1.html")); 2449 "/navigation_controller/simple_page_1.html"));
2425 NavigateToURL(shell(), main_url); 2450 NavigateToURL(shell(), main_url);
2426 const NavigationControllerImpl& controller = 2451 const NavigationControllerImpl& controller =
(...skipping 2902 matching lines...) Expand 10 before | Expand all | Expand 10 after
5329 std::string body; 5354 std::string body;
5330 EXPECT_TRUE(ExecuteScriptAndExtractString( 5355 EXPECT_TRUE(ExecuteScriptAndExtractString(
5331 shell()->web_contents(), 5356 shell()->web_contents(),
5332 "window.domAutomationController.send(" 5357 "window.domAutomationController.send("
5333 "document.getElementsByTagName('pre')[0].innerText);", 5358 "document.getElementsByTagName('pre')[0].innerText);",
5334 &body)); 5359 &body));
5335 EXPECT_EQ("text=value\n", body); 5360 EXPECT_EQ("text=value\n", body);
5336 } 5361 }
5337 5362
5338 } // namespace content 5363 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698