diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 21:29:55 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 21:29:55 +0000 |
commit | 91ed49a3f98ff91be98d786f44da18d4bf182a32 (patch) | |
tree | 9223bd373a7e97a42d803e04e3b45504758d09ea /chrome/browser/tab_contents/web_contents_unittest.cc | |
parent | 9840dd700990d0f5385e8320719d0fcba3a5c68a (diff) | |
download | chromium_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/browser/tab_contents/web_contents_unittest.cc')
-rw-r--r-- | chrome/browser/tab_contents/web_contents_unittest.cc | 34 |
1 files changed, 34 insertions, 0 deletions
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(¶ms, 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); +} |