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

Unified Diff: chrome/browser/views/constrained_window_impl_interactive_uitest.cc

Issue 7388: Remove throttling code from the Browser process and... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents.cc ('k') | chrome/browser/web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/constrained_window_impl_interactive_uitest.cc
===================================================================
--- chrome/browser/views/constrained_window_impl_interactive_uitest.cc (revision 3394)
+++ chrome/browser/views/constrained_window_impl_interactive_uitest.cc (working copy)
@@ -143,3 +143,58 @@
EXPECT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count));
EXPECT_EQ(browser_window_count, 1);
}
+
+// Tests that in the window.open() equivalent of a fork bomb, we stop building
+// windows.
+TEST_F(InteractiveConstrainedWindowTest, DontSpawnEndlessPopups) {
+ scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+
+ scoped_ptr<WindowProxy> window(
+ automation()->GetWindowForBrowser(browser.get()));
+ ASSERT_TRUE(window.get());
+
+ scoped_ptr<TabProxy> tab(browser->GetTab(0));
+ ASSERT_TRUE(tab.get());
+
+ std::wstring filename(test_data_directory_);
+ file_util::AppendToPath(&filename, L"constrained_files");
+ file_util::AppendToPath(&filename,
+ L"infinite_popups.html");
+ ASSERT_TRUE(tab->NavigateToURL(net::FilePathToFileURL(filename)));
+
+ gfx::Rect tab_view_bounds;
+ ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER,
+ &tab_view_bounds, true));
+
+ // Simulate a click of the actual link to force user_gesture to be
+ // true; if we don't, the resulting popup will be constrained, which
+ // isn't what we want to test.
+ POINT link_point(tab_view_bounds.CenterPoint().ToPOINT());
+ ASSERT_TRUE(window->SimulateOSClick(link_point,
+ ChromeViews::Event::EF_LEFT_BUTTON_DOWN));
+
+ ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));
+
+ scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
+ ASSERT_TRUE(popup_browser.get());
+ scoped_ptr<TabProxy> popup_tab(popup_browser->GetTab(0));
+ ASSERT_TRUE(popup_tab.get());
+
+ // And now we spin on this, waiting to make sure that we don't spawn popup
+ // windows endlessly. The current limit is 25, so allowing for possible race
+ // conditions and one off errors, don't break out until we go over 35 popup
+ // windows (in which case we are bork bork bork).
+ const int kMaxPopupWindows = 35;
+ int constrained_window_count = 0;
+ int new_constrained_window_count;
+ bool continuing = true;
+ while (continuing && constrained_window_count < kMaxPopupWindows) {
+ continuing = popup_tab->WaitForChildWindowCountToChange(
+ constrained_window_count, &new_constrained_window_count,
+ 100000);
+ EXPECT_GE(new_constrained_window_count, constrained_window_count);
+ EXPECT_LE(new_constrained_window_count, kMaxPopupWindows);
+ constrained_window_count = new_constrained_window_count;
+ }
+}
« no previous file with comments | « chrome/browser/tab_contents.cc ('k') | chrome/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698