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/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 Shell* new_shell = new_shell_observer.GetShell(); | 809 Shell* new_shell = new_shell_observer.GetShell(); |
810 WaitForLoadStop(new_shell->web_contents()); | 810 WaitForLoadStop(new_shell->web_contents()); |
811 | 811 |
812 EXPECT_EQ("foo", | 812 EXPECT_EQ("foo", |
813 static_cast<WebContentsImpl*>(new_shell->web_contents()) | 813 static_cast<WebContentsImpl*>(new_shell->web_contents()) |
814 ->GetFrameTree()->root()->frame_name()); | 814 ->GetFrameTree()->root()->frame_name()); |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
| 818 // TODO(clamy): Make the test work on Windows and on Mac. On Mac and Windows, |
| 819 // there seem to be an issue with the ShellJavascriptDialogManager. |
| 820 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 821 #define MAYBE_NoResetOnBeforeUnloadCanceledOnCommit \ |
| 822 DISABLED_NoResetOnBeforeUnloadCanceledOnCommit |
| 823 #else |
| 824 #define MAYBE_NoResetOnBeforeUnloadCanceledOnCommit \ |
| 825 NoResetOnBeforeUnloadCanceledOnCommit |
| 826 #endif |
| 827 // Test that if a BeforeUnload dialog is destroyed due to the commit of a |
| 828 // cross-site navigation, it will not reset the loading state. |
| 829 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
| 830 MAYBE_NoResetOnBeforeUnloadCanceledOnCommit) { |
| 831 ASSERT_TRUE(embedded_test_server()->Start()); |
| 832 const GURL kStartURL( |
| 833 embedded_test_server()->GetURL("/hang_before_unload.html")); |
| 834 const GURL kCrossSiteURL( |
| 835 embedded_test_server()->GetURL("bar.com", "/title1.html")); |
| 836 |
| 837 // Navigate to a first web page with a BeforeUnload event listener. |
| 838 EXPECT_TRUE(NavigateToURL(shell(), kStartURL)); |
| 839 |
| 840 // Start a cross-site navigation that will not commit for the moment. |
| 841 TestNavigationManager cross_site_delayer(shell()->web_contents(), |
| 842 kCrossSiteURL); |
| 843 shell()->LoadURL(kCrossSiteURL); |
| 844 cross_site_delayer.WaitForWillStartRequest(); |
| 845 |
| 846 // Click on a link in the page. This will show the BeforeUnload dialog. |
| 847 // Ensure the dialog is not dismissed, which will cause it to still be |
| 848 // present when the cross-site navigation later commits. |
| 849 // Note: the javascript function executed will not do the link click but |
| 850 // schedule it for afterwards. Since the BeforeUnload event is synchronous, |
| 851 // clicking on the link right away would cause the ExecuteScript to never |
| 852 // return. |
| 853 SetShouldProceedOnBeforeUnload(shell(), false); |
| 854 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "clickLinkSoon()")); |
| 855 WaitForAppModalDialog(shell()); |
| 856 |
| 857 // Have the cross-site navigation commit. The main RenderFrameHost should |
| 858 // still be loading after that. |
| 859 cross_site_delayer.ResumeNavigation(); |
| 860 cross_site_delayer.WaitForNavigationFinished(); |
| 861 EXPECT_TRUE(shell()->web_contents()->IsLoading()); |
| 862 } |
| 863 |
818 } // namespace content | 864 } // namespace content |
OLD | NEW |