| 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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 dialog_manager.Wait(); | 961 dialog_manager.Wait(); |
| 962 EXPECT_EQ(GURL("http://a.com/title1.html"), | 962 EXPECT_EQ(GURL("http://a.com/title1.html"), |
| 963 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); | 963 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); |
| 964 | 964 |
| 965 // A dialog from the subframe. | 965 // A dialog from the subframe. |
| 966 EXPECT_TRUE( | 966 EXPECT_TRUE( |
| 967 content::ExecuteScript(frame->current_frame_host(), alert_location)); | 967 content::ExecuteScript(frame->current_frame_host(), alert_location)); |
| 968 dialog_manager.Wait(); | 968 dialog_manager.Wait(); |
| 969 EXPECT_EQ("about:blank", dialog_manager.last_message()); | 969 EXPECT_EQ("about:blank", dialog_manager.last_message()); |
| 970 | 970 |
| 971 // Navigate cross-domain. | 971 // Navigate the subframe cross-site. |
| 972 NavigateFrameToURL(frame, | 972 NavigateFrameToURL(frame, |
| 973 embedded_test_server()->GetURL("b.com", "/title2.html")); | 973 embedded_test_server()->GetURL("b.com", "/title2.html")); |
| 974 EXPECT_TRUE(WaitForLoadStop(wc)); | 974 EXPECT_TRUE(WaitForLoadStop(wc)); |
| 975 | 975 |
| 976 // A dialog from the subframe. | 976 // A dialog from the subframe. |
| 977 EXPECT_TRUE( | 977 EXPECT_TRUE( |
| 978 content::ExecuteScript(frame->current_frame_host(), alert_location)); | 978 content::ExecuteScript(frame->current_frame_host(), alert_location)); |
| 979 dialog_manager.Wait(); | 979 dialog_manager.Wait(); |
| 980 EXPECT_EQ(GURL("http://b.com/title2.html"), | 980 EXPECT_EQ(GURL("http://b.com/title2.html"), |
| 981 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); | 981 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); |
| 982 | 982 |
| 983 // Dialogs do not work with out-of-process iframes yet. | |
| 984 // http://crbug.com/453893 | |
| 985 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | |
| 986 wc->SetDelegate(nullptr); | |
| 987 wc->SetJavaScriptDialogManagerForTesting(nullptr); | |
| 988 return; // :( | |
| 989 } | |
| 990 | |
| 991 // A dialog from the main frame. | 983 // A dialog from the main frame. |
| 992 EXPECT_TRUE( | 984 EXPECT_TRUE( |
| 993 content::ExecuteScript(root->current_frame_host(), alert_location)); | 985 content::ExecuteScript(root->current_frame_host(), alert_location)); |
| 994 dialog_manager.Wait(); | 986 dialog_manager.Wait(); |
| 995 EXPECT_EQ(GURL("http://a.com/title1.html"), | 987 EXPECT_EQ(GURL("http://a.com/title1.html"), |
| 996 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); | 988 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); |
| 997 | 989 |
| 990 // Navigate the top frame cross-site; ensure that dialogs work. |
| 991 NavigateToURL(shell(), |
| 992 embedded_test_server()->GetURL("c.com", "/title3.html")); |
| 993 EXPECT_TRUE(WaitForLoadStop(wc)); |
| 994 EXPECT_TRUE( |
| 995 content::ExecuteScript(root->current_frame_host(), alert_location)); |
| 996 dialog_manager.Wait(); |
| 997 EXPECT_EQ(GURL("http://c.com/title3.html"), |
| 998 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); |
| 999 |
| 1000 // Navigate back; ensure that dialogs work. |
| 1001 wc->GetController().GoBack(); |
| 1002 EXPECT_TRUE(WaitForLoadStop(wc)); |
| 1003 EXPECT_TRUE( |
| 1004 content::ExecuteScript(root->current_frame_host(), alert_location)); |
| 1005 dialog_manager.Wait(); |
| 1006 EXPECT_EQ(GURL("http://a.com/title1.html"), |
| 1007 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); |
| 1008 |
| 998 wc->SetDelegate(nullptr); | 1009 wc->SetDelegate(nullptr); |
| 999 wc->SetJavaScriptDialogManagerForTesting(nullptr); | 1010 wc->SetJavaScriptDialogManagerForTesting(nullptr); |
| 1000 } | 1011 } |
| 1001 | 1012 |
| 1002 } // namespace content | 1013 } // namespace content |
| OLD | NEW |