| Index: chrome/browser/unload_browsertest.cc
|
| diff --git a/chrome/browser/unload_browsertest.cc b/chrome/browser/unload_browsertest.cc
|
| index 2af1a45082547fa5dad650df28f6867d2e6445cd..303f60e0520efd14323b4c75a50a2eb78b79ab75 100644
|
| --- a/chrome/browser/unload_browsertest.cc
|
| +++ b/chrome/browser/unload_browsertest.cc
|
| @@ -24,6 +24,7 @@
|
| #include "components/app_modal/native_app_modal_dialog.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| @@ -278,6 +279,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, DISABLED_BrowserCloseUnload) {
|
| // OK in the beforeunload confirm dialog.
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -292,6 +298,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
|
| // If this test flakes, reopen http://crbug.com/123110
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
| chrome::CloseWindow(browser());
|
|
|
| // We wait for the title to change after cancelling the closure of browser
|
| @@ -337,6 +348,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListCloseNoUnloadListeners) {
|
| // beforeunload handler and clicking Leave in the beforeunload confirm dialog.
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListCloseBeforeUnloadOK) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -357,6 +373,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListCloseBeforeUnloadOK) {
|
| // beforeunload handler and clicking Stay in the beforeunload confirm dialog.
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListCloseBeforeUnloadCancel) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| UnloadResults unload_results;
|
| BrowserList::CloseAllBrowsersWithProfile(
|
| @@ -392,6 +413,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListCloseBeforeUnloadCancel) {
|
| // beforeunload handler and clicking Leave in the beforeunload confirm dialog.
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListDoubleCloseBeforeUnloadOK) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -417,6 +443,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListDoubleCloseBeforeUnloadOK) {
|
| // beforeunload handler and clicking Stay in the beforeunload confirm dialog.
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListDoubleCloseBeforeUnloadCancel) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| UnloadResults unload_results;
|
| BrowserList::CloseAllBrowsersWithProfile(
|
| @@ -458,6 +489,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListDoubleCloseBeforeUnloadCancel) {
|
| #if defined(OS_CHROMEOS)
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserTerminateBeforeUnload) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
| EXPECT_EQ(kill(base::GetCurrentProcessHandle(), SIGTERM), 0);
|
| }
|
| #endif
|
| @@ -467,6 +503,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserTerminateBeforeUnload) {
|
| // If this flakes, use http://crbug.com/32615 and http://crbug.com/45675
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseWithInnerFocusedFrame) {
|
| NavigateToDataURL(INNER_FRAME_WITH_FOCUS_HTML, "innerframewithfocus");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -595,6 +636,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListForceCloseNoUnloadListeners) {
|
|
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListForceCloseWithBeforeUnload) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -612,6 +658,11 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListForceCloseWithBeforeUnload) {
|
|
|
| IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserListForceCloseAfterNormalClose) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -841,6 +892,11 @@ IN_PROC_BROWSER_TEST_F(FastUnloadTest,
|
| return;
|
|
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
| content::WebContents* beforeunload_contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
|
|
| @@ -873,6 +929,11 @@ IN_PROC_BROWSER_TEST_F(FastUnloadTest,
|
| IN_PROC_BROWSER_TEST_F(FastUnloadTest,
|
| BrowserListForceCloseWithBeforeUnloadWithFastUnload) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
| @@ -891,6 +952,11 @@ IN_PROC_BROWSER_TEST_F(FastUnloadTest,
|
| IN_PROC_BROWSER_TEST_F(FastUnloadTest,
|
| BrowserListForceCloseAfterNormalCloseWithFastUnload) {
|
| NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
|
| + // JavaScript onbeforeunload dialogs require a user gesture.
|
| + for (auto* frame :
|
| + browser()->tab_strip_model()->GetActiveWebContents()->GetAllFrames()) {
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| + }
|
|
|
| content::WindowedNotificationObserver window_observer(
|
| chrome::NOTIFICATION_BROWSER_CLOSED,
|
|
|