| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/test/web_contents_observer_sanity_checker.h" | 5 #include "content/test/web_contents_observer_sanity_checker.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/browser/frame_host/render_frame_host_impl.h" | 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/public/browser/navigation_handle.h" | 10 #include "content/public/browser/navigation_handle.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 void WebContentsObserverSanityChecker::DidStartNavigation( | 124 void WebContentsObserverSanityChecker::DidStartNavigation( |
| 125 NavigationHandle* navigation_handle) { | 125 NavigationHandle* navigation_handle) { |
| 126 CHECK(!NavigationIsOngoing(navigation_handle)); | 126 CHECK(!NavigationIsOngoing(navigation_handle)); |
| 127 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); | 127 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); |
| 128 | 128 |
| 129 CHECK(navigation_handle->GetNetErrorCode() == net::OK); | 129 CHECK(navigation_handle->GetNetErrorCode() == net::OK); |
| 130 CHECK(!navigation_handle->HasCommittedDocument()); | 130 CHECK(!navigation_handle->HasCommittedDocument()); |
| 131 CHECK(!navigation_handle->HasCommittedErrorPage()); | 131 CHECK(!navigation_handle->HasCommittedErrorPage()); |
| 132 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); | |
| 133 | 132 |
| 134 ongoing_navigations_.insert(navigation_handle); | 133 ongoing_navigations_.insert(navigation_handle); |
| 135 } | 134 } |
| 136 | 135 |
| 137 void WebContentsObserverSanityChecker::DidRedirectNavigation( | 136 void WebContentsObserverSanityChecker::DidRedirectNavigation( |
| 138 NavigationHandle* navigation_handle) { | 137 NavigationHandle* navigation_handle) { |
| 139 CHECK(NavigationIsOngoing(navigation_handle)); | 138 CHECK(NavigationIsOngoing(navigation_handle)); |
| 140 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); | 139 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); |
| 141 | 140 |
| 142 CHECK(navigation_handle->GetNetErrorCode() == net::OK); | 141 CHECK(navigation_handle->GetNetErrorCode() == net::OK); |
| 143 CHECK(!navigation_handle->HasCommittedDocument()); | 142 CHECK(!navigation_handle->HasCommittedDocument()); |
| 144 CHECK(!navigation_handle->HasCommittedErrorPage()); | 143 CHECK(!navigation_handle->HasCommittedErrorPage()); |
| 145 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); | |
| 146 } | 144 } |
| 147 | 145 |
| 148 void WebContentsObserverSanityChecker::ReadyToCommitNavigation( | 146 void WebContentsObserverSanityChecker::ReadyToCommitNavigation( |
| 149 NavigationHandle* navigation_handle) { | 147 NavigationHandle* navigation_handle) { |
| 150 CHECK(NavigationIsOngoing(navigation_handle)); | 148 CHECK(NavigationIsOngoing(navigation_handle)); |
| 151 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); | 149 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); |
| 152 | 150 |
| 153 CHECK(!navigation_handle->HasCommittedDocument()); | 151 CHECK(!navigation_handle->HasCommittedDocument()); |
| 154 CHECK(!navigation_handle->HasCommittedErrorPage()); | 152 CHECK(!navigation_handle->HasCommittedErrorPage()); |
| 155 } | 153 } |
| 156 | 154 |
| 157 void WebContentsObserverSanityChecker::DidCommitNavigation( | 155 void WebContentsObserverSanityChecker::DidCommitNavigation( |
| 158 NavigationHandle* navigation_handle) { | 156 NavigationHandle* navigation_handle) { |
| 159 CHECK(NavigationIsOngoing(navigation_handle)); | 157 CHECK(NavigationIsOngoing(navigation_handle)); |
| 160 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); | 158 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); |
| 161 | 159 |
| 162 CHECK_NE(navigation_handle->HasCommittedDocument(), | 160 CHECK_NE(navigation_handle->HasCommittedDocument(), |
| 163 navigation_handle->HasCommittedErrorPage()); | 161 navigation_handle->HasCommittedErrorPage()); |
| 164 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), | 162 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), |
| 165 navigation_handle->GetNetErrorCode() == net::OK); | 163 navigation_handle->GetNetErrorCode() == net::OK); |
| 166 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), | 164 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), |
| 167 navigation_handle->GetNetErrorCode() != net::OK); | 165 navigation_handle->GetNetErrorCode() != net::OK); |
| 168 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); | |
| 169 | 166 |
| 170 ongoing_committed_navigations_.insert(navigation_handle); | 167 ongoing_committed_navigations_.insert(navigation_handle); |
| 171 } | 168 } |
| 172 | 169 |
| 173 void WebContentsObserverSanityChecker::DidFinishNavigation( | 170 void WebContentsObserverSanityChecker::DidFinishNavigation( |
| 174 NavigationHandle* navigation_handle) { | 171 NavigationHandle* navigation_handle) { |
| 175 CHECK(NavigationIsOngoing(navigation_handle)); | 172 CHECK(NavigationIsOngoing(navigation_handle)); |
| 176 | 173 |
| 177 CHECK_IMPLIES(NavigationIsOngoingAndCommitted(navigation_handle), | 174 CHECK_IMPLIES(NavigationIsOngoingAndCommitted(navigation_handle), |
| 178 navigation_handle->HasCommittedDocument() != | 175 navigation_handle->HasCommittedDocument() != |
| 179 navigation_handle->HasCommittedErrorPage()); | 176 navigation_handle->HasCommittedErrorPage()); |
| 180 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), | 177 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), |
| 181 navigation_handle->GetNetErrorCode() == net::OK); | 178 navigation_handle->GetNetErrorCode() == net::OK); |
| 182 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), | 179 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), |
| 183 navigation_handle->GetNetErrorCode() != net::OK); | 180 navigation_handle->GetNetErrorCode() != net::OK); |
| 184 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); | |
| 185 | 181 |
| 186 if (NavigationIsOngoingAndCommitted(navigation_handle)) | 182 if (NavigationIsOngoingAndCommitted(navigation_handle)) |
| 187 ongoing_committed_navigations_.erase(navigation_handle); | 183 ongoing_committed_navigations_.erase(navigation_handle); |
| 188 | 184 |
| 189 ongoing_navigations_.erase(navigation_handle); | 185 ongoing_navigations_.erase(navigation_handle); |
| 190 } | 186 } |
| 191 | 187 |
| 192 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame( | 188 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame( |
| 193 RenderFrameHost* render_frame_host, | 189 RenderFrameHost* render_frame_host, |
| 194 const GURL& validated_url, | 190 const GURL& validated_url, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return it != ongoing_navigations_.end(); | 340 return it != ongoing_navigations_.end(); |
| 345 } | 341 } |
| 346 | 342 |
| 347 bool WebContentsObserverSanityChecker::NavigationIsOngoingAndCommitted( | 343 bool WebContentsObserverSanityChecker::NavigationIsOngoingAndCommitted( |
| 348 NavigationHandle* navigation_handle) { | 344 NavigationHandle* navigation_handle) { |
| 349 auto it = ongoing_committed_navigations_.find(navigation_handle); | 345 auto it = ongoing_committed_navigations_.find(navigation_handle); |
| 350 return it != ongoing_committed_navigations_.end(); | 346 return it != ongoing_committed_navigations_.end(); |
| 351 } | 347 } |
| 352 | 348 |
| 353 } // namespace content | 349 } // namespace content |
| OLD | NEW |