Chromium Code Reviews| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 EnsureStableParentValue(render_frame_host); | 151 EnsureStableParentValue(render_frame_host); |
| 152 | 152 |
| 153 CHECK(!HasAnyChildren(render_frame_host)) | 153 CHECK(!HasAnyChildren(render_frame_host)) |
| 154 << "All children should be deleted before a frame is detached."; | 154 << "All children should be deleted before a frame is detached."; |
| 155 | 155 |
| 156 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); | 156 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); |
| 157 CHECK(current_hosts_.erase(routing_pair)) | 157 CHECK(current_hosts_.erase(routing_pair)) |
| 158 << "FrameDeleted called with a non-current RenderFrameHost."; | 158 << "FrameDeleted called with a non-current RenderFrameHost."; |
| 159 | 159 |
| 160 if (render_frame_host->GetParent()) | 160 if (render_frame_host->GetParent()) |
| 161 AssertRenderFrameExists(render_frame_host->GetParent()); | 161 AssertRenderFrameExists(render_frame_host->GetParent()); |
|
nasko
2015/12/18 15:10:51
This is causing issues when process has died accor
| |
| 162 } | 162 } |
| 163 | 163 |
| 164 void WebContentsObserverSanityChecker::DidStartNavigation( | 164 void WebContentsObserverSanityChecker::DidStartNavigation( |
| 165 NavigationHandle* navigation_handle) { | 165 NavigationHandle* navigation_handle) { |
| 166 CHECK(!NavigationIsOngoing(navigation_handle)); | 166 CHECK(!NavigationIsOngoing(navigation_handle)); |
| 167 | 167 |
| 168 CHECK(navigation_handle->GetNetErrorCode() == net::OK); | 168 CHECK(navigation_handle->GetNetErrorCode() == net::OK); |
| 169 CHECK(!navigation_handle->HasCommitted()); | 169 CHECK(!navigation_handle->HasCommitted()); |
| 170 CHECK(!navigation_handle->IsErrorPage()); | 170 CHECK(!navigation_handle->IsErrorPage()); |
| 171 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); | 171 CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 active_media_players_.end()); | 310 active_media_players_.end()); |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool WebContentsObserverSanityChecker::OnMessageReceived( | 313 bool WebContentsObserverSanityChecker::OnMessageReceived( |
| 314 const IPC::Message& message, | 314 const IPC::Message& message, |
| 315 RenderFrameHost* render_frame_host) { | 315 RenderFrameHost* render_frame_host) { |
| 316 // FrameHostMsg_RenderProcessGone is special internal IPC message that | 316 // FrameHostMsg_RenderProcessGone is special internal IPC message that |
| 317 // should not be leaking outside of RenderFrameHost. | 317 // should not be leaking outside of RenderFrameHost. |
| 318 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID); | 318 CHECK(message.type() != FrameHostMsg_RenderProcessGone::ID); |
| 319 | 319 |
| 320 #if !defined(OS_MACOSX) | |
| 321 // TODO(avi): Disabled because of http://crbug.com/445054 | |
|
nasko
2015/12/18 15:10:51
Yay!
| |
| 322 AssertRenderFrameExists(render_frame_host); | 320 AssertRenderFrameExists(render_frame_host); |
| 323 #endif | |
| 324 return false; | 321 return false; |
| 325 } | 322 } |
| 326 | 323 |
| 327 void WebContentsObserverSanityChecker::WebContentsDestroyed() { | 324 void WebContentsObserverSanityChecker::WebContentsDestroyed() { |
| 328 CHECK(!web_contents_destroyed_); | 325 CHECK(!web_contents_destroyed_); |
| 329 web_contents_destroyed_ = true; | 326 web_contents_destroyed_ = true; |
| 330 CHECK(ongoing_navigations_.empty()); | 327 CHECK(ongoing_navigations_.empty()); |
| 331 CHECK(active_media_players_.empty()); | 328 CHECK(active_media_players_.empty()); |
| 332 } | 329 } |
| 333 | 330 |
| 334 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( | 331 WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( |
| 335 WebContents* web_contents) | 332 WebContents* web_contents) |
| 336 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { | 333 : WebContentsObserver(web_contents), web_contents_destroyed_(false) { |
| 337 } | 334 } |
| 338 | 335 |
| 339 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { | 336 WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { |
| 340 CHECK(web_contents_destroyed_); | 337 CHECK(web_contents_destroyed_); |
| 341 } | 338 } |
| 342 | 339 |
| 343 void WebContentsObserverSanityChecker::AssertRenderFrameExists( | 340 void WebContentsObserverSanityChecker::AssertRenderFrameExists( |
| 344 RenderFrameHost* render_frame_host) { | 341 RenderFrameHost* render_frame_host) { |
| 345 CHECK(!web_contents_destroyed_); | 342 CHECK(!web_contents_destroyed_); |
| 343 CHECK(render_frame_host->IsRenderFrameLive()); | |
| 344 | |
| 346 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); | 345 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); |
| 347 | 346 |
| 348 bool render_frame_created_happened = live_routes_.count(routing_pair) != 0; | 347 bool render_frame_created_happened = live_routes_.count(routing_pair) != 0; |
| 349 bool render_frame_deleted_happened = deleted_routes_.count(routing_pair) != 0; | 348 bool render_frame_deleted_happened = deleted_routes_.count(routing_pair) != 0; |
| 350 | 349 |
| 351 CHECK(render_frame_created_happened) | 350 CHECK(render_frame_created_happened) |
| 352 << "A RenderFrameHost pointer was passed to a WebContentsObserver " | 351 << "A RenderFrameHost pointer was passed to a WebContentsObserver " |
| 353 << "method, but WebContentsObserver::RenderFrameCreated was never called " | 352 << "method, but WebContentsObserver::RenderFrameCreated was never called " |
| 354 << "for that RenderFrameHost: " << Format(render_frame_host); | 353 << "for that RenderFrameHost: " << Format(render_frame_host); |
| 355 CHECK(!render_frame_deleted_happened) | 354 CHECK(!render_frame_deleted_happened) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 if (live_routes_.count(entry.first)) | 398 if (live_routes_.count(entry.first)) |
| 400 return true; | 399 return true; |
| 401 if (current_hosts_.count(entry.first)) | 400 if (current_hosts_.count(entry.first)) |
| 402 return true; | 401 return true; |
| 403 } | 402 } |
| 404 } | 403 } |
| 405 return false; | 404 return false; |
| 406 } | 405 } |
| 407 | 406 |
| 408 } // namespace content | 407 } // namespace content |
| OLD | NEW |