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

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

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 #include "content/browser/web_contents/web_contents_impl.h" 6 #include "content/browser/web_contents/web_contents_impl.h"
7 #include "content/public/browser/web_contents.h" 7 #include "content/public/browser/web_contents.h"
8 #include "content/public/browser/web_contents_observer.h" 8 #include "content/public/browser/web_contents_observer.h"
9 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test.h" 10 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h" 11 #include "content/public/test/content_browser_test_utils.h"
12 #include "content/public/test/test_navigation_observer.h" 12 #include "content/public/test/test_navigation_observer.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 #include "content/shell/browser/shell.h" 14 #include "content/shell/browser/shell.h"
15 #include "content/test/content_browser_test_utils_internal.h"
15 #include "net/dns/mock_host_resolver.h" 16 #include "net/dns/mock_host_resolver.h"
16 #include "ui/base/page_transition_types.h" 17 #include "ui/base/page_transition_types.h"
17 #include "url/url_constants.h" 18 #include "url/url_constants.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
22 23
23 class NavigationHandleObserver : public WebContentsObserver { 24 class NavigationHandleObserver : public WebContentsObserver {
24 public: 25 public:
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 "a.com", "/cross_site_iframe_factory.html?a(a())")); 444 "a.com", "/cross_site_iframe_factory.html?a(a())"));
444 EXPECT_TRUE(NavigateToURL(shell(), url)); 445 EXPECT_TRUE(NavigateToURL(shell(), url));
445 446
446 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 447 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
447 ->GetFrameTree() 448 ->GetFrameTree()
448 ->root(); 449 ->root();
449 450
450 NavigationHandleObserver observer( 451 NavigationHandleObserver observer(
451 shell()->web_contents(), 452 shell()->web_contents(),
452 embedded_test_server()->GetURL("a.com", "/bar")); 453 embedded_test_server()->GetURL("a.com", "/bar"));
453 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), 454 EXPECT_TRUE(ExecuteScript(root->child_at(0),
454 "window.history.pushState({}, '', 'bar');")); 455 "window.history.pushState({}, '', 'bar');"));
455 456
456 EXPECT_TRUE(observer.has_committed()); 457 EXPECT_TRUE(observer.has_committed());
457 EXPECT_FALSE(observer.is_error()); 458 EXPECT_FALSE(observer.is_error());
458 EXPECT_TRUE(observer.is_renderer_initiated()); 459 EXPECT_TRUE(observer.is_renderer_initiated());
459 } 460 }
460 } 461 }
461 462
462 // Ensure that the IsSrcdoc() method on NavigationHandle behaves correctly. 463 // Ensure that the IsSrcdoc() method on NavigationHandle behaves correctly.
463 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, VerifySrcdoc) { 464 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, VerifySrcdoc) {
(...skipping 15 matching lines...) Expand all
479 GURL url(embedded_test_server()->GetURL( 480 GURL url(embedded_test_server()->GetURL(
480 "a.com", "/cross_site_iframe_factory.html?a(a())")); 481 "a.com", "/cross_site_iframe_factory.html?a(a())"));
481 EXPECT_TRUE(NavigateToURL(shell(), url)); 482 EXPECT_TRUE(NavigateToURL(shell(), url));
482 483
483 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 484 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
484 ->GetFrameTree() 485 ->GetFrameTree()
485 ->root(); 486 ->root();
486 487
487 NavigationHandleObserver observer( 488 NavigationHandleObserver observer(
488 shell()->web_contents(), embedded_test_server()->GetURL("a.com", "/bar")); 489 shell()->web_contents(), embedded_test_server()->GetURL("a.com", "/bar"));
489 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), 490 EXPECT_TRUE(ExecuteScript(root->child_at(0),
490 "window.history.pushState({}, '', 'bar');")); 491 "window.history.pushState({}, '', 'bar');"));
491 492
492 EXPECT_TRUE(observer.has_committed()); 493 EXPECT_TRUE(observer.has_committed());
493 EXPECT_FALSE(observer.is_error()); 494 EXPECT_FALSE(observer.is_error());
494 EXPECT_TRUE(observer.is_synchronous()); 495 EXPECT_TRUE(observer.is_synchronous());
495 } 496 }
496 497
497 // Ensure that a NavigationThrottle can cancel the navigation at navigation 498 // Ensure that a NavigationThrottle can cancel the navigation at navigation
498 // start. 499 // start.
499 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, ThrottleCancelStart) { 500 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, ThrottleCancelStart) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 navigation_observer.Wait(); 624 navigation_observer.Wait();
624 625
625 EXPECT_TRUE(observer.has_committed()); 626 EXPECT_TRUE(observer.has_committed());
626 EXPECT_TRUE(observer.was_redirected()); 627 EXPECT_TRUE(observer.was_redirected());
627 EXPECT_FALSE(observer.is_error()); 628 EXPECT_FALSE(observer.is_error());
628 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), 629 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(),
629 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html"))); 630 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html")));
630 } 631 }
631 632
632 } // namespace content 633 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698