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

Side by Side Diff: content/browser/renderer_host/render_view_host_manager_browsertest.cc

Issue 10952035: Don't let swappedout:// page be visible when updating frame tree. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments Created 8 years, 3 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 | « no previous file | content/browser/web_contents/render_view_host_manager.cc » ('j') | 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/json/json_reader.h" 6 #include "base/json/json_reader.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/common/content_constants_internal.h" 10 #include "content/common/content_constants_internal.h"
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 EXPECT_EQ(subtree->GetSize(), 3U); 1291 EXPECT_EQ(subtree->GetSize(), 3U);
1292 1292
1293 EXPECT_TRUE(CompareTrees( 1293 EXPECT_TRUE(CompareTrees(
1294 GetTree(opener_rvhm->current_host()), 1294 GetTree(opener_rvhm->current_host()),
1295 GetTree(opener_rvhm->GetSwappedOutRenderViewHost(site_instance1)))); 1295 GetTree(opener_rvhm->GetSwappedOutRenderViewHost(site_instance1))));
1296 EXPECT_TRUE(CompareTrees( 1296 EXPECT_TRUE(CompareTrees(
1297 GetTree(opener_rvhm->current_host()), 1297 GetTree(opener_rvhm->current_host()),
1298 GetTree(opener_rvhm->GetSwappedOutRenderViewHost(site_instance2)))); 1298 GetTree(opener_rvhm->GetSwappedOutRenderViewHost(site_instance2))));
1299 } 1299 }
1300 1300
1301 // Test for crbug.com/143155. Frame tree updates during unload should not
1302 // interrupt the intended navigation and show swappedout:// instead.
1303 // Specifically:
1304 // 1) Open 2 tabs in an HTTP SiteInstance, with a subframe in the opener.
1305 // 2) Send the second tab to a different HTTPS SiteInstance.
1306 // This creates a swapped out opener for the first tab in the HTTPS process.
1307 // 3) Navigate the first tab to the HTTPS SiteInstance, and have the first
1308 // tab's unload handler remove its frame.
1309 // This used to cause an update to the frame tree of the swapped out RV,
1310 // just as it was navigating to a real page. That pre-empted the real
1311 // navigation and visibly sent the tab to swappedout://.
1312 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
1313 DontPreemptNavigationWithFrameTreeUpdate) {
1314 // Start two servers with different sites.
1315 ASSERT_TRUE(test_server()->Start());
1316 net::TestServer https_server(
1317 net::TestServer::TYPE_HTTPS,
1318 net::TestServer::kLocalhost,
1319 FilePath(FILE_PATH_LITERAL("content/test/data")));
1320 ASSERT_TRUE(https_server.Start());
1321
1322 // 1. Load a page that deletes its iframe during unload.
1323 NavigateToURL(shell(),
1324 test_server()->GetURL("files/remove_frame_on_unload.html"));
1325
1326 // Get the original SiteInstance for later comparison.
1327 scoped_refptr<SiteInstance> orig_site_instance(
1328 shell()->web_contents()->GetSiteInstance());
1329
1330 // Open a same-site page in a new window.
1331 ShellAddedObserver new_shell_observer;
1332 bool success = false;
1333 EXPECT_TRUE(ExecuteJavaScriptAndExtractBool(
1334 shell()->web_contents()->GetRenderViewHost(), L"",
1335 L"window.domAutomationController.send(openWindow());",
1336 &success));
1337 EXPECT_TRUE(success);
1338 Shell* new_shell = new_shell_observer.GetShell();
1339
1340 // Wait for the navigation in the new window to finish, if it hasn't.
1341 WaitForLoadStop(new_shell->web_contents());
1342 EXPECT_EQ("/files/title1.html",
1343 new_shell->web_contents()->GetURL().path());
1344
1345 // Should have the same SiteInstance.
1346 EXPECT_EQ(orig_site_instance, new_shell->web_contents()->GetSiteInstance());
1347
1348 // 2. Send the second tab to a different process.
1349 NavigateToURL(new_shell, https_server.GetURL("files/title1.html"));
1350 scoped_refptr<SiteInstance> new_site_instance(
1351 new_shell->web_contents()->GetSiteInstance());
1352 EXPECT_NE(orig_site_instance, new_site_instance);
1353
1354 // 3. Send the first tab to the second tab's process.
1355 NavigateToURL(shell(), https_server.GetURL("files/title1.html"));
1356
1357 // Make sure it ends up at the right page.
1358 WaitForLoadStop(shell()->web_contents());
1359 EXPECT_EQ(https_server.GetURL("files/title1.html"),
1360 shell()->web_contents()->GetURL());
1361 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance());
1362 }
1363
1301 } // namespace content 1364 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/render_view_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698