| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 8 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); | 295 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); |
| 296 }; | 296 }; |
| 297 | 297 |
| 298 // Pretends to be a normal browser that receives toggles and transitions to/from | 298 // Pretends to be a normal browser that receives toggles and transitions to/from |
| 299 // a fullscreened state. | 299 // a fullscreened state. |
| 300 class FakeFullscreenDelegate : public WebContentsDelegate { | 300 class FakeFullscreenDelegate : public WebContentsDelegate { |
| 301 public: | 301 public: |
| 302 FakeFullscreenDelegate() : fullscreened_contents_(NULL) {} | 302 FakeFullscreenDelegate() : fullscreened_contents_(NULL) {} |
| 303 ~FakeFullscreenDelegate() override {} | 303 ~FakeFullscreenDelegate() override {} |
| 304 | 304 |
| 305 void ToggleFullscreenModeForTab(WebContents* web_contents, | 305 void EnterFullscreenModeForTab(WebContents* web_contents, |
| 306 bool enter_fullscreen) override { | 306 const GURL& origin) override { |
| 307 fullscreened_contents_ = enter_fullscreen ? web_contents : NULL; | 307 fullscreened_contents_ = web_contents; |
| 308 } |
| 309 |
| 310 void ExitFullscreenModeForTab(WebContents* web_contents) override { |
| 311 fullscreened_contents_ = NULL; |
| 308 } | 312 } |
| 309 | 313 |
| 310 bool IsFullscreenForTabOrPending( | 314 bool IsFullscreenForTabOrPending( |
| 311 const WebContents* web_contents) const override { | 315 const WebContents* web_contents) const override { |
| 312 return fullscreened_contents_ && web_contents == fullscreened_contents_; | 316 return fullscreened_contents_ && web_contents == fullscreened_contents_; |
| 313 } | 317 } |
| 314 | 318 |
| 315 private: | 319 private: |
| 316 WebContents* fullscreened_contents_; | 320 WebContents* fullscreened_contents_; |
| 317 | 321 |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 const GURL url("http://www.google.com"); | 1299 const GURL url("http://www.google.com"); |
| 1296 controller().LoadURL( | 1300 controller().LoadURL( |
| 1297 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1301 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1298 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | 1302 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); |
| 1299 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1303 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
| 1300 | 1304 |
| 1301 // Toggle fullscreen mode on (as if initiated via IPC from renderer). | 1305 // Toggle fullscreen mode on (as if initiated via IPC from renderer). |
| 1302 EXPECT_FALSE(orig_rvh->IsFullscreen()); | 1306 EXPECT_FALSE(orig_rvh->IsFullscreen()); |
| 1303 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1307 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
| 1304 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1308 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
| 1305 orig_rvh->OnMessageReceived( | 1309 orig_rfh->OnMessageReceived( |
| 1306 ViewHostMsg_ToggleFullscreen(orig_rvh->GetRoutingID(), true)); | 1310 FrameHostMsg_ToggleFullscreen(orig_rfh->GetRoutingID(), true)); |
| 1307 EXPECT_TRUE(orig_rvh->IsFullscreen()); | 1311 EXPECT_TRUE(orig_rvh->IsFullscreen()); |
| 1308 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); | 1312 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); |
| 1309 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1313 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
| 1310 | 1314 |
| 1311 // Navigate to a new site. | 1315 // Navigate to a new site. |
| 1312 const GURL url2("http://www.yahoo.com"); | 1316 const GURL url2("http://www.yahoo.com"); |
| 1313 controller().LoadURL( | 1317 controller().LoadURL( |
| 1314 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1318 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1315 TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame(); | 1319 TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame(); |
| 1316 contents()->TestDidNavigate( | 1320 contents()->TestDidNavigate( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1347 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); | 1351 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); |
| 1348 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1352 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
| 1349 | 1353 |
| 1350 // Sanity-check: Confirm we're not starting out in fullscreen mode. | 1354 // Sanity-check: Confirm we're not starting out in fullscreen mode. |
| 1351 EXPECT_FALSE(orig_rvh->IsFullscreen()); | 1355 EXPECT_FALSE(orig_rvh->IsFullscreen()); |
| 1352 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1356 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
| 1353 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1357 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
| 1354 | 1358 |
| 1355 for (int i = 0; i < 2; ++i) { | 1359 for (int i = 0; i < 2; ++i) { |
| 1356 // Toggle fullscreen mode on (as if initiated via IPC from renderer). | 1360 // Toggle fullscreen mode on (as if initiated via IPC from renderer). |
| 1357 orig_rvh->OnMessageReceived( | 1361 orig_rfh->OnMessageReceived( |
| 1358 ViewHostMsg_ToggleFullscreen(orig_rvh->GetRoutingID(), true)); | 1362 FrameHostMsg_ToggleFullscreen(orig_rfh->GetRoutingID(), true)); |
| 1359 EXPECT_TRUE(orig_rvh->IsFullscreen()); | 1363 EXPECT_TRUE(orig_rvh->IsFullscreen()); |
| 1360 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); | 1364 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); |
| 1361 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1365 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
| 1362 | 1366 |
| 1363 // Navigate backward (or forward). | 1367 // Navigate backward (or forward). |
| 1364 if (i == 0) | 1368 if (i == 0) |
| 1365 controller().GoBack(); | 1369 controller().GoBack(); |
| 1366 else | 1370 else |
| 1367 controller().GoForward(); | 1371 controller().GoForward(); |
| 1368 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1372 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 const GURL url("http://www.google.com"); | 1409 const GURL url("http://www.google.com"); |
| 1406 controller().LoadURL( | 1410 controller().LoadURL( |
| 1407 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1411 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1408 contents()->TestDidNavigate( | 1412 contents()->TestDidNavigate( |
| 1409 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); | 1413 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); |
| 1410 | 1414 |
| 1411 // Toggle fullscreen mode on (as if initiated via IPC from renderer). | 1415 // Toggle fullscreen mode on (as if initiated via IPC from renderer). |
| 1412 EXPECT_FALSE(test_rvh()->IsFullscreen()); | 1416 EXPECT_FALSE(test_rvh()->IsFullscreen()); |
| 1413 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); | 1417 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); |
| 1414 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1418 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
| 1415 test_rvh()->OnMessageReceived( | 1419 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen( |
| 1416 ViewHostMsg_ToggleFullscreen(test_rvh()->GetRoutingID(), true)); | 1420 contents()->GetMainFrame()->GetRoutingID(), true)); |
| 1417 EXPECT_TRUE(test_rvh()->IsFullscreen()); | 1421 EXPECT_TRUE(test_rvh()->IsFullscreen()); |
| 1418 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); | 1422 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); |
| 1419 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); | 1423 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); |
| 1420 | 1424 |
| 1421 // Crash the renderer. | 1425 // Crash the renderer. |
| 1422 test_rvh()->OnMessageReceived( | 1426 test_rvh()->OnMessageReceived( |
| 1423 ViewHostMsg_RenderProcessGone( | 1427 ViewHostMsg_RenderProcessGone( |
| 1424 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 1428 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 1425 | 1429 |
| 1426 // Confirm fullscreen has exited. | 1430 // Confirm fullscreen has exited. |
| (...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 | 2920 |
| 2917 // Destroy the remote player. No power save blockers should remain. | 2921 // Destroy the remote player. No power save blockers should remain. |
| 2918 rfh->OnMessageReceived( | 2922 rfh->OnMessageReceived( |
| 2919 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); | 2923 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); |
| 2920 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2924 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
| 2921 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2925 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
| 2922 } | 2926 } |
| 2923 #endif | 2927 #endif |
| 2924 | 2928 |
| 2925 } // namespace content | 2929 } // namespace content |
| OLD | NEW |