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

Unified Diff: chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc

Issue 8468032: Fix next_page_id_ in a NTP forced to share an existing WebUI process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to UpdateAndSendMaxPageID Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/browser_render_process_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc b/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
index e1273293c82ce30d0a98b0743cede34dd0c3c009..8894e6faceb984dccca004887896721267c42845 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
@@ -3,9 +3,12 @@
// found in the LICENSE file.
#include "chrome/browser/ui/browser.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
#include "googleurl/src/gurl.h"
class NewTabUIBrowserTest : public InProcessBrowserTest {
@@ -28,3 +31,64 @@ IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeInternalLoadsNTP) {
&empty_inner_html));
ASSERT_FALSE(empty_inner_html);
}
+
+// Ensure loading a NTP with an existing SiteInstance in a reused process
+// doesn't cause us to kill the process. See http://crbug.com/104258.
+IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, LoadNTPInExistingProcess) {
+ // Set max renderers to 1 to force running out of processes.
+ RenderProcessHost::SetMaxRendererProcessCountForTest(1);
+
+ // Start server for simple page.
+ ASSERT_TRUE(test_server()->Start());
+
+ // Load a NTP in a new tab.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ EXPECT_EQ(1,
+ browser()->GetTabContentsAt(1)->GetSiteInstance()->max_page_id());
+
+ // Navigate that tab to another site. This allows the NTP process to exit,
+ // but it keeps the NTP SiteInstance (and its max_page_id) alive in history.
+ {
+ // Wait not just for the navigation to finish, but for the NTP process to
+ // exit as well.
+ ui_test_utils::WindowedNotificationObserver process_exited_observer(
+ content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
+ content::NotificationService::AllSources());
+ browser()->OpenURL(test_server()->GetURL("files/title1.html"), GURL(),
+ CURRENT_TAB, content::PAGE_TRANSITION_TYPED);
+ process_exited_observer.Wait();
+ }
+
+ // Create and close another two NTPs to inflate the max_page_id.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ EXPECT_EQ(2,
+ browser()->GetTabContentsAt(2)->GetSiteInstance()->max_page_id());
+ browser()->CloseTab();
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ EXPECT_EQ(3,
+ browser()->GetTabContentsAt(2)->GetSiteInstance()->max_page_id());
+ browser()->CloseTab();
+
+ // Open another Web UI page in a new tab.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL(chrome::kChromeUISettingsURL), NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ EXPECT_EQ(1,
+ browser()->GetTabContentsAt(2)->GetSiteInstance()->max_page_id());
+
+ // At this point, opening another NTP will use the old SiteInstance (with a
+ // large max_page_id) in the existing Web UI process (with a small page ID).
+ // Make sure we don't confuse this as an existing navigation to an unknown
+ // entry.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ EXPECT_EQ(4,
+ browser()->GetTabContentsAt(3)->GetSiteInstance()->max_page_id());
+}
« no previous file with comments | « no previous file | content/browser/renderer_host/browser_render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698