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

Side by Side 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 unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 other_contents->NavigateAndCommit(url_normalized); 2609 other_contents->NavigateAndCommit(url_normalized);
2610 2610
2611 // Check that an IPC with about:whatever is correctly normalized. 2611 // Check that an IPC with about:whatever is correctly normalized.
2612 other_contents->TestDidFailLoadWithError( 2612 other_contents->TestDidFailLoadWithError(
2613 url_from_ipc, 1, base::string16(), false); 2613 url_from_ipc, 1, base::string16(), false);
2614 EXPECT_EQ(url_normalized, other_observer.last_url()); 2614 EXPECT_EQ(url_normalized, other_observer.last_url());
2615 } 2615 }
2616 2616
2617 // Test that if a pending contents is deleted before it is shown, we don't 2617 // Test that if a pending contents is deleted before it is shown, we don't
2618 // crash. 2618 // crash.
2619 TEST_F(WebContentsImplTest, PendingContents) { 2619 TEST_F(WebContentsImplTest, PendingContentsDestroyed) {
2620 std::unique_ptr<TestWebContents> other_contents( 2620 std::unique_ptr<TestWebContents> other_contents(
2621 static_cast<TestWebContents*>(CreateTestWebContents())); 2621 static_cast<TestWebContents*>(CreateTestWebContents()));
2622 contents()->AddPendingContents(other_contents.get()); 2622 contents()->AddPendingContents(other_contents.get());
2623 int process_id = other_contents->GetRenderViewHost()->GetProcess()->GetID(); 2623 RenderWidgetHost* widget =
2624 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); 2624 other_contents->GetMainFrame()->GetRenderWidgetHost();
2625 int process_id = widget->GetProcess()->GetID();
2626 int widget_id = widget->GetRoutingID();
2625 other_contents.reset(); 2627 other_contents.reset();
2626 EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, route_id)); 2628 EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, widget_id));
2629 }
2630
2631 TEST_F(WebContentsImplTest, PendingContentsShown) {
2632 std::unique_ptr<TestWebContents> other_contents(
2633 static_cast<TestWebContents*>(CreateTestWebContents()));
2634 contents()->AddPendingContents(other_contents.get());
2635 RenderWidgetHost* widget =
2636 other_contents->GetMainFrame()->GetRenderWidgetHost();
2637 int process_id = widget->GetProcess()->GetID();
2638 int widget_id = widget->GetRoutingID();
2639
2640 // The first call to GetCreatedWindow pops it off the pending list.
2641 EXPECT_EQ(other_contents.get(),
2642 contents()->GetCreatedWindow(process_id, widget_id));
2643 // A second call should return nullptr, verifying that it's been forgotten.
2644 EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, widget_id));
2627 } 2645 }
2628 2646
2629 TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) { 2647 TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) {
2630 const gfx::Size original_preferred_size(1024, 768); 2648 const gfx::Size original_preferred_size(1024, 768);
2631 contents()->UpdatePreferredSize(original_preferred_size); 2649 contents()->UpdatePreferredSize(original_preferred_size);
2632 2650
2633 // With no capturers, expect the preferred size to be the one propagated into 2651 // With no capturers, expect the preferred size to be the one propagated into
2634 // WebContentsImpl via the RenderViewHostDelegate interface. 2652 // WebContentsImpl via the RenderViewHostDelegate interface.
2635 EXPECT_EQ(contents()->GetCapturerCount(), 0); 2653 EXPECT_EQ(contents()->GetCapturerCount(), 0);
2636 EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize()); 2654 EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize());
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 // An automatic navigation. 3432 // An automatic navigation.
3415 main_test_rfh()->SendNavigateWithModificationCallback( 3433 main_test_rfh()->SendNavigateWithModificationCallback(
3416 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3434 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3417 3435
3418 EXPECT_EQ(1u, dialog_manager.reset_count()); 3436 EXPECT_EQ(1u, dialog_manager.reset_count());
3419 3437
3420 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3438 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3421 } 3439 }
3422 3440
3423 } // namespace content 3441 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698