| OLD | NEW |
| 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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 // increased screenshot interval. | 548 // increased screenshot interval. |
| 549 NavigationController::LoadURLParams params(navigations[0].url); | 549 NavigationController::LoadURLParams params(navigations[0].url); |
| 550 params.transition_type = PageTransitionFromInt(navigations[0].transition); | 550 params.transition_type = PageTransitionFromInt(navigations[0].transition); |
| 551 web_contents->GetController().LoadURLWithParams(params); | 551 web_contents->GetController().LoadURLWithParams(params); |
| 552 WaitForLoadStop(web_contents); | 552 WaitForLoadStop(web_contents); |
| 553 screenshot_manager()->WaitUntilScreenshotIsReady(); | 553 screenshot_manager()->WaitUntilScreenshotIsReady(); |
| 554 | 554 |
| 555 EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for()); | 555 EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for()); |
| 556 } | 556 } |
| 557 | 557 |
| 558 // Tests that navigations resulting from reloads and history.replaceState |
| 559 // do not capture screenshots while navigations resulting from |
| 560 // histrory.pushState do. |
| 561 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ReplaceStateReloadPushState) { |
| 562 ASSERT_NO_FATAL_FAILURE( |
| 563 StartTestWithPage("files/overscroll_navigation.html")); |
| 564 WebContentsImpl* web_contents = |
| 565 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 566 RenderFrameHost* main_frame = web_contents->GetMainFrame(); |
| 567 |
| 568 set_min_screenshot_interval(0); |
| 569 screenshot_manager()->Reset(); |
| 570 ExecuteSyncJSFunction(main_frame, "use_replace_state()"); |
| 571 screenshot_manager()->WaitUntilScreenshotIsReady(); |
| 572 // history.replaceState shouldn't capture a screenshot |
| 573 EXPECT_FALSE(screenshot_manager()->screenshot_taken_for()); |
| 574 screenshot_manager()->Reset(); |
| 575 web_contents->GetController().Reload(true); |
| 576 WaitForLoadStop(web_contents); |
| 577 // reloading the page shouldn't capture a screenshot |
| 578 EXPECT_FALSE(screenshot_manager()->screenshot_taken_for()); |
| 579 screenshot_manager()->Reset(); |
| 580 ExecuteSyncJSFunction(main_frame, "use_push_state()"); |
| 581 screenshot_manager()->WaitUntilScreenshotIsReady(); |
| 582 // pushing a state should capture a screenshot |
| 583 EXPECT_TRUE(screenshot_manager()->screenshot_taken_for()); |
| 584 } |
| 585 |
| 558 // TODO(sadrul): This test is disabled because it reparents in a way the | 586 // TODO(sadrul): This test is disabled because it reparents in a way the |
| 559 // FocusController does not support. This code would crash in | 587 // FocusController does not support. This code would crash in |
| 560 // a production build. It only passed prior to this revision | 588 // a production build. It only passed prior to this revision |
| 561 // because testing used the old FocusManager which did some | 589 // because testing used the old FocusManager which did some |
| 562 // different (osbolete) processing. TODO(sadrul) to figure out | 590 // different (osbolete) processing. TODO(sadrul) to figure out |
| 563 // how this test should work that mimics production code a bit | 591 // how this test should work that mimics production code a bit |
| 564 // better. | 592 // better. |
| 565 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, | 593 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, |
| 566 DISABLED_ContentWindowReparent) { | 594 DISABLED_ContentWindowReparent) { |
| 567 ASSERT_NO_FATAL_FAILURE( | 595 ASSERT_NO_FATAL_FAILURE( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 static_cast<WebContentsImpl*>(shell()->web_contents()); | 709 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 682 aura::Window* content = web_contents->GetNativeView()->parent(); | 710 aura::Window* content = web_contents->GetNativeView()->parent(); |
| 683 EXPECT_TRUE(web_contents->should_normally_be_visible()); | 711 EXPECT_TRUE(web_contents->should_normally_be_visible()); |
| 684 content->Hide(); | 712 content->Hide(); |
| 685 EXPECT_FALSE(web_contents->should_normally_be_visible()); | 713 EXPECT_FALSE(web_contents->should_normally_be_visible()); |
| 686 content->Show(); | 714 content->Show(); |
| 687 EXPECT_TRUE(web_contents->should_normally_be_visible()); | 715 EXPECT_TRUE(web_contents->should_normally_be_visible()); |
| 688 } | 716 } |
| 689 | 717 |
| 690 } // namespace content | 718 } // namespace content |
| OLD | NEW |