| 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/pattern.h" | 7 #include "base/strings/pattern.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 class WebContentsImplBrowserTest : public ContentBrowserTest { | 63 class WebContentsImplBrowserTest : public ContentBrowserTest { |
| 64 public: | 64 public: |
| 65 WebContentsImplBrowserTest() {} | 65 WebContentsImplBrowserTest() {} |
| 66 void SetUp() override { | 66 void SetUp() override { |
| 67 RenderWidgetHostImpl::DisableResizeAckCheckForTesting(); | 67 RenderWidgetHostImpl::DisableResizeAckCheckForTesting(); |
| 68 ContentBrowserTest::SetUp(); | 68 ContentBrowserTest::SetUp(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SetUpOnMainThread() override { |
| 72 // Setup the server to allow serving separate sites, so we can perform |
| 73 // cross-process navigation. |
| 74 host_resolver()->AddRule("*", "127.0.0.1"); |
| 75 } |
| 76 |
| 71 private: | 77 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(WebContentsImplBrowserTest); | 78 DISALLOW_COPY_AND_ASSIGN(WebContentsImplBrowserTest); |
| 73 }; | 79 }; |
| 74 | 80 |
| 75 // Keeps track of data from LoadNotificationDetails so we can later verify that | 81 // Keeps track of data from LoadNotificationDetails so we can later verify that |
| 76 // they are correct, after the LoadNotificationDetails object is deleted. | 82 // they are correct, after the LoadNotificationDetails object is deleted. |
| 77 class LoadStopNotificationObserver : public WindowedNotificationObserver { | 83 class LoadStopNotificationObserver : public WindowedNotificationObserver { |
| 78 public: | 84 public: |
| 79 LoadStopNotificationObserver(NavigationController* controller) | 85 LoadStopNotificationObserver(NavigationController* controller) |
| 80 : WindowedNotificationObserver(NOTIFICATION_LOAD_STOP, | 86 : WindowedNotificationObserver(NOTIFICATION_LOAD_STOP, |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 435 |
| 430 // Test that creation of new RenderFrameHost objects sends the correct object | 436 // Test that creation of new RenderFrameHost objects sends the correct object |
| 431 // to the WebContentObservers. See http://crbug.com/347339. | 437 // to the WebContentObservers. See http://crbug.com/347339. |
| 432 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 438 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
| 433 RenderFrameCreatedCorrectProcessForObservers) { | 439 RenderFrameCreatedCorrectProcessForObservers) { |
| 434 static const char kFooCom[] = "foo.com"; | 440 static const char kFooCom[] = "foo.com"; |
| 435 GURL::Replacements replace_host; | 441 GURL::Replacements replace_host; |
| 436 net::HostPortPair foo_host_port; | 442 net::HostPortPair foo_host_port; |
| 437 GURL cross_site_url; | 443 GURL cross_site_url; |
| 438 | 444 |
| 439 // Setup the server to allow serving separate sites, so we can perform | |
| 440 // cross-process navigation. | |
| 441 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 442 ASSERT_TRUE(embedded_test_server()->Start()); | 445 ASSERT_TRUE(embedded_test_server()->Start()); |
| 443 | 446 |
| 444 foo_host_port = embedded_test_server()->host_port_pair(); | 447 foo_host_port = embedded_test_server()->host_port_pair(); |
| 445 foo_host_port.set_host(kFooCom); | 448 foo_host_port.set_host(kFooCom); |
| 446 | 449 |
| 447 GURL initial_url(embedded_test_server()->GetURL("/title1.html")); | 450 GURL initial_url(embedded_test_server()->GetURL("/title1.html")); |
| 448 | 451 |
| 449 cross_site_url = embedded_test_server()->GetURL("/title2.html"); | 452 cross_site_url = embedded_test_server()->GetURL("/title2.html"); |
| 450 replace_host.SetHostStr(kFooCom); | 453 replace_host.SetHostStr(kFooCom); |
| 451 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 454 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 // ... and the last one should be 1.0, meaning complete. | 590 // ... and the last one should be 1.0, meaning complete. |
| 588 ASSERT_GE(progresses.size(), 1U) | 591 ASSERT_GE(progresses.size(), 1U) |
| 589 << "There should be at least one progress update"; | 592 << "There should be at least one progress update"; |
| 590 EXPECT_EQ(1.0, *progresses.rbegin()); | 593 EXPECT_EQ(1.0, *progresses.rbegin()); |
| 591 } | 594 } |
| 592 | 595 |
| 593 // Ensure that a new navigation that interrupts a pending one will still fire | 596 // Ensure that a new navigation that interrupts a pending one will still fire |
| 594 // a DidStopLoading. See http://crbug.com/429399. | 597 // a DidStopLoading. See http://crbug.com/429399. |
| 595 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 598 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
| 596 LoadProgressAfterInterruptedNav) { | 599 LoadProgressAfterInterruptedNav) { |
| 597 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 598 ASSERT_TRUE(embedded_test_server()->Start()); | 600 ASSERT_TRUE(embedded_test_server()->Start()); |
| 599 | 601 |
| 600 // Start at a real page. | 602 // Start at a real page. |
| 601 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 603 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
| 602 | 604 |
| 603 // Simulate a navigation that has not completed. | 605 // Simulate a navigation that has not completed. |
| 604 const GURL kURL2 = embedded_test_server()->GetURL("/title2.html"); | 606 const GURL kURL2 = embedded_test_server()->GetURL("/title2.html"); |
| 605 NavigationStallDelegate stall_delegate(kURL2); | 607 NavigationStallDelegate stall_delegate(kURL2); |
| 606 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); | 608 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); |
| 607 std::unique_ptr<LoadProgressDelegateAndObserver> delegate( | 609 std::unique_ptr<LoadProgressDelegateAndObserver> delegate( |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 }; | 997 }; |
| 996 | 998 |
| 997 } // namespace | 999 } // namespace |
| 998 | 1000 |
| 999 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 1001 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
| 1000 JavaScriptDialogsInMainAndSubframes) { | 1002 JavaScriptDialogsInMainAndSubframes) { |
| 1001 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); | 1003 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 1002 TestJavaScriptDialogManager dialog_manager; | 1004 TestJavaScriptDialogManager dialog_manager; |
| 1003 wc->SetDelegate(&dialog_manager); | 1005 wc->SetDelegate(&dialog_manager); |
| 1004 | 1006 |
| 1005 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 1006 ASSERT_TRUE(embedded_test_server()->Start()); | 1007 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1007 | 1008 |
| 1008 NavigateToURL(shell(), | 1009 NavigateToURL(shell(), |
| 1009 embedded_test_server()->GetURL("a.com", "/title1.html")); | 1010 embedded_test_server()->GetURL("a.com", "/title1.html")); |
| 1010 EXPECT_TRUE(WaitForLoadStop(wc)); | 1011 EXPECT_TRUE(WaitForLoadStop(wc)); |
| 1011 | 1012 |
| 1012 FrameTreeNode* root = wc->GetFrameTree()->root(); | 1013 FrameTreeNode* root = wc->GetFrameTree()->root(); |
| 1013 ASSERT_EQ(0U, root->child_count()); | 1014 ASSERT_EQ(0U, root->child_count()); |
| 1014 | 1015 |
| 1015 std::string script = | 1016 std::string script = |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 void RequestToLockMouse(WebContents* web_contents, | 1275 void RequestToLockMouse(WebContents* web_contents, |
| 1275 bool user_gesture, | 1276 bool user_gesture, |
| 1276 bool last_unlocked_by_target) override { | 1277 bool last_unlocked_by_target) override { |
| 1277 request_to_lock_mouse_called_ = true; | 1278 request_to_lock_mouse_called_ = true; |
| 1278 } | 1279 } |
| 1279 bool request_to_lock_mouse_called_ = false; | 1280 bool request_to_lock_mouse_called_ = false; |
| 1280 }; | 1281 }; |
| 1281 | 1282 |
| 1282 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 1283 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
| 1283 RenderWidgetDeletedWhileMouseLockPending) { | 1284 RenderWidgetDeletedWhileMouseLockPending) { |
| 1284 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 1285 ASSERT_TRUE(embedded_test_server()->Start()); | 1285 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1286 | 1286 |
| 1287 std::unique_ptr<MouseLockDelegate> delegate(new MouseLockDelegate()); | 1287 std::unique_ptr<MouseLockDelegate> delegate(new MouseLockDelegate()); |
| 1288 shell()->web_contents()->SetDelegate(delegate.get()); | 1288 shell()->web_contents()->SetDelegate(delegate.get()); |
| 1289 ASSERT_TRUE(shell()->web_contents()->GetDelegate() == delegate.get()); | 1289 ASSERT_TRUE(shell()->web_contents()->GetDelegate() == delegate.get()); |
| 1290 | 1290 |
| 1291 NavigateToURL(shell(), | 1291 NavigateToURL(shell(), |
| 1292 embedded_test_server()->GetURL("a.com", "/title1.html")); | 1292 embedded_test_server()->GetURL("a.com", "/title1.html")); |
| 1293 | 1293 |
| 1294 // Try to request pointer lock. WebContentsDelegate should get a notification. | 1294 // Try to request pointer lock. WebContentsDelegate should get a notification. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 ASSERT_TRUE(saw_override); | 1389 ASSERT_TRUE(saw_override); |
| 1390 | 1390 |
| 1391 BrowserThread::PostTask( | 1391 BrowserThread::PostTask( |
| 1392 BrowserThread::IO, FROM_HERE, | 1392 BrowserThread::IO, FROM_HERE, |
| 1393 base::Bind(&ResourceDispatcherHost::SetDelegate, | 1393 base::Bind(&ResourceDispatcherHost::SetDelegate, |
| 1394 base::Unretained(ResourceDispatcherHostImpl::Get()), | 1394 base::Unretained(ResourceDispatcherHostImpl::Get()), |
| 1395 old_delegate)); | 1395 old_delegate)); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| 1398 } // namespace content | 1398 } // namespace content |
| OLD | NEW |