summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 21:29:55 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 21:29:55 +0000
commit91ed49a3f98ff91be98d786f44da18d4bf182a32 (patch)
tree9223bd373a7e97a42d803e04e3b45504758d09ea /chrome
parent9840dd700990d0f5385e8320719d0fcba3a5c68a (diff)
downloadchromium_src-91ed49a3f98ff91be98d786f44da18d4bf182a32.zip
chromium_src-91ed49a3f98ff91be98d786f44da18d4bf182a32.tar.gz
chromium_src-91ed49a3f98ff91be98d786f44da18d4bf182a32.tar.bz2
This CL makes sure JavaScript alerts are not shown while an interstitial is showing.
(The interstitial is displayed on top of an existing page. We don't want the hidden page to interfere with the interstitial.) BUG=http://crbug.com/3256 TEST=Open the page attached in the bug (interstitial_test.html), no alert boxes should show. Review URL: http://codereview.chromium.org/149261 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc6
-rw-r--r--chrome/browser/tab_contents/tab_contents.h3
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc34
3 files changed, 41 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 8141c42..d239955 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1929,7 +1929,11 @@ void TabContents::RunJavaScriptMessage(
// Suppress javascript messages when requested and when inside a constrained
// popup window (because that activates them and breaks them out of the
// constrained window jail).
- bool suppress_this_message = suppress_javascript_messages_;
+ // Also suppress messages when showing an interstitial. The interstitial is
+ // shown over the previous page, we don't want the hidden page dialogs to
+ // interfere with the interstitial.
+ bool suppress_this_message = suppress_javascript_messages_ ||
+ showing_interstitial_page();
if (delegate())
suppress_this_message |=
(delegate()->GetConstrainingContents(this) != this);
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 759c70a..c4f2d2f 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -578,8 +578,9 @@ class TabContents : public PageNavigator,
friend class BlockedPopupContainerTest;
friend class BlockedPopupContainerControllerTest;
- FRIEND_TEST(TabContentsTest, UpdateTitle);
FRIEND_TEST(BlockedPopupContainerTest, TestReposition);
+ FRIEND_TEST(TabContentsTest, NoJSMessageOnInterstitials);
+ FRIEND_TEST(TabContentsTest, UpdateTitle);
// Temporary until the view/contents separation is complete.
friend class TabContentsView;
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index bbdc7ef..15229a1 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -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 @@ TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) {
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);
+}