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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 CHECK(render_frame_host->GetProcess()->HasConnection()) | 49 CHECK(render_frame_host->GetProcess()->HasConnection()) |
50 << "RenderFrameCreated was called for a RenderFrameHost whose render " | 50 << "RenderFrameCreated was called for a RenderFrameHost whose render " |
51 "process is not currently live, so there's no way for the RenderFrame " | 51 "process is not currently live, so there's no way for the RenderFrame " |
52 "to have been created."; | 52 "to have been created."; |
53 CHECK( | 53 CHECK( |
54 static_cast<RenderFrameHostImpl*>(render_frame_host)->IsRenderFrameLive()) | 54 static_cast<RenderFrameHostImpl*>(render_frame_host)->IsRenderFrameLive()) |
55 << "RenderFrameCreated called on for a RenderFrameHost that thinks it is " | 55 << "RenderFrameCreated called on for a RenderFrameHost that thinks it is " |
56 "not alive."; | 56 "not alive."; |
| 57 |
| 58 // Any child frame must be in the same BrowsingInstance as its parent. |
| 59 if (render_frame_host->GetParent()) { |
| 60 CHECK(render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( |
| 61 render_frame_host->GetParent()->GetSiteInstance())); |
| 62 } |
57 } | 63 } |
58 | 64 |
59 void WebContentsObserverSanityChecker::RenderFrameDeleted( | 65 void WebContentsObserverSanityChecker::RenderFrameDeleted( |
60 RenderFrameHost* render_frame_host) { | 66 RenderFrameHost* render_frame_host) { |
61 CHECK(!web_contents_destroyed_); | 67 CHECK(!web_contents_destroyed_); |
62 std::pair<int, int> routing_pair = | 68 std::pair<int, int> routing_pair = |
63 std::make_pair(render_frame_host->GetProcess()->GetID(), | 69 std::make_pair(render_frame_host->GetProcess()->GetID(), |
64 render_frame_host->GetRoutingID()); | 70 render_frame_host->GetRoutingID()); |
65 bool was_live = !!live_routes_.erase(routing_pair); | 71 bool was_live = !!live_routes_.erase(routing_pair); |
66 bool was_dead_already = !deleted_routes_.insert(routing_pair).second; | 72 bool was_dead_already = !deleted_routes_.insert(routing_pair).second; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); | 322 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); |
317 } | 323 } |
318 | 324 |
319 bool WebContentsObserverSanityChecker::NavigationIsOngoing( | 325 bool WebContentsObserverSanityChecker::NavigationIsOngoing( |
320 NavigationHandle* navigation_handle) { | 326 NavigationHandle* navigation_handle) { |
321 auto it = ongoing_navigations_.find(navigation_handle); | 327 auto it = ongoing_navigations_.find(navigation_handle); |
322 return it != ongoing_navigations_.end(); | 328 return it != ongoing_navigations_.end(); |
323 } | 329 } |
324 | 330 |
325 } // namespace content | 331 } // namespace content |
OLD | NEW |