summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_contents_unittest.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 22:42:47 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 22:42:47 +0000
commitcbab76d1c74c93837bc76298d1a2e43646154194 (patch)
tree7f1bdcd891e670b67eeac2993730c580698048eb /chrome/browser/web_contents_unittest.cc
parent3c1e4d080a8e69fb973638d1360d4d5dd0d2e4d5 (diff)
downloadchromium_src-cbab76d1c74c93837bc76298d1a2e43646154194.zip
chromium_src-cbab76d1c74c93837bc76298d1a2e43646154194.tar.gz
chromium_src-cbab76d1c74c93837bc76298d1a2e43646154194.tar.bz2
This is the first pass at refactoring the interstitial page.
The SSL and malware blocking pages were doing similar things in 2 different classes. There is now a base class called InterstitialPage that contains the common logic. As part of that refactoring, the safe browsing was changed so that the SafeBrowsingBlockingPage is only used from the UI thread. This CL also adds transient entries to the navigation controller: that type of entry gets deleted as soon as a navigation occurs. It is used by interstitial that need to create such a temporary entry while they show. BUG=3013 TEST=Run the unit tests and ui tests. Review URL: http://codereview.chromium.org/6311 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_contents_unittest.cc')
-rw-r--r--chrome/browser/web_contents_unittest.cc64
1 files changed, 53 insertions, 11 deletions
diff --git a/chrome/browser/web_contents_unittest.cc b/chrome/browser/web_contents_unittest.cc
index 3620df8..932af42 100644
--- a/chrome/browser/web_contents_unittest.cc
+++ b/chrome/browser/web_contents_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "chrome/browser/interstitial_page.h"
#include "chrome/browser/navigation_controller.h"
#include "chrome/browser/navigation_entry.h"
#include "chrome/browser/render_view_host.h"
@@ -357,7 +358,11 @@ TEST_F(WebContentsTest, ShowInterstitialDontProceed) {
EXPECT_TRUE(orig_rvh->is_loading);
// Show interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
EXPECT_TRUE(contents->state_is_entering_interstitial());
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
EXPECT_TRUE(orig_rvh->is_loading); // Still loading in the background
@@ -392,7 +397,11 @@ TEST_F(WebContentsTest, ShowInterstitialProceed) {
contents->controller()->LoadURL(url, PageTransition::TYPED);
// Show interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
// DidNavigate from the interstitial
@@ -434,7 +443,11 @@ TEST_F(WebContentsTest, ShowInterstitialThenNavigate) {
contents->controller()->LoadURL(url, PageTransition::TYPED);
// Show interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
// DidNavigate from the interstitial
@@ -481,7 +494,11 @@ TEST_F(WebContentsTest, ShowInterstitialIFrameNavigate) {
// Show interstitial (in real world would probably be triggered by a resource
// in the page).
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
EXPECT_TRUE(contents->state_is_entering_interstitial());
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
EXPECT_TRUE(interstitial_rvh->is_loading);
@@ -518,7 +535,11 @@ TEST_F(WebContentsTest, VisitInterstitialURLTwice) {
// Now navigate to an interstitial-inducing URL
const GURL url2("https://www.google.com");
contents->controller()->LoadURL(url2, PageTransition::TYPED);
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
EXPECT_TRUE(contents->state_is_entering_interstitial());
int interstitial_delete_counter = 0;
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
@@ -537,7 +558,8 @@ TEST_F(WebContentsTest, VisitInterstitialURLTwice) {
EXPECT_EQ(interstitial_rvh, contents->render_view_host());
// Interstitial shown a second time in a different RenderViewHost.
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ interstitial = new InterstitialPage(contents, true, interstitial_url);
+ interstitial->Show();
EXPECT_TRUE(contents->state_is_entering_interstitial());
// We expect the original interstitial has been deleted.
EXPECT_EQ(interstitial_delete_counter, 1);
@@ -704,7 +726,11 @@ TEST_F(WebContentsTest, CrossSiteInterstitialDontProceed) {
TestRenderViewHost* pending_rvh = contents->pending_rvh();
// Show an interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
EXPECT_TRUE(contents->state_is_entering_interstitial());
EXPECT_EQ(orig_rvh, contents->render_view_host());
EXPECT_EQ(pending_rvh, contents->pending_rvh());
@@ -753,7 +779,11 @@ TEST_F(WebContentsTest, CrossSiteInterstitialProceed) {
pending_rvh->set_delete_counter(&pending_rvh_delete_count);
// Show an interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
// DidNavigate from the interstitial
@@ -819,7 +849,11 @@ TEST_F(WebContentsTest, CrossSiteInterstitialThenNavigate) {
contents->TestDidNavigate(orig_rvh, params1);
// Show an interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ false,
+ interstitial_url);
+ interstitial->Show();
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
// DidNavigate from the interstitial
@@ -875,7 +909,11 @@ TEST_F(WebContentsTest, CrossSiteInterstitialCrashThenNavigate) {
pending_rvh->set_delete_counter(&pending_rvh_delete_count);
// Show an interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
// DidNavigate from the interstitial
@@ -938,7 +976,11 @@ TEST_F(WebContentsTest, CrossSiteInterstitialCrashesThenNavigate) {
pending_rvh->set_delete_counter(&pending_rvh_delete_count);
// Show an interstitial
- contents->ShowInterstitialPage(std::string("Blocked"), NULL);
+ const GURL interstitial_url("http://interstitial");
+ InterstitialPage* interstitial = new InterstitialPage(contents,
+ true,
+ interstitial_url);
+ interstitial->Show();
TestRenderViewHost* interstitial_rvh = contents->interstitial_rvh();
// DidNavigate from the interstitial