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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "app/message_box_flags.h"
5 #include "base/logging.h" 6 #include "base/logging.h"
6 #include "chrome/browser/renderer_host/render_view_host.h" 7 #include "chrome/browser/renderer_host/render_view_host.h"
7 #include "chrome/browser/renderer_host/render_widget_host_view.h" 8 #include "chrome/browser/renderer_host/render_widget_host_view.h"
8 #include "chrome/browser/renderer_host/test/test_render_view_host.h" 9 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
9 #include "chrome/browser/tab_contents/interstitial_page.h" 10 #include "chrome/browser/tab_contents/interstitial_page.h"
10 #include "chrome/browser/tab_contents/navigation_controller.h" 11 #include "chrome/browser/tab_contents/navigation_controller.h"
11 #include "chrome/browser/tab_contents/navigation_entry.h" 12 #include "chrome/browser/tab_contents/navigation_entry.h"
12 #include "chrome/browser/tab_contents/test_web_contents.h" 13 #include "chrome/browser/tab_contents/test_web_contents.h"
13 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/ipc_channel.h" 15 #include "chrome/common/ipc_channel.h"
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 NavigationEntry* entry = contents()->controller().pending_entry(); 1250 NavigationEntry* entry = contents()->controller().pending_entry();
1250 ASSERT_TRUE(entry); 1251 ASSERT_TRUE(entry);
1251 EXPECT_EQ(kUrl, entry->url().spec()); 1252 EXPECT_EQ(kUrl, entry->url().spec());
1252 1253
1253 // And that the first interstitial is gone, but not the second. 1254 // And that the first interstitial is gone, but not the second.
1254 EXPECT_TRUE(deleted); 1255 EXPECT_TRUE(deleted);
1255 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1256 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1256 EXPECT_FALSE(deleted2); 1257 EXPECT_FALSE(deleted2);
1257 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); 1258 EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2);
1258 } 1259 }
1260
1261 // Tests that Javascript messages are not shown while an interstitial is
1262 // showing.
1263 TEST_F(TabContentsTest, NoJSMessageOnInterstitials) {
1264 const char kUrl[] = "http://www.badguys.com/";
1265 const GURL kGURL(kUrl);
1266
1267 // Start a navigation to a page
1268 contents()->controller().LoadURL(kGURL, GURL(), PageTransition::TYPED);
1269 // DidNavigate from the page
1270 ViewHostMsg_FrameNavigate_Params params;
1271 InitNavigateParams(&params, 1, kGURL);
1272 contents()->TestDidNavigate(rvh(), params);
1273
1274 // Simulate showing an interstitial while the page is showing.
1275 TestInterstitialPage::InterstitialState state =
1276 TestInterstitialPage::UNDECIDED;
1277 bool deleted = false;
1278 TestInterstitialPage* interstitial =
1279 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted);
1280 TestInterstitialPageStateGuard state_guard(interstitial);
1281 interstitial->Show();
1282 interstitial->TestDidNavigate(1, kGURL);
1283
1284 // While the interstitial is showing, let's simulate the hidden page
1285 // attempting to show a JS message.
1286 IPC::Message* dummy_message = new IPC::Message;
1287 bool did_suppress_message = false;
1288 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK",
1289 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message,
1290 &did_suppress_message);
1291 EXPECT_TRUE(did_suppress_message);
1292 }
OLDNEW
« 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