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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" |
8 #include "content/browser/frame_host/interstitial_page_impl.h" | 8 #include "content/browser/frame_host/interstitial_page_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 const OVERRIDE { | 307 const OVERRIDE { |
308 return fullscreened_contents_ && web_contents == fullscreened_contents_; | 308 return fullscreened_contents_ && web_contents == fullscreened_contents_; |
309 } | 309 } |
310 | 310 |
311 private: | 311 private: |
312 WebContents* fullscreened_contents_; | 312 WebContents* fullscreened_contents_; |
313 | 313 |
314 DISALLOW_COPY_AND_ASSIGN(FakeFullscreenDelegate); | 314 DISALLOW_COPY_AND_ASSIGN(FakeFullscreenDelegate); |
315 }; | 315 }; |
316 | 316 |
| 317 class FakeValidationMessageDelegate : public WebContentsDelegate { |
| 318 public: |
| 319 FakeValidationMessageDelegate() |
| 320 : hide_validation_message_was_called_(false) {} |
| 321 virtual ~FakeValidationMessageDelegate() {} |
| 322 |
| 323 virtual void HideValidationMessage(WebContents* web_contents) OVERRIDE { |
| 324 hide_validation_message_was_called_ = true; |
| 325 } |
| 326 |
| 327 bool hide_validation_message_was_called() const { |
| 328 return hide_validation_message_was_called_; |
| 329 } |
| 330 |
| 331 private: |
| 332 bool hide_validation_message_was_called_; |
| 333 |
| 334 DISALLOW_COPY_AND_ASSIGN(FakeValidationMessageDelegate); |
| 335 }; |
| 336 |
317 } // namespace | 337 } // namespace |
318 | 338 |
319 // Test to make sure that title updates get stripped of whitespace. | 339 // Test to make sure that title updates get stripped of whitespace. |
320 TEST_F(WebContentsImplTest, UpdateTitle) { | 340 TEST_F(WebContentsImplTest, UpdateTitle) { |
321 NavigationControllerImpl& cont = | 341 NavigationControllerImpl& cont = |
322 static_cast<NavigationControllerImpl&>(controller()); | 342 static_cast<NavigationControllerImpl&>(controller()); |
323 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 343 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
324 InitNavigateParams( | 344 InitNavigateParams( |
325 ¶ms, 0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED); | 345 ¶ms, 0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED); |
326 | 346 |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 | 1436 |
1417 // Confirm fullscreen has exited. | 1437 // Confirm fullscreen has exited. |
1418 EXPECT_FALSE(orig_rvh->IsFullscreen()); | 1438 EXPECT_FALSE(orig_rvh->IsFullscreen()); |
1419 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1439 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
1420 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1440 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
1421 } | 1441 } |
1422 | 1442 |
1423 contents()->SetDelegate(NULL); | 1443 contents()->SetDelegate(NULL); |
1424 } | 1444 } |
1425 | 1445 |
| 1446 TEST_F(WebContentsImplTest, TerminateHidesValidationMessage) { |
| 1447 FakeValidationMessageDelegate fake_delegate; |
| 1448 contents()->SetDelegate(&fake_delegate); |
| 1449 EXPECT_FALSE(fake_delegate.hide_validation_message_was_called()); |
| 1450 |
| 1451 // Crash the renderer. |
| 1452 test_rvh()->OnMessageReceived( |
| 1453 ViewHostMsg_RenderProcessGone( |
| 1454 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 1455 |
| 1456 // Confirm HideValidationMessage was called. |
| 1457 EXPECT_TRUE(fake_delegate.hide_validation_message_was_called()); |
| 1458 |
| 1459 contents()->SetDelegate(NULL); |
| 1460 } |
| 1461 |
1426 // Tests that fullscreen is exited throughout the object hierarchy on a renderer | 1462 // Tests that fullscreen is exited throughout the object hierarchy on a renderer |
1427 // crash. | 1463 // crash. |
1428 TEST_F(WebContentsImplTest, CrashExitsFullscreen) { | 1464 TEST_F(WebContentsImplTest, CrashExitsFullscreen) { |
1429 FakeFullscreenDelegate fake_delegate; | 1465 FakeFullscreenDelegate fake_delegate; |
1430 contents()->SetDelegate(&fake_delegate); | 1466 contents()->SetDelegate(&fake_delegate); |
1431 | 1467 |
1432 // Navigate to a site. | 1468 // Navigate to a site. |
1433 const GURL url("http://www.google.com"); | 1469 const GURL url("http://www.google.com"); |
1434 controller().LoadURL( | 1470 controller().LoadURL( |
1435 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1471 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 contents->CommitPendingNavigation(); | 2743 contents->CommitPendingNavigation(); |
2708 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); | 2744 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); |
2709 EXPECT_EQ(1u, instance_webui->GetRelatedActiveContentsCount()); | 2745 EXPECT_EQ(1u, instance_webui->GetRelatedActiveContentsCount()); |
2710 | 2746 |
2711 contents.reset(); | 2747 contents.reset(); |
2712 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); | 2748 EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); |
2713 EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); | 2749 EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); |
2714 } | 2750 } |
2715 | 2751 |
2716 } // namespace content | 2752 } // namespace content |
OLD | NEW |