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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 2506183002: Make window.open() IPCs be frame-based (Closed)
Patch Set: Compile fix. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index 08413755370f5e435379a981d80141bf0148f686..6bd522f451ec0c06023acb27472e0bd2496bc950 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -2616,14 +2616,32 @@ TEST_F(WebContentsImplTest, FilterURLs) {
// Test that if a pending contents is deleted before it is shown, we don't
// crash.
-TEST_F(WebContentsImplTest, PendingContents) {
+TEST_F(WebContentsImplTest, PendingContentsDestroyed) {
std::unique_ptr<TestWebContents> other_contents(
static_cast<TestWebContents*>(CreateTestWebContents()));
contents()->AddPendingContents(other_contents.get());
- int process_id = other_contents->GetRenderViewHost()->GetProcess()->GetID();
- int route_id = other_contents->GetRenderViewHost()->GetRoutingID();
+ RenderWidgetHost* widget =
+ other_contents->GetMainFrame()->GetRenderWidgetHost();
+ int process_id = widget->GetProcess()->GetID();
+ int widget_id = widget->GetRoutingID();
other_contents.reset();
- EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, route_id));
+ EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, widget_id));
+}
+
+TEST_F(WebContentsImplTest, PendingContentsShown) {
+ std::unique_ptr<TestWebContents> other_contents(
+ static_cast<TestWebContents*>(CreateTestWebContents()));
+ contents()->AddPendingContents(other_contents.get());
+ RenderWidgetHost* widget =
+ other_contents->GetMainFrame()->GetRenderWidgetHost();
+ int process_id = widget->GetProcess()->GetID();
+ int widget_id = widget->GetRoutingID();
+
+ // The first call to GetCreatedWindow pops it off the pending list.
+ EXPECT_EQ(other_contents.get(),
+ contents()->GetCreatedWindow(process_id, widget_id));
+ // A second call should return nullptr, verifying that it's been forgotten.
+ EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, widget_id));
}
TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) {

Powered by Google App Engine
This is Rietveld 408576698