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

Unified Diff: chrome/browser/tab_contents/web_contents_unittest.cc

Issue 149261: Disimiss JS message boxes when an interstitial is showing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
Index: chrome/browser/tab_contents/web_contents_unittest.cc
===================================================================
--- chrome/browser/tab_contents/web_contents_unittest.cc (revision 20029)
+++ chrome/browser/tab_contents/web_contents_unittest.cc (working copy)
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/message_box_flags.h"
#include "base/logging.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
@@ -1256,3 +1257,36 @@
EXPECT_FALSE(deleted2);
EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2);
}
+
+// Tests that Javascript messages are not shown while an interstitial is
+// showing.
+TEST_F(TabContentsTest, NoJSMessageOnInterstitials) {
+ const char kUrl[] = "http://www.badguys.com/";
+ const GURL kGURL(kUrl);
+
+ // Start a navigation to a page
+ contents()->controller().LoadURL(kGURL, GURL(), PageTransition::TYPED);
+ // DidNavigate from the page
+ ViewHostMsg_FrameNavigate_Params params;
+ InitNavigateParams(&params, 1, kGURL);
+ contents()->TestDidNavigate(rvh(), params);
+
+ // Simulate showing an interstitial while the page is showing.
+ TestInterstitialPage::InterstitialState state =
+ TestInterstitialPage::UNDECIDED;
+ bool deleted = false;
+ TestInterstitialPage* interstitial =
+ new TestInterstitialPage(contents(), true, kGURL, &state, &deleted);
+ TestInterstitialPageStateGuard state_guard(interstitial);
+ interstitial->Show();
+ interstitial->TestDidNavigate(1, kGURL);
+
+ // While the interstitial is showing, let's simulate the hidden page
+ // attempting to show a JS message.
+ IPC::Message* dummy_message = new IPC::Message;
+ bool did_suppress_message = false;
+ contents()->RunJavaScriptMessage(L"This is an informative message", L"OK",
+ kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message,
+ &did_suppress_message);
+ EXPECT_TRUE(did_suppress_message);
+}
« chrome/browser/tab_contents/tab_contents.h ('K') | « chrome/browser/tab_contents/tab_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698