| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 DISABLED_SingleBeforeUnloadAfterWindowClose | 789 DISABLED_SingleBeforeUnloadAfterWindowClose |
| 790 #else | 790 #else |
| 791 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ | 791 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ |
| 792 SingleBeforeUnloadAfterWindowClose | 792 SingleBeforeUnloadAfterWindowClose |
| 793 #endif | 793 #endif |
| 794 | 794 |
| 795 // Test for crbug.com/11647. A page closed with window.close() should not have | 795 // Test for crbug.com/11647. A page closed with window.close() should not have |
| 796 // two beforeunload dialogs shown. | 796 // two beforeunload dialogs shown. |
| 797 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { | 797 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { |
| 798 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> | 798 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> |
| 799 ExecuteJavaScript(ASCIIToUTF16(kOpenNewBeforeUnloadPage)); | 799 ExecuteJavaScriptForTests(ASCIIToUTF16(kOpenNewBeforeUnloadPage)); |
| 800 | 800 |
| 801 // Close the new window with JavaScript, which should show a single | 801 // Close the new window with JavaScript, which should show a single |
| 802 // beforeunload dialog. Then show another alert, to make it easy to verify | 802 // beforeunload dialog. Then show another alert, to make it easy to verify |
| 803 // that a second beforeunload dialog isn't shown. | 803 // that a second beforeunload dialog isn't shown. |
| 804 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame()-> | 804 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame()-> |
| 805 ExecuteJavaScript(ASCIIToUTF16("w.close(); alert('bar');")); | 805 ExecuteJavaScriptForTests(ASCIIToUTF16("w.close(); alert('bar');")); |
| 806 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 806 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 807 alert->native_dialog()->AcceptAppModalDialog(); | 807 alert->native_dialog()->AcceptAppModalDialog(); |
| 808 | 808 |
| 809 alert = ui_test_utils::WaitForAppModalDialog(); | 809 alert = ui_test_utils::WaitForAppModalDialog(); |
| 810 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)-> | 810 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)-> |
| 811 is_before_unload_dialog()); | 811 is_before_unload_dialog()); |
| 812 alert->native_dialog()->AcceptAppModalDialog(); | 812 alert->native_dialog()->AcceptAppModalDialog(); |
| 813 } | 813 } |
| 814 | 814 |
| 815 // BrowserTest.BeforeUnloadVsBeforeReload times out on Windows. | 815 // BrowserTest.BeforeUnloadVsBeforeReload times out on Windows. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 redirect_popup += "w.document.location=\""; | 951 redirect_popup += "w.document.location=\""; |
| 952 redirect_popup += https_url.spec(); | 952 redirect_popup += https_url.spec(); |
| 953 redirect_popup += "\";"; | 953 redirect_popup += "\";"; |
| 954 | 954 |
| 955 content::WindowedNotificationObserver popup_observer( | 955 content::WindowedNotificationObserver popup_observer( |
| 956 chrome::NOTIFICATION_TAB_ADDED, | 956 chrome::NOTIFICATION_TAB_ADDED, |
| 957 content::NotificationService::AllSources()); | 957 content::NotificationService::AllSources()); |
| 958 content::WindowedNotificationObserver nav_observer( | 958 content::WindowedNotificationObserver nav_observer( |
| 959 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 959 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 960 content::NotificationService::AllSources()); | 960 content::NotificationService::AllSources()); |
| 961 oldtab->GetMainFrame()->ExecuteJavaScript(ASCIIToUTF16(redirect_popup)); | 961 oldtab->GetMainFrame()-> |
| 962 ExecuteJavaScriptForTests(ASCIIToUTF16(redirect_popup)); |
| 962 | 963 |
| 963 // Wait for popup window to appear and finish navigating. | 964 // Wait for popup window to appear and finish navigating. |
| 964 popup_observer.Wait(); | 965 popup_observer.Wait(); |
| 965 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 966 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 966 WebContents* newtab = browser()->tab_strip_model()->GetActiveWebContents(); | 967 WebContents* newtab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 967 EXPECT_TRUE(newtab); | 968 EXPECT_TRUE(newtab); |
| 968 EXPECT_NE(oldtab, newtab); | 969 EXPECT_NE(oldtab, newtab); |
| 969 nav_observer.Wait(); | 970 nav_observer.Wait(); |
| 970 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); | 971 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); |
| 971 EXPECT_EQ(https_url.spec(), | 972 EXPECT_EQ(https_url.spec(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 984 refresh_popup += "'<META HTTP-EQUIV=\"refresh\" content=\"0; url="; | 985 refresh_popup += "'<META HTTP-EQUIV=\"refresh\" content=\"0; url="; |
| 985 refresh_popup += https_url.spec(); | 986 refresh_popup += https_url.spec(); |
| 986 refresh_popup += "\">');w.document.close();"; | 987 refresh_popup += "\">');w.document.close();"; |
| 987 | 988 |
| 988 content::WindowedNotificationObserver popup_observer2( | 989 content::WindowedNotificationObserver popup_observer2( |
| 989 chrome::NOTIFICATION_TAB_ADDED, | 990 chrome::NOTIFICATION_TAB_ADDED, |
| 990 content::NotificationService::AllSources()); | 991 content::NotificationService::AllSources()); |
| 991 content::WindowedNotificationObserver nav_observer2( | 992 content::WindowedNotificationObserver nav_observer2( |
| 992 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 993 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 993 content::NotificationService::AllSources()); | 994 content::NotificationService::AllSources()); |
| 994 oldtab->GetMainFrame()->ExecuteJavaScript(ASCIIToUTF16(refresh_popup)); | 995 oldtab->GetMainFrame()-> |
| 996 ExecuteJavaScriptForTests(ASCIIToUTF16(refresh_popup)); |
| 995 | 997 |
| 996 // Wait for popup window to appear and finish navigating. | 998 // Wait for popup window to appear and finish navigating. |
| 997 popup_observer2.Wait(); | 999 popup_observer2.Wait(); |
| 998 ASSERT_EQ(3, browser()->tab_strip_model()->count()); | 1000 ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
| 999 WebContents* newtab2 = browser()->tab_strip_model()->GetActiveWebContents(); | 1001 WebContents* newtab2 = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1000 EXPECT_TRUE(newtab2); | 1002 EXPECT_TRUE(newtab2); |
| 1001 EXPECT_NE(oldtab, newtab2); | 1003 EXPECT_NE(oldtab, newtab2); |
| 1002 nav_observer2.Wait(); | 1004 nav_observer2.Wait(); |
| 1003 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); | 1005 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); |
| 1004 EXPECT_EQ(https_url.spec(), | 1006 EXPECT_EQ(https_url.spec(), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 dont_fork_popup += "w.document.location=\""; | 1039 dont_fork_popup += "w.document.location=\""; |
| 1038 dont_fork_popup += https_url.spec(); | 1040 dont_fork_popup += https_url.spec(); |
| 1039 dont_fork_popup += "\";"; | 1041 dont_fork_popup += "\";"; |
| 1040 | 1042 |
| 1041 content::WindowedNotificationObserver popup_observer( | 1043 content::WindowedNotificationObserver popup_observer( |
| 1042 chrome::NOTIFICATION_TAB_ADDED, | 1044 chrome::NOTIFICATION_TAB_ADDED, |
| 1043 content::NotificationService::AllSources()); | 1045 content::NotificationService::AllSources()); |
| 1044 content::WindowedNotificationObserver nav_observer( | 1046 content::WindowedNotificationObserver nav_observer( |
| 1045 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1047 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 1046 content::NotificationService::AllSources()); | 1048 content::NotificationService::AllSources()); |
| 1047 oldtab->GetMainFrame()->ExecuteJavaScript(ASCIIToUTF16(dont_fork_popup)); | 1049 oldtab->GetMainFrame()-> |
| 1050 ExecuteJavaScriptForTests(ASCIIToUTF16(dont_fork_popup)); |
| 1048 | 1051 |
| 1049 // Wait for popup window to appear and finish navigating. | 1052 // Wait for popup window to appear and finish navigating. |
| 1050 popup_observer.Wait(); | 1053 popup_observer.Wait(); |
| 1051 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1054 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 1052 WebContents* newtab = browser()->tab_strip_model()->GetActiveWebContents(); | 1055 WebContents* newtab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1053 EXPECT_TRUE(newtab); | 1056 EXPECT_TRUE(newtab); |
| 1054 EXPECT_NE(oldtab, newtab); | 1057 EXPECT_NE(oldtab, newtab); |
| 1055 nav_observer.Wait(); | 1058 nav_observer.Wait(); |
| 1056 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); | 1059 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); |
| 1057 EXPECT_EQ(https_url.spec(), | 1060 EXPECT_EQ(https_url.spec(), |
| 1058 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); | 1061 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); |
| 1059 | 1062 |
| 1060 // Popup window should still be in the opener's process. | 1063 // Popup window should still be in the opener's process. |
| 1061 content::RenderProcessHost* popup_process = | 1064 content::RenderProcessHost* popup_process = |
| 1062 newtab->GetRenderProcessHost(); | 1065 newtab->GetRenderProcessHost(); |
| 1063 EXPECT_EQ(process, popup_process); | 1066 EXPECT_EQ(process, popup_process); |
| 1064 | 1067 |
| 1065 // Same thing if the current tab tries to navigate itself. | 1068 // Same thing if the current tab tries to navigate itself. |
| 1066 std::string navigate_str = "document.location=\""; | 1069 std::string navigate_str = "document.location=\""; |
| 1067 navigate_str += https_url.spec(); | 1070 navigate_str += https_url.spec(); |
| 1068 navigate_str += "\";"; | 1071 navigate_str += "\";"; |
| 1069 | 1072 |
| 1070 content::WindowedNotificationObserver nav_observer2( | 1073 content::WindowedNotificationObserver nav_observer2( |
| 1071 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1074 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 1072 content::NotificationService::AllSources()); | 1075 content::NotificationService::AllSources()); |
| 1073 oldtab->GetMainFrame()->ExecuteJavaScript(ASCIIToUTF16(navigate_str)); | 1076 oldtab->GetMainFrame()->ExecuteJavaScriptForTests(ASCIIToUTF16(navigate_str)); |
| 1074 nav_observer2.Wait(); | 1077 nav_observer2.Wait(); |
| 1075 ASSERT_TRUE(oldtab->GetController().GetLastCommittedEntry()); | 1078 ASSERT_TRUE(oldtab->GetController().GetLastCommittedEntry()); |
| 1076 EXPECT_EQ(https_url.spec(), | 1079 EXPECT_EQ(https_url.spec(), |
| 1077 oldtab->GetController().GetLastCommittedEntry()->GetURL().spec()); | 1080 oldtab->GetController().GetLastCommittedEntry()->GetURL().spec()); |
| 1078 | 1081 |
| 1079 // Original window should still be in the original process. | 1082 // Original window should still be in the original process. |
| 1080 content::RenderProcessHost* new_process = newtab->GetRenderProcessHost(); | 1083 content::RenderProcessHost* new_process = newtab->GetRenderProcessHost(); |
| 1081 EXPECT_EQ(process, new_process); | 1084 EXPECT_EQ(process, new_process); |
| 1082 } | 1085 } |
| 1083 | 1086 |
| (...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2722 #endif | 2725 #endif |
| 2723 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2726 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
| 2724 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2727 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
| 2725 gfx::Size exp_final_size(initial_wcv_size); | 2728 gfx::Size exp_final_size(initial_wcv_size); |
| 2726 exp_final_size.Enlarge(wcv_resize_insets.width(), | 2729 exp_final_size.Enlarge(wcv_resize_insets.width(), |
| 2727 wcv_resize_insets.height() + height_inset); | 2730 wcv_resize_insets.height() + height_inset); |
| 2728 EXPECT_EQ(exp_final_size, | 2731 EXPECT_EQ(exp_final_size, |
| 2729 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2732 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
| 2730 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); | 2733 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); |
| 2731 } | 2734 } |
| OLD | NEW |