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

Unified Diff: chrome/browser/ui/browser_browsertest.cc

Issue 24360011: Cancel JavaScript dialogs when an interstitial appears. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 7 years, 3 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 | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_browsertest.cc
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 960b62e606ce3ac116491a34e4d627e56f12dea8..56901bcdfb435f9800494117dd64cd875f9a7148 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/translate/translate_tab_helper.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
+#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
#include "chrome/browser/ui/browser.h"
@@ -1686,6 +1687,53 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) {
EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU));
}
+// Ensure that creating an interstitial page closes any JavaScript dialogs
+// that were present on the previous page. See http://crbug.com/295695.
+IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialClosesDialogs) {
+ ASSERT_TRUE(test_server()->Start());
+ host_resolver()->AddRule("www.example.com", "127.0.0.1");
+ GURL url(test_server()->GetURL("empty.html"));
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
+ contents->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
+ string16(),
+ ASCIIToUTF16("alert('Dialog showing!');"));
+ AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
+ EXPECT_TRUE(alert->IsValid());
+ AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance();
+ EXPECT_TRUE(dialog_queue->HasActiveDialog());
+
+ TestInterstitialPage* interstitial = NULL;
+ {
+ scoped_refptr<content::MessageLoopRunner> loop_runner(
+ new content::MessageLoopRunner);
+
+ InterstitialObserver observer(contents,
+ loop_runner->QuitClosure(),
+ base::Closure());
+ interstitial = new TestInterstitialPage(contents, false, GURL());
+ loop_runner->Run();
+ }
+
+ // The interstitial should have closed the dialog.
+ EXPECT_TRUE(contents->ShowingInterstitialPage());
+ EXPECT_FALSE(dialog_queue->HasActiveDialog());
+
+ {
+ scoped_refptr<content::MessageLoopRunner> loop_runner(
+ new content::MessageLoopRunner);
+
+ InterstitialObserver observer(contents,
+ base::Closure(),
+ loop_runner->QuitClosure());
+ interstitial->Proceed();
+ loop_runner->Run();
+ // interstitial is deleted now.
+ }
+}
+
+
IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCloseTab) {
WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698