diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 16:48:06 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 16:48:06 +0000 |
commit | 74bad4b4c067b980ceb9d5b80c82ef67cc55826d (patch) | |
tree | 9cfc1d548ac07103615e3061bbc11dc6736e2b86 /chrome/browser/tab_contents/web_contents_unittest.cc | |
parent | ce5c4504531cfd32972dfd123f98183c3706951a (diff) | |
download | chromium_src-74bad4b4c067b980ceb9d5b80c82ef67cc55826d.zip chromium_src-74bad4b4c067b980ceb9d5b80c82ef67cc55826d.tar.gz chromium_src-74bad4b4c067b980ceb9d5b80c82ef67cc55826d.tar.bz2 |
Adding a test for a testing that the bug http://crbug.com/9791 is really fixed.
Removing the interstitial UI tests: they test the same functionalities as the unit-tests but are flacky and
most of them have been disabled (a new unit-test for the "show interstitial and then navigate back" has been added to cover for a case that the unit-tests were not covering).
TEST=Run the unit-tests.
BUG=6729,3327
Review URL: http://codereview.chromium.org/109038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15416 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 | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index e9367e6..97e09a5 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -902,6 +902,38 @@ TEST_F(TabContentsTest, ShowInterstitialThenNavigate) { EXPECT_EQ(TestInterstitialPage::CANCELED, state); } +// Test navigating to a page that shows an interstitial, then going back. +TEST_F(TabContentsTest, ShowInterstitialThenGoBack) { + // Navigate to a page so we have a navigation entry in the controller. + GURL url1("http://www.google.com"); + rvh()->SendNavigate(1, url1); + EXPECT_EQ(1, controller().entry_count()); + + // Show interstitial. + TestInterstitialPage::InterstitialState state = + TestInterstitialPage::UNDECIDED; + bool deleted = false; + GURL interstitial_url("http://interstitial"); + TestInterstitialPage* interstitial = + new TestInterstitialPage(contents(), true, interstitial_url, + &state, &deleted); + TestInterstitialPageStateGuard state_guard(interstitial); + interstitial->Show(); + interstitial->TestDidNavigate(2, interstitial_url); + + // While the interstitial is showing, go back. + controller().GoBack(); + rvh()->SendNavigate(1, url1); + + // Make sure we are back to the original page and that the interstitial is + // gone. + EXPECT_TRUE(deleted); + EXPECT_EQ(TestInterstitialPage::CANCELED, state); + NavigationEntry* entry = controller().GetActiveEntry(); + ASSERT_TRUE(entry); + EXPECT_EQ(url1.spec(), entry->url().spec()); +} + // Test navigating to a page that shows an interstitial, then close the tab. TEST_F(TabContentsTest, ShowInterstitialThenCloseTab) { // Show interstitial. @@ -1117,3 +1149,47 @@ TEST_F(TabContentsTest, InterstitialCrasher) { EXPECT_TRUE(deleted); EXPECT_EQ(TestInterstitialPage::CANCELED, state); } + +// Tests that showing an interstitial as a result of a browser initiated +// navigation while an interstitial is showing does not remove the pending +// entry (see http://crbug.com/9791). +TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) { + const char kUrl[] = "http://www.badguys.com/"; + const GURL kGURL(kUrl); + + // Start a navigation to a page + contents()->controller().LoadURL(kGURL, GURL(), PageTransition::TYPED); + + // Simulate that navigation triggering an interstitial. + 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); + + // Initiate a new navigation from the browser that also triggers an + // interstitial. + contents()->controller().LoadURL(kGURL, GURL(), PageTransition::TYPED); + TestInterstitialPage::InterstitialState state2 = + TestInterstitialPage::UNDECIDED; + bool deleted2 = false; + TestInterstitialPage* interstitial2 = + new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); + TestInterstitialPageStateGuard state_guard2(interstitial2); + interstitial2->Show(); + interstitial2->TestDidNavigate(1, kGURL); + + // Make sure we still have an entry. + NavigationEntry* entry = contents()->controller().pending_entry(); + ASSERT_TRUE(entry); + EXPECT_EQ(kUrl, entry->url().spec()); + + // And that the first interstitial is gone, but not the second. + EXPECT_TRUE(deleted); + EXPECT_EQ(TestInterstitialPage::CANCELED, state); + EXPECT_FALSE(deleted2); + EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); +} |