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

Side by Side Diff: chrome/browser/tab_contents/web_contents_unittest.cc

Issue 3386014: This adds some plumbing for propagating the status and error code of a (Closed)
Patch Set: Fixed Mac code to handle both SEGV and BUS Created 10 years, 3 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
« no previous file with comments | « chrome/browser/tab_contents/interstitial_page.cc ('k') | chrome/browser/task_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(&params, page_id, url); 119 InitNavigateParams(&params, 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
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
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 // Show an interstitial. 1387 // Show an interstitial.
1384 TestInterstitialPage::InterstitialState state = 1388 TestInterstitialPage::InterstitialState state =
1385 TestInterstitialPage::UNDECIDED; 1389 TestInterstitialPage::UNDECIDED;
1386 bool deleted = false; 1390 bool deleted = false;
1387 GURL url("http://interstitial"); 1391 GURL url("http://interstitial");
1388 TestInterstitialPage* interstitial = 1392 TestInterstitialPage* interstitial =
1389 new TestInterstitialPage(contents(), true, url, &state, &deleted); 1393 new TestInterstitialPage(contents(), true, url, &state, &deleted);
1390 TestInterstitialPageStateGuard state_guard(interstitial); 1394 TestInterstitialPageStateGuard state_guard(interstitial);
1391 interstitial->Show(); 1395 interstitial->Show();
1392 // Simulate a renderer crash before the interstitial is shown. 1396 // Simulate a renderer crash before the interstitial is shown.
1393 interstitial->TestRenderViewGone(); 1397 interstitial->TestRenderViewGone(
1398 base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1394 // The interstitial should have been dismissed. 1399 // The interstitial should have been dismissed.
1395 EXPECT_TRUE(deleted); 1400 EXPECT_TRUE(deleted);
1396 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1401 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1397 1402
1398 // Now try again but this time crash the intersitial after it was shown. 1403 // Now try again but this time crash the intersitial after it was shown.
1399 interstitial = 1404 interstitial =
1400 new TestInterstitialPage(contents(), true, url, &state, &deleted); 1405 new TestInterstitialPage(contents(), true, url, &state, &deleted);
1401 interstitial->Show(); 1406 interstitial->Show();
1402 interstitial->TestDidNavigate(1, url); 1407 interstitial->TestDidNavigate(1, url);
1403 // Simulate a renderer crash. 1408 // Simulate a renderer crash.
1404 interstitial->TestRenderViewGone(); 1409 interstitial->TestRenderViewGone(
1410 base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1405 // The interstitial should have been dismissed. 1411 // The interstitial should have been dismissed.
1406 EXPECT_TRUE(deleted); 1412 EXPECT_TRUE(deleted);
1407 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 1413 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
1408 } 1414 }
1409 1415
1410 // Tests that showing an interstitial as a result of a browser initiated 1416 // Tests that showing an interstitial as a result of a browser initiated
1411 // navigation while an interstitial is showing does not remove the pending 1417 // navigation while an interstitial is showing does not remove the pending
1412 // entry (see http://crbug.com/9791). 1418 // entry (see http://crbug.com/9791).
1413 TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) { 1419 TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) {
1414 const char kUrl[] = "http://www.badguys.com/"; 1420 const char kUrl[] = "http://www.badguys.com/";
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 1571
1566 // It should have a transient entry. 1572 // It should have a transient entry.
1567 EXPECT_TRUE(other_controller.GetTransientEntry()); 1573 EXPECT_TRUE(other_controller.GetTransientEntry());
1568 1574
1569 // And the interstitial should be showing. 1575 // And the interstitial should be showing.
1570 EXPECT_TRUE(other_contents->showing_interstitial_page()); 1576 EXPECT_TRUE(other_contents->showing_interstitial_page());
1571 1577
1572 // And the interstitial should do a reload on don't proceed. 1578 // And the interstitial should do a reload on don't proceed.
1573 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); 1579 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed());
1574 } 1580 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/interstitial_page.cc ('k') | chrome/browser/task_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698