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

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: Rebase. Created 3 years, 11 months 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 other_contents->NavigateAndCommit(url_normalized); 2610 other_contents->NavigateAndCommit(url_normalized);
2611 2611
2612 // Check that an IPC with about:whatever is correctly normalized. 2612 // Check that an IPC with about:whatever is correctly normalized.
2613 other_contents->TestDidFailLoadWithError( 2613 other_contents->TestDidFailLoadWithError(
2614 url_from_ipc, 1, base::string16(), false); 2614 url_from_ipc, 1, base::string16(), false);
2615 EXPECT_EQ(url_normalized, other_observer.last_url()); 2615 EXPECT_EQ(url_normalized, other_observer.last_url());
2616 } 2616 }
2617 2617
2618 // Test that if a pending contents is deleted before it is shown, we don't 2618 // Test that if a pending contents is deleted before it is shown, we don't
2619 // crash. 2619 // crash.
2620 TEST_F(WebContentsImplTest, PendingContents) { 2620 TEST_F(WebContentsImplTest, PendingContentsDestroyed) {
2621 std::unique_ptr<TestWebContents> other_contents( 2621 std::unique_ptr<TestWebContents> other_contents(
2622 static_cast<TestWebContents*>(CreateTestWebContents())); 2622 static_cast<TestWebContents*>(CreateTestWebContents()));
2623 contents()->AddPendingContents(other_contents.get()); 2623 contents()->AddPendingContents(other_contents.get());
2624 int process_id = other_contents->GetRenderViewHost()->GetProcess()->GetID(); 2624 RenderWidgetHost* widget =
2625 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); 2625 other_contents->GetMainFrame()->GetRenderWidgetHost();
2626 int process_id = widget->GetProcess()->GetID();
2627 int widget_id = widget->GetRoutingID();
2626 other_contents.reset(); 2628 other_contents.reset();
2627 EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, route_id)); 2629 EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, widget_id));
2630 }
2631
2632 TEST_F(WebContentsImplTest, PendingContentsShown) {
2633 std::unique_ptr<TestWebContents> other_contents(
2634 static_cast<TestWebContents*>(CreateTestWebContents()));
2635 contents()->AddPendingContents(other_contents.get());
2636 RenderWidgetHost* widget =
2637 other_contents->GetMainFrame()->GetRenderWidgetHost();
2638 int process_id = widget->GetProcess()->GetID();
2639 int widget_id = widget->GetRoutingID();
2640
2641 // The first call to GetCreatedWindow pops it off the pending list.
2642 EXPECT_EQ(other_contents.get(),
2643 contents()->GetCreatedWindow(process_id, widget_id));
2644 // A second call should return nullptr, verifying that it's been forgotten.
2645 EXPECT_EQ(nullptr, contents()->GetCreatedWindow(process_id, widget_id));
2628 } 2646 }
2629 2647
2630 TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) { 2648 TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) {
2631 const gfx::Size original_preferred_size(1024, 768); 2649 const gfx::Size original_preferred_size(1024, 768);
2632 contents()->UpdatePreferredSize(original_preferred_size); 2650 contents()->UpdatePreferredSize(original_preferred_size);
2633 2651
2634 // With no capturers, expect the preferred size to be the one propagated into 2652 // With no capturers, expect the preferred size to be the one propagated into
2635 // WebContentsImpl via the RenderViewHostDelegate interface. 2653 // WebContentsImpl via the RenderViewHostDelegate interface.
2636 EXPECT_EQ(contents()->GetCapturerCount(), 0); 2654 EXPECT_EQ(contents()->GetCapturerCount(), 0);
2637 EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize()); 2655 EXPECT_EQ(original_preferred_size, contents()->GetPreferredSize());
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 // An automatic navigation. 3431 // An automatic navigation.
3414 main_test_rfh()->SendNavigateWithModificationCallback( 3432 main_test_rfh()->SendNavigateWithModificationCallback(
3415 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3433 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3416 3434
3417 EXPECT_EQ(1u, dialog_manager.reset_count()); 3435 EXPECT_EQ(1u, dialog_manager.reset_count());
3418 3436
3419 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3437 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3420 } 3438 }
3421 3439
3422 } // namespace content 3440 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698