| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void TestDomOperationResponse(const std::string& json_string) { | 113 void TestDomOperationResponse(const std::string& json_string) { |
| 114 DomOperationResponse(json_string, 1); | 114 DomOperationResponse(json_string, 1); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void TestDidNavigate(int page_id, const GURL& url) { | 117 void TestDidNavigate(int page_id, const GURL& url) { |
| 118 ViewHostMsg_FrameNavigate_Params params; | 118 ViewHostMsg_FrameNavigate_Params params; |
| 119 InitNavigateParams(¶ms, page_id, url); | 119 InitNavigateParams(¶ms, page_id, url); |
| 120 DidNavigate(render_view_host(), params); | 120 DidNavigate(render_view_host(), params); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void TestRenderViewGone() { | 123 void TestRenderViewGone(base::TerminationStatus status, int error_code) { |
| 124 RenderViewGone(render_view_host()); | 124 RenderViewGone(render_view_host(), status, error_code); |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool is_showing() const { | 127 bool is_showing() const { |
| 128 return static_cast<TestRenderWidgetHostView*>(render_view_host()->view())-> | 128 return static_cast<TestRenderWidgetHostView*>(render_view_host()->view())-> |
| 129 is_showing(); | 129 is_showing(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ClearStates() { | 132 void ClearStates() { |
| 133 state_ = NULL; | 133 state_ = NULL; |
| 134 deleted_ = NULL; | 134 deleted_ = NULL; |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 bool deleted = false; | 1144 bool deleted = false; |
| 1145 GURL interstitial_url("http://interstitial"); | 1145 GURL interstitial_url("http://interstitial"); |
| 1146 TestInterstitialPage* interstitial = | 1146 TestInterstitialPage* interstitial = |
| 1147 new TestInterstitialPage(contents(), true, interstitial_url, | 1147 new TestInterstitialPage(contents(), true, interstitial_url, |
| 1148 &state, &deleted); | 1148 &state, &deleted); |
| 1149 TestInterstitialPageStateGuard state_guard(interstitial); | 1149 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1150 interstitial->Show(); | 1150 interstitial->Show(); |
| 1151 interstitial->TestDidNavigate(2, interstitial_url); | 1151 interstitial->TestDidNavigate(2, interstitial_url); |
| 1152 | 1152 |
| 1153 // Crash the renderer | 1153 // Crash the renderer |
| 1154 rvh()->TestOnMessageReceived(ViewHostMsg_RenderViewGone(0)); | 1154 rvh()->TestOnMessageReceived( |
| 1155 ViewHostMsg_RenderViewGone( |
| 1156 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 1155 | 1157 |
| 1156 // While the interstitial is showing, go back. | 1158 // While the interstitial is showing, go back. |
| 1157 controller().GoBack(); | 1159 controller().GoBack(); |
| 1158 rvh()->SendNavigate(1, url1); | 1160 rvh()->SendNavigate(1, url1); |
| 1159 | 1161 |
| 1160 // Make sure we are back to the original page and that the interstitial is | 1162 // Make sure we are back to the original page and that the interstitial is |
| 1161 // gone. | 1163 // gone. |
| 1162 EXPECT_TRUE(deleted); | 1164 EXPECT_TRUE(deleted); |
| 1163 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1165 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
| 1164 NavigationEntry* entry = controller().GetActiveEntry(); | 1166 NavigationEntry* entry = controller().GetActiveEntry(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1179 TestInterstitialPage::UNDECIDED; | 1181 TestInterstitialPage::UNDECIDED; |
| 1180 bool deleted = false; | 1182 bool deleted = false; |
| 1181 GURL interstitial_url("http://interstitial"); | 1183 GURL interstitial_url("http://interstitial"); |
| 1182 TestInterstitialPage* interstitial = | 1184 TestInterstitialPage* interstitial = |
| 1183 new TestInterstitialPage(contents(), true, interstitial_url, | 1185 new TestInterstitialPage(contents(), true, interstitial_url, |
| 1184 &state, &deleted); | 1186 &state, &deleted); |
| 1185 TestInterstitialPageStateGuard state_guard(interstitial); | 1187 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1186 interstitial->Show(); | 1188 interstitial->Show(); |
| 1187 | 1189 |
| 1188 // Crash the renderer | 1190 // Crash the renderer |
| 1189 rvh()->TestOnMessageReceived(ViewHostMsg_RenderViewGone(0)); | 1191 rvh()->TestOnMessageReceived( |
| 1192 ViewHostMsg_RenderViewGone( |
| 1193 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 1190 | 1194 |
| 1191 interstitial->TestDidNavigate(2, interstitial_url); | 1195 interstitial->TestDidNavigate(2, interstitial_url); |
| 1192 } | 1196 } |
| 1193 | 1197 |
| 1194 // Test navigating to a page that shows an interstitial, then close the tab. | 1198 // Test navigating to a page that shows an interstitial, then close the tab. |
| 1195 TEST_F(TabContentsTest, ShowInterstitialThenCloseTab) { | 1199 TEST_F(TabContentsTest, ShowInterstitialThenCloseTab) { |
| 1196 // Show interstitial. | 1200 // Show interstitial. |
| 1197 TestInterstitialPage::InterstitialState state = | 1201 TestInterstitialPage::InterstitialState state = |
| 1198 TestInterstitialPage::UNDECIDED; | 1202 TestInterstitialPage::UNDECIDED; |
| 1199 bool deleted = false; | 1203 bool deleted = false; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 // Show an interstitial. | 1426 // Show an interstitial. |
| 1423 TestInterstitialPage::InterstitialState state = | 1427 TestInterstitialPage::InterstitialState state = |
| 1424 TestInterstitialPage::UNDECIDED; | 1428 TestInterstitialPage::UNDECIDED; |
| 1425 bool deleted = false; | 1429 bool deleted = false; |
| 1426 GURL url("http://interstitial"); | 1430 GURL url("http://interstitial"); |
| 1427 TestInterstitialPage* interstitial = | 1431 TestInterstitialPage* interstitial = |
| 1428 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1432 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
| 1429 TestInterstitialPageStateGuard state_guard(interstitial); | 1433 TestInterstitialPageStateGuard state_guard(interstitial); |
| 1430 interstitial->Show(); | 1434 interstitial->Show(); |
| 1431 // Simulate a renderer crash before the interstitial is shown. | 1435 // Simulate a renderer crash before the interstitial is shown. |
| 1432 interstitial->TestRenderViewGone(); | 1436 interstitial->TestRenderViewGone( |
| 1437 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 1433 // The interstitial should have been dismissed. | 1438 // The interstitial should have been dismissed. |
| 1434 EXPECT_TRUE(deleted); | 1439 EXPECT_TRUE(deleted); |
| 1435 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1440 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
| 1436 | 1441 |
| 1437 // Now try again but this time crash the intersitial after it was shown. | 1442 // Now try again but this time crash the intersitial after it was shown. |
| 1438 interstitial = | 1443 interstitial = |
| 1439 new TestInterstitialPage(contents(), true, url, &state, &deleted); | 1444 new TestInterstitialPage(contents(), true, url, &state, &deleted); |
| 1440 interstitial->Show(); | 1445 interstitial->Show(); |
| 1441 interstitial->TestDidNavigate(1, url); | 1446 interstitial->TestDidNavigate(1, url); |
| 1442 // Simulate a renderer crash. | 1447 // Simulate a renderer crash. |
| 1443 interstitial->TestRenderViewGone(); | 1448 interstitial->TestRenderViewGone( |
| 1449 base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 1444 // The interstitial should have been dismissed. | 1450 // The interstitial should have been dismissed. |
| 1445 EXPECT_TRUE(deleted); | 1451 EXPECT_TRUE(deleted); |
| 1446 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1452 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
| 1447 } | 1453 } |
| 1448 | 1454 |
| 1449 // Tests that showing an interstitial as a result of a browser initiated | 1455 // Tests that showing an interstitial as a result of a browser initiated |
| 1450 // navigation while an interstitial is showing does not remove the pending | 1456 // navigation while an interstitial is showing does not remove the pending |
| 1451 // entry (see http://crbug.com/9791). | 1457 // entry (see http://crbug.com/9791). |
| 1452 TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) { | 1458 TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) { |
| 1453 const char kUrl[] = "http://www.badguys.com/"; | 1459 const char kUrl[] = "http://www.badguys.com/"; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 | 1610 |
| 1605 // It should have a transient entry. | 1611 // It should have a transient entry. |
| 1606 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1612 EXPECT_TRUE(other_controller.GetTransientEntry()); |
| 1607 | 1613 |
| 1608 // And the interstitial should be showing. | 1614 // And the interstitial should be showing. |
| 1609 EXPECT_TRUE(other_contents->showing_interstitial_page()); | 1615 EXPECT_TRUE(other_contents->showing_interstitial_page()); |
| 1610 | 1616 |
| 1611 // And the interstitial should do a reload on don't proceed. | 1617 // And the interstitial should do a reload on don't proceed. |
| 1612 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); | 1618 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); |
| 1613 } | 1619 } |
| OLD | NEW |