OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 7402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7413 TestNavigationObserver load_observer(shell()->web_contents()); | 7413 TestNavigationObserver load_observer(shell()->web_contents()); |
7414 GURL blocked_url = embedded_test_server()->GetURL("c.com", "/title3.html"); | 7414 GURL blocked_url = embedded_test_server()->GetURL("c.com", "/title3.html"); |
7415 EXPECT_TRUE(ExecuteScript(root->child_at(0), "window.location.href = '" + | 7415 EXPECT_TRUE(ExecuteScript(root->child_at(0), "window.location.href = '" + |
7416 blocked_url.spec() + "';")); | 7416 blocked_url.spec() + "';")); |
7417 | 7417 |
7418 // The blocked frame should still fire a load event in its parent's process. | 7418 // The blocked frame should still fire a load event in its parent's process. |
7419 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 7419 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
7420 | 7420 |
7421 // Check that the current RenderFrameHost has stopped loading. | 7421 // Check that the current RenderFrameHost has stopped loading. |
7422 if (root->child_at(0)->current_frame_host()->is_loading()) { | 7422 if (root->child_at(0)->current_frame_host()->is_loading()) { |
7423 ADD_FAILURE() << "Blocked RenderFrameHost shouldn't be loading anything"; | 7423 if (!IsBrowserSideNavigationEnabled()) |
7424 ADD_FAILURE() << "Blocked RenderFrameHost shouldn't be loading anything"; | |
7424 load_observer.Wait(); | 7425 load_observer.Wait(); |
7425 } | 7426 } |
7426 | 7427 |
7427 // The blocked frame should stay at the old location. | 7428 // The blocked frame should stay at the old location. |
7428 EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url()); | 7429 EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url()); |
7429 | 7430 |
7430 // The blocked frame should keep the old title. | 7431 // The blocked frame should keep the old title. |
7431 std::string frame_title; | 7432 std::string frame_title; |
7432 EXPECT_TRUE(ExecuteScriptAndExtractString( | 7433 EXPECT_TRUE(ExecuteScriptAndExtractString( |
7433 root->child_at(0), "domAutomationController.send(document.title)", | 7434 root->child_at(0), "domAutomationController.send(document.title)", |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7488 TestNavigationObserver load_observer2(shell()->web_contents()); | 7489 TestNavigationObserver load_observer2(shell()->web_contents()); |
7489 GURL blocked_url = embedded_test_server()->GetURL("c.com", "/title3.html"); | 7490 GURL blocked_url = embedded_test_server()->GetURL("c.com", "/title3.html"); |
7490 EXPECT_TRUE(ExecuteScript(root->child_at(0), "window.location.href = '" + | 7491 EXPECT_TRUE(ExecuteScript(root->child_at(0), "window.location.href = '" + |
7491 blocked_url.spec() + "';")); | 7492 blocked_url.spec() + "';")); |
7492 | 7493 |
7493 // The blocked frame should still fire a load event in its parent's process. | 7494 // The blocked frame should still fire a load event in its parent's process. |
7494 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 7495 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
7495 | 7496 |
7496 // Check that the current RenderFrameHost has stopped loading. | 7497 // Check that the current RenderFrameHost has stopped loading. |
7497 if (root->child_at(0)->current_frame_host()->is_loading()) { | 7498 if (root->child_at(0)->current_frame_host()->is_loading()) { |
7498 ADD_FAILURE() << "Blocked RenderFrameHost shouldn't be loading anything"; | 7499 if (!IsBrowserSideNavigationEnabled()) |
7500 ADD_FAILURE() << "Blocked RenderFrameHost shouldn't be loading anything"; | |
7499 load_observer2.Wait(); | 7501 load_observer2.Wait(); |
nasko
2017/03/17 21:21:31
I think it will be slightly better to change the c
| |
7500 } | 7502 } |
7501 | 7503 |
7502 // The blocked frame should stay at the old location. | 7504 // The blocked frame should stay at the old location. |
7503 EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url()); | 7505 EXPECT_EQ(old_subframe_url, root->child_at(0)->current_url()); |
7504 | 7506 |
7505 // The blocked frame should keep the old title. | 7507 // The blocked frame should keep the old title. |
7506 std::string frame_title; | 7508 std::string frame_title; |
7507 EXPECT_TRUE(ExecuteScriptAndExtractString( | 7509 EXPECT_TRUE(ExecuteScriptAndExtractString( |
7508 root->child_at(0), "domAutomationController.send(document.title)", | 7510 root->child_at(0), "domAutomationController.send(document.title)", |
7509 &frame_title)); | 7511 &frame_title)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7557 TestNavigationObserver load_observer2(shell()->web_contents()); | 7559 TestNavigationObserver load_observer2(shell()->web_contents()); |
7558 GURL blocked_url = embedded_test_server()->GetURL("c.com", "/title3.html"); | 7560 GURL blocked_url = embedded_test_server()->GetURL("c.com", "/title3.html"); |
7559 EXPECT_TRUE(ExecuteScript(navigating_frame, "window.location.href = '" + | 7561 EXPECT_TRUE(ExecuteScript(navigating_frame, "window.location.href = '" + |
7560 blocked_url.spec() + "';")); | 7562 blocked_url.spec() + "';")); |
7561 | 7563 |
7562 // The blocked frame should still fire a load event in its parent's process. | 7564 // The blocked frame should still fire a load event in its parent's process. |
7563 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 7565 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
7564 | 7566 |
7565 // Check that the current RenderFrameHost has stopped loading. | 7567 // Check that the current RenderFrameHost has stopped loading. |
7566 if (navigating_frame->current_frame_host()->is_loading()) { | 7568 if (navigating_frame->current_frame_host()->is_loading()) { |
7567 ADD_FAILURE() << "Blocked RenderFrameHost shouldn't be loading anything"; | 7569 if (!IsBrowserSideNavigationEnabled()) |
7570 ADD_FAILURE() << "Blocked RenderFrameHost shouldn't be loading anything"; | |
7568 load_observer2.Wait(); | 7571 load_observer2.Wait(); |
7569 } | 7572 } |
7570 | 7573 |
7571 // The blocked frame should stay at the old location. | 7574 // The blocked frame should stay at the old location. |
7572 EXPECT_EQ(old_subframe_url, navigating_frame->current_url()); | 7575 EXPECT_EQ(old_subframe_url, navigating_frame->current_url()); |
7573 | 7576 |
7574 // The blocked frame should keep the old title. | 7577 // The blocked frame should keep the old title. |
7575 std::string frame_title; | 7578 std::string frame_title; |
7576 EXPECT_TRUE(ExecuteScriptAndExtractString( | 7579 EXPECT_TRUE(ExecuteScriptAndExtractString( |
7577 navigating_frame, "domAutomationController.send(document.title)", | 7580 navigating_frame, "domAutomationController.send(document.title)", |
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9841 | 9844 |
9842 // Try the same navigation, but use the browser-initiated path. | 9845 // Try the same navigation, but use the browser-initiated path. |
9843 NavigateFrameToURL(root->child_at(0), frame_url); | 9846 NavigateFrameToURL(root->child_at(0), frame_url); |
9844 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); | 9847 EXPECT_FALSE(root->child_at(0)->render_manager()->pending_frame_host()); |
9845 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); | 9848 EXPECT_EQ(root->child_at(0)->current_url(), redirected_url); |
9846 EXPECT_EQ(b_site_instance, | 9849 EXPECT_EQ(b_site_instance, |
9847 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 9850 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
9848 } | 9851 } |
9849 | 9852 |
9850 } // namespace content | 9853 } // namespace content |
OLD | NEW |