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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 218093002: Ensure fullscreen mode is exited for same-site navigations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | 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 "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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED); 1292 pending_rvh, 1, url2, PAGE_TRANSITION_TYPED);
1293 1293
1294 // Confirm fullscreen has exited. 1294 // Confirm fullscreen has exited.
1295 EXPECT_FALSE(orig_rvh->IsFullscreen()); 1295 EXPECT_FALSE(orig_rvh->IsFullscreen());
1296 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1296 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1297 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1297 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1298 1298
1299 contents()->SetDelegate(NULL); 1299 contents()->SetDelegate(NULL);
1300 } 1300 }
1301 1301
1302 // Tests that fullscreen is exited throughout the object hierarchy when
1303 // instructing NavigationController to GoBack() or GoForward().
1304 TEST_F(WebContentsImplTest, HistoryNavigationExitsFullscreen) {
1305 FakeFullscreenDelegate fake_delegate;
1306 contents()->SetDelegate(&fake_delegate);
1307 TestRenderViewHost* const orig_rvh = test_rvh();
1308
1309 // Navigate to a site.
1310 const GURL url("http://www.google.com");
1311 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
1312 contents()->TestDidNavigate(orig_rvh, 1, url, PAGE_TRANSITION_TYPED);
1313 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost());
1314
1315 // Now, navigate to another page on the same site.
1316 const GURL url2("http://www.google.com/search?q=kittens");
1317 controller().LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
1318 EXPECT_FALSE(contents()->cross_navigation_pending());
1319 contents()->TestDidNavigate(orig_rvh, 2, url2, PAGE_TRANSITION_TYPED);
1320 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost());
1321
1322 // Sanity-check: Confirm we're not starting out in fullscreen mode.
1323 EXPECT_FALSE(orig_rvh->IsFullscreen());
1324 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1325 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1326
1327 for (int i = 0; i < 2; ++i) {
1328 // Toggle fullscreen mode on (as if initiated via IPC from renderer).
1329 orig_rvh->OnMessageReceived(
1330 ViewHostMsg_ToggleFullscreen(orig_rvh->GetRoutingID(), true));
1331 EXPECT_TRUE(orig_rvh->IsFullscreen());
1332 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab());
1333 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1334
1335 // Navigate backward (or forward).
1336 if (i == 0)
1337 controller().GoBack();
1338 else
1339 controller().GoForward();
1340 EXPECT_FALSE(contents()->cross_navigation_pending());
1341 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost());
1342 contents()->TestDidNavigate(
1343 orig_rvh, i + 1, url, PAGE_TRANSITION_FORWARD_BACK);
1344
1345 // Confirm fullscreen has exited.
1346 EXPECT_FALSE(orig_rvh->IsFullscreen());
1347 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1348 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1349 }
1350
1351 contents()->SetDelegate(NULL);
1352 }
1353
1302 // Tests that fullscreen is exited throughout the object hierarchy on a renderer 1354 // Tests that fullscreen is exited throughout the object hierarchy on a renderer
1303 // crash. 1355 // crash.
1304 TEST_F(WebContentsImplTest, CrashExitsFullscreen) { 1356 TEST_F(WebContentsImplTest, CrashExitsFullscreen) {
1305 FakeFullscreenDelegate fake_delegate; 1357 FakeFullscreenDelegate fake_delegate;
1306 contents()->SetDelegate(&fake_delegate); 1358 contents()->SetDelegate(&fake_delegate);
1307 1359
1308 // Navigate to a site. 1360 // Navigate to a site.
1309 const GURL url("http://www.google.com"); 1361 const GURL url("http://www.google.com");
1310 controller().LoadURL( 1362 controller().LoadURL(
1311 url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 1363 url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 WebInputEvent::GesturePinchUpdate, WebGestureEvent::Touchscreen); 2526 WebInputEvent::GesturePinchUpdate, WebGestureEvent::Touchscreen);
2475 event.data.pinchUpdate.scale = kZoomStepValue * 3; 2527 event.data.pinchUpdate.scale = kZoomStepValue * 3;
2476 EXPECT_FALSE(contents()->HandleGestureEvent(event)); 2528 EXPECT_FALSE(contents()->HandleGestureEvent(event));
2477 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); 2529 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount());
2478 2530
2479 // Ensure pointers to the delegate aren't kept beyond it's lifetime. 2531 // Ensure pointers to the delegate aren't kept beyond it's lifetime.
2480 contents()->SetDelegate(NULL); 2532 contents()->SetDelegate(NULL);
2481 } 2533 }
2482 2534
2483 } // namespace content 2535 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698