Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Unified Diff: chrome/browser/browser_browsertest.cc

Issue 6627063: Ignore JavaScript messages (alert/confirm/prompt) during unload handlers. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added a browsertest Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_browsertest.cc
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index 4a2c7f5fa2d43bb4deef0554ad7dd62c9763bf3c..4d84f743c676bcdb18e6f9a4423c5668b9a5a08d 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -304,6 +304,25 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) {
alert->native_dialog()->AcceptAppModalDialog();
}
+// Test for crbug.com/68780. JavaScript messages (alert/confirm/prompt) should
+// be ignored (i.e., no dialogs shown) during onunload() and onbeforeunload().
+IN_PROC_BROWSER_TEST_F(BrowserTest, NoAlertsDuringUnload) {
+ // Register an observer to watch for dialogs.
+ ui_test_utils::TestNotificationObserver observer;
+ NotificationRegistrar registrar;
+ registrar.Add(&observer, NotificationType::APP_MODAL_DIALOG_SHOWN,
+ NotificationService::AllSources());
+
+ // Load a page that will try to show various modal dialogs when unloaded.
+ ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,<html><head>"
+ "<title>1</title></head><body><script>onbeforeunload=onunload=function(){"
+ "alert(1);confirm(2);prompt(3)}</script></body></html>"));
+
+ // Unload the page and verify that no dialogs were spotted.
+ ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
+ EXPECT_FALSE(Source<AppModalDialog>(observer.source()).ptr());
+}
+
// Test that get_process_idle_time() returns reasonable values when compared
// with time deltas measured locally.
IN_PROC_BROWSER_TEST_F(BrowserTest, RenderIdleTime) {
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698