OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/frame_host/interstitial_page_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
12 #include "content/common/clipboard_messages.h" | 12 #include "content/common/clipboard_messages.h" |
13 #include "content/common/frame_messages.h" | 13 #include "content/common/frame_messages.h" |
14 #include "content/public/browser/browser_message_filter.h" | 14 #include "content/public/browser/browser_message_filter.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/interstitial_page_delegate.h" | 16 #include "content/public/browser/interstitial_page_delegate.h" |
| 17 #include "content/public/common/browser_side_navigation_policy.h" |
17 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
18 #include "content/public/test/content_browser_test.h" | 19 #include "content/public/test/content_browser_test.h" |
| 20 #include "content/public/test/content_browser_test_utils.h" |
19 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
20 #include "content/shell/browser/shell.h" | 22 #include "content/shell/browser/shell.h" |
21 #include "ipc/message_filter.h" | 23 #include "ipc/message_filter.h" |
22 | 24 |
23 namespace content { | 25 namespace content { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 class TestInterstitialPageDelegate : public InterstitialPageDelegate { | 29 class TestInterstitialPageDelegate : public InterstitialPageDelegate { |
28 private: | 30 private: |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 EXPECT_EQ(std::string(), input_text); | 308 EXPECT_EQ(std::string(), input_text); |
307 | 309 |
308 PerformSelectAll(); | 310 PerformSelectAll(); |
309 | 311 |
310 ASSERT_TRUE(GetSelection(&input_text)); | 312 ASSERT_TRUE(GetSelection(&input_text)); |
311 EXPECT_EQ("original body text", input_text); | 313 EXPECT_EQ("original body text", input_text); |
312 | 314 |
313 TearDownInterstitialPage(); | 315 TearDownInterstitialPage(); |
314 } | 316 } |
315 | 317 |
| 318 // Ensure that we don't show the underlying RenderWidgetHostView if a subframe |
| 319 // commits in the original page while an interstitial is showing. |
| 320 // See https://crbug.com/729105. |
| 321 IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, UnderlyingSubframeCommit) { |
| 322 // This test doesn't apply in PlzNavigate, since the subframe does not |
| 323 // succesfully commit in that mode. |
| 324 // TODO(creis, clamy): Determine if this is a bug that should be fixed. |
| 325 if (IsBrowserSideNavigationEnabled()) |
| 326 return; |
| 327 |
| 328 ASSERT_TRUE(embedded_test_server()->Start()); |
| 329 |
| 330 // Load an initial page and inject an iframe that won't commit yet. |
| 331 WebContentsImpl* web_contents = |
| 332 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 333 GURL main_url(embedded_test_server()->GetURL("/title1.html")); |
| 334 GURL slow_url(embedded_test_server()->GetURL("/title2.html")); |
| 335 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 336 TestNavigationManager subframe_delayer(web_contents, slow_url); |
| 337 { |
| 338 std::string script = |
| 339 "var iframe = document.createElement('iframe');" |
| 340 "iframe.src = '" + |
| 341 slow_url.spec() + |
| 342 "';" |
| 343 "document.body.appendChild(iframe);"; |
| 344 EXPECT_TRUE(ExecuteScript(web_contents->GetMainFrame(), script)); |
| 345 } |
| 346 EXPECT_TRUE(subframe_delayer.WaitForRequestStart()); |
| 347 |
| 348 // Show an interstitial. The underlying RenderWidgetHostView should not be |
| 349 // showing. |
| 350 SetUpInterstitialPage(); |
| 351 EXPECT_FALSE(web_contents->GetMainFrame()->GetView()->IsShowing()); |
| 352 EXPECT_TRUE(web_contents->GetMainFrame()->GetRenderWidgetHost()->is_hidden()); |
| 353 |
| 354 // Allow the subframe to commit. |
| 355 subframe_delayer.WaitForNavigationFinished(); |
| 356 |
| 357 // The underlying RenderWidgetHostView should still not be showing. |
| 358 EXPECT_FALSE(web_contents->GetMainFrame()->GetView()->IsShowing()); |
| 359 EXPECT_TRUE(web_contents->GetMainFrame()->GetRenderWidgetHost()->is_hidden()); |
| 360 |
| 361 TearDownInterstitialPage(); |
| 362 } |
| 363 |
316 } // namespace content | 364 } // namespace content |
OLD | NEW |