| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/captive_portal/captive_portal_service.h" | 10 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Simulates an abort while requesting |url|. | 122 // Simulates an abort while requesting |url|. |
| 123 void SimulateAbort(const GURL& url, | 123 void SimulateAbort(const GURL& url, |
| 124 NavigationType navigation_type) { | 124 NavigationType navigation_type) { |
| 125 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsCryptographic())) | 125 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsCryptographic())) |
| 126 .Times(1); | 126 .Times(1); |
| 127 content::WebContentsTester* web_contents_tester = | 127 content::WebContentsTester* web_contents_tester = |
| 128 content::WebContentsTester::For(web_contents()); | 128 content::WebContentsTester::For(web_contents()); |
| 129 web_contents_tester->StartNavigation(url); | 129 web_contents_tester->StartNavigation(url); |
| 130 DCHECK_IMPLIES(navigation_type == kSameProcess, !pending_main_rfh()); | 130 DCHECK(navigation_type != kSameProcess || !pending_main_rfh()); |
| 131 | 131 |
| 132 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); | 132 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); |
| 133 content::RenderFrameHost* rfh = | 133 content::RenderFrameHost* rfh = |
| 134 navigation_type == kSameProcess ? main_rfh() : pending_main_rfh(); | 134 navigation_type == kSameProcess ? main_rfh() : pending_main_rfh(); |
| 135 content::RenderFrameHostTester* rfh_tester = | 135 content::RenderFrameHostTester* rfh_tester = |
| 136 content::RenderFrameHostTester::For(rfh); | 136 content::RenderFrameHostTester::For(rfh); |
| 137 rfh_tester->SimulateNavigationError(url, net::ERR_ABORTED); | 137 rfh_tester->SimulateNavigationError(url, net::ERR_ABORTED); |
| 138 // PlzNavigate: on abort, no renderer will have been associated with the | 138 // PlzNavigate: on abort, no renderer will have been associated with the |
| 139 // navigation. Therefore do not simulate a DidStopLoading IPC coming from a | 139 // navigation. Therefore do not simulate a DidStopLoading IPC coming from a |
| 140 // renderer. | 140 // renderer. |
| 141 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 141 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 142 switches::kEnableBrowserSideNavigation)) { | 142 switches::kEnableBrowserSideNavigation)) { |
| 143 rfh_tester->SimulateNavigationStop(); | 143 rfh_tester->SimulateNavigationStop(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Make sure that above call resulted in abort, for tests that continue | 146 // Make sure that above call resulted in abort, for tests that continue |
| 147 // after the abort. | 147 // after the abort. |
| 148 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0); | 148 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Simulates an abort while loading an error page. | 151 // Simulates an abort while loading an error page. |
| 152 void SimulateAbortTimeout(const GURL& url, | 152 void SimulateAbortTimeout(const GURL& url, |
| 153 NavigationType navigation_type) { | 153 NavigationType navigation_type) { |
| 154 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsCryptographic())) | 154 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsCryptographic())) |
| 155 .Times(1); | 155 .Times(1); |
| 156 content::WebContentsTester* web_contents_tester = | 156 content::WebContentsTester* web_contents_tester = |
| 157 content::WebContentsTester::For(web_contents()); | 157 content::WebContentsTester::For(web_contents()); |
| 158 web_contents_tester->StartNavigation(url); | 158 web_contents_tester->StartNavigation(url); |
| 159 DCHECK_IMPLIES(navigation_type == kSameProcess, !pending_main_rfh()); | 159 DCHECK(navigation_type != kSameProcess || !pending_main_rfh()); |
| 160 | 160 |
| 161 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); | 161 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); |
| 162 content::RenderFrameHost* rfh = | 162 content::RenderFrameHost* rfh = |
| 163 navigation_type == kSameProcess ? main_rfh() : pending_main_rfh(); | 163 navigation_type == kSameProcess ? main_rfh() : pending_main_rfh(); |
| 164 content::RenderFrameHostTester* rfh_tester = | 164 content::RenderFrameHostTester* rfh_tester = |
| 165 content::RenderFrameHostTester::For(rfh); | 165 content::RenderFrameHostTester::For(rfh); |
| 166 rfh_tester->SimulateNavigationError(url, net::ERR_TIMED_OUT); | 166 rfh_tester->SimulateNavigationError(url, net::ERR_TIMED_OUT); |
| 167 rfh_tester->SimulateNavigationStop(); | 167 rfh_tester->SimulateNavigationStop(); |
| 168 | 168 |
| 169 // Make sure that above call resulted in abort, for tests that continue | 169 // Make sure that above call resulted in abort, for tests that continue |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 520 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 521 | 521 |
| 522 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, | 522 ObservePortalResult(captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL, |
| 523 captive_portal::RESULT_NO_RESPONSE); | 523 captive_portal::RESULT_NO_RESPONSE); |
| 524 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 524 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 525 | 525 |
| 526 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, | 526 ObservePortalResult(captive_portal::RESULT_NO_RESPONSE, |
| 527 captive_portal::RESULT_INTERNET_CONNECTED); | 527 captive_portal::RESULT_INTERNET_CONNECTED); |
| 528 EXPECT_FALSE(tab_helper()->IsLoginTab()); | 528 EXPECT_FALSE(tab_helper()->IsLoginTab()); |
| 529 } | 529 } |
| OLD | NEW |