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. | |
819 #if defined(OS_WIN) || defined(OS_MACOSX) | |
clamy
2016/03/29 13:01:50
Apparently the test has some issues on Windows and
Charlie Reis
2016/03/29 18:33:21
Hmm, this concerns me, because the crash affects t
clamy
2016/03/30 13:31:11
From what I see on the logs, there is an issue wit
| |
820 #define MAYBE_NoResetOnBeforeUnloadCanceledOnCommit \ | |
821 DISABLED_NoResetOnBeforeUnloadCanceledOnCommit | |
822 #else | |
823 #define MAYBE_NoResetOnBeforeUnloadCanceledOnCommit \ | |
824 NoResetOnBeforeUnloadCanceledOnCommit | |
825 #endif | |
826 // This CL tests that if a BeforeUnload dialog is destroyed due to the commit | |
nasko
2016/03/29 20:19:06
nit: drop "CL". This is a test case, it just happe
clamy
2016/03/30 13:31:11
Done. I did meant to write tests don't know what h
| |
827 // of a cross-site navigation, it will not reset the loading state. | |
828 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | |
829 MAYBE_NoResetOnBeforeUnloadCanceledOnCommit) { | |
830 ASSERT_TRUE(embedded_test_server()->Start()); | |
831 const GURL kStartURL( | |
832 embedded_test_server()->GetURL("/hang_before_unload.html")); | |
833 const GURL kCrossSiteURL( | |
834 embedded_test_server()->GetURL("bar.com", "/title1.html")); | |
835 | |
836 // Navigate to a first web page with a BeforeUnload event listener. | |
837 EXPECT_TRUE(NavigateToURL(shell(), kStartURL)); | |
838 | |
839 // Start a cross-site navigation that will not commit for the moment. | |
840 NavigationDelayer cross_site_delayer(shell()->web_contents(), kCrossSiteURL); | |
841 shell()->LoadURL(kCrossSiteURL); | |
842 cross_site_delayer.WaitForNavigationPaused(); | |
843 | |
844 // Click on a link in the page. This will show the BeforeUnload dialog. Have | |
nasko
2016/03/29 20:19:06
nit: "Have it hang" doesn't convey why or what han
clamy
2016/03/30 13:31:11
Done.
| |
845 // it hang. | |
846 // Note: the javascript function executed will not do the link click but | |
847 // schedule it for afterwards. Since the BeforeUnload event is synchronous, | |
848 // clicking on the link right away would cause the ExecuteScript to never | |
849 // return. | |
850 SetProceedByDefaultOnBeforeUnload(shell(), false); | |
851 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), "clickLinkSoon()")); | |
852 WaitForAppModalDialog(shell()); | |
853 | |
854 // Have the cross-site navigation commit. The main RenderFrameHost should | |
855 // still be loading after that. | |
856 cross_site_delayer.ResumeNavigation(); | |
857 cross_site_delayer.WaitForNavigationFinished(); | |
858 EXPECT_TRUE(shell()->web_contents()->IsLoading()); | |
859 } | |
860 | |
818 } // namespace content | 861 } // namespace content |
OLD | NEW |