| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 // Now go forward directly to B3. Shouldn't be left spinning. | 1395 // Now go forward directly to B3. Shouldn't be left spinning. |
| 1396 { | 1396 { |
| 1397 TestNavigationObserver forward_nav_load_observer(shell()->web_contents()); | 1397 TestNavigationObserver forward_nav_load_observer(shell()->web_contents()); |
| 1398 shell()->web_contents()->GetController().GoToIndex(4); | 1398 shell()->web_contents()->GetController().GoToIndex(4); |
| 1399 forward_nav_load_observer.Wait(); | 1399 forward_nav_load_observer.Wait(); |
| 1400 } | 1400 } |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 // Test for http://crbug.com/130016. | |
| 1404 // Swapping out a render view should update its visiblity state. | |
| 1405 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | |
| 1406 SwappedOutViewHasCorrectVisibilityState) { | |
| 1407 // This test is invalid in when swapped out is disabled. | |
| 1408 if (SiteIsolationPolicy::IsSwappedOutStateForbidden()) | |
| 1409 return; | |
| 1410 StartEmbeddedServer(); | |
| 1411 | |
| 1412 // Load a page with links that open in a new window. | |
| 1413 NavigateToPageWithLinks(shell()); | |
| 1414 | |
| 1415 // Open a same-site link in a new widnow. | |
| 1416 ShellAddedObserver new_shell_observer; | |
| 1417 bool success = false; | |
| 1418 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 1419 shell()->web_contents(), | |
| 1420 "window.domAutomationController.send(clickSameSiteTargetedLink());", | |
| 1421 &success)); | |
| 1422 EXPECT_TRUE(success); | |
| 1423 Shell* new_shell = new_shell_observer.GetShell(); | |
| 1424 | |
| 1425 // Wait for the navigation in the new tab to finish, if it hasn't. | |
| 1426 WaitForLoadStop(new_shell->web_contents()); | |
| 1427 EXPECT_EQ("/navigate_opener.html", | |
| 1428 new_shell->web_contents()->GetLastCommittedURL().path()); | |
| 1429 | |
| 1430 RenderViewHost* rvh = new_shell->web_contents()->GetRenderViewHost(); | |
| 1431 | |
| 1432 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 1433 rvh, | |
| 1434 "window.domAutomationController.send(" | |
| 1435 " document.visibilityState == 'visible');", | |
| 1436 &success)); | |
| 1437 EXPECT_TRUE(success); | |
| 1438 | |
| 1439 // Now navigate the new window to a different site. This should swap out the | |
| 1440 // tab's existing RenderView, causing it become hidden. | |
| 1441 NavigateToURL(new_shell, | |
| 1442 embedded_test_server()->GetURL("foo.com", "/title1.html")); | |
| 1443 | |
| 1444 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 1445 rvh, | |
| 1446 "window.domAutomationController.send(" | |
| 1447 " document.visibilityState == 'hidden');", | |
| 1448 &success)); | |
| 1449 EXPECT_TRUE(success); | |
| 1450 | |
| 1451 // Going back should make the previously swapped-out view to become visible | |
| 1452 // again. | |
| 1453 { | |
| 1454 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); | |
| 1455 new_shell->web_contents()->GetController().GoBack(); | |
| 1456 back_nav_load_observer.Wait(); | |
| 1457 } | |
| 1458 | |
| 1459 EXPECT_EQ("/navigate_opener.html", | |
| 1460 new_shell->web_contents()->GetLastCommittedURL().path()); | |
| 1461 | |
| 1462 EXPECT_EQ(rvh, new_shell->web_contents()->GetRenderViewHost()); | |
| 1463 | |
| 1464 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 1465 rvh, | |
| 1466 "window.domAutomationController.send(" | |
| 1467 " document.visibilityState == 'visible');", | |
| 1468 &success)); | |
| 1469 EXPECT_TRUE(success); | |
| 1470 } | |
| 1471 | |
| 1472 // This class ensures that all the given RenderViewHosts have properly been | 1403 // This class ensures that all the given RenderViewHosts have properly been |
| 1473 // shutdown. | 1404 // shutdown. |
| 1474 class RenderViewHostDestructionObserver : public WebContentsObserver { | 1405 class RenderViewHostDestructionObserver : public WebContentsObserver { |
| 1475 public: | 1406 public: |
| 1476 explicit RenderViewHostDestructionObserver(WebContents* web_contents) | 1407 explicit RenderViewHostDestructionObserver(WebContents* web_contents) |
| 1477 : WebContentsObserver(web_contents) {} | 1408 : WebContentsObserver(web_contents) {} |
| 1478 ~RenderViewHostDestructionObserver() override {} | 1409 ~RenderViewHostDestructionObserver() override {} |
| 1479 void EnsureRVHGetsDestructed(RenderViewHost* rvh) { | 1410 void EnsureRVHGetsDestructed(RenderViewHost* rvh) { |
| 1480 watched_render_view_hosts_.insert(rvh); | 1411 watched_render_view_hosts_.insert(rvh); |
| 1481 } | 1412 } |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 web_contents->GetRenderManagerForTesting()->speculative_frame_host()); | 2407 web_contents->GetRenderManagerForTesting()->speculative_frame_host()); |
| 2477 } else { | 2408 } else { |
| 2478 EXPECT_FALSE( | 2409 EXPECT_FALSE( |
| 2479 web_contents->GetRenderManagerForTesting()->pending_frame_host()); | 2410 web_contents->GetRenderManagerForTesting()->pending_frame_host()); |
| 2480 } | 2411 } |
| 2481 | 2412 |
| 2482 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 2413 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
| 2483 } | 2414 } |
| 2484 | 2415 |
| 2485 } // namespace content | 2416 } // namespace content |
| OLD | NEW |