summaryrefslogtreecommitdiffstats
path: root/chrome/browser/unload_uitest.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 21:19:27 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 21:19:27 +0000
commit35f7d2144b8aae4bdc1509961738e6bf71d6021c (patch)
tree2b5a7ba48e9e86084f96d8ad4a809f6733257d41 /chrome/browser/unload_uitest.cc
parentf3089a667ef63143572a19a0ade9644d38cd3757 (diff)
downloadchromium_src-35f7d2144b8aae4bdc1509961738e6bf71d6021c.zip
chromium_src-35f7d2144b8aae4bdc1509961738e6bf71d6021c.tar.gz
chromium_src-35f7d2144b8aae4bdc1509961738e6bf71d6021c.tar.bz2
Second attempt at cleaning up handling of --disable-popup-blocking. I didn't realize that now window.open() will result in a popup with this flag, where before it resulted in a tab. This necessitated changes to a test that expected one window and two tabs to expect two windows each with one tab.
I also fixed the test to not crash when some expectations were not met (by using ASSERT_ instead of EXPECT_), and to properly use (expected, actual) instead of (actual, expected). Review URL: http://codereview.chromium.org/99203 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/unload_uitest.cc')
-rw-r--r--chrome/browser/unload_uitest.cc49
1 files changed, 30 insertions, 19 deletions
diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc
index 61b8ec1..e4401f7 100644
--- a/chrome/browser/unload_uitest.cc
+++ b/chrome/browser/unload_uitest.cc
@@ -74,7 +74,7 @@ const std::string TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML =
const std::string CLOSE_TAB_WHEN_OTHER_TAB_HAS_LISTENER =
"<html><head><title>only_one_unload</title></head>"
- "<body onload=\"window.open('data:text/html,<html><head><title>second_tab</title></head></body>')\" "
+ "<body onload=\"window.open('data:text/html,<html><head><title>popup</title></head></body>')\" "
"onbeforeunload='return;'"
"</body></html>";
@@ -337,24 +337,35 @@ TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) {
// unload handler, and the other doesn't, the tab that doesn't have an unload
// handler can be closed. If this test fails, the Close() call will hang.
TEST_F(UnloadTest, BrowserCloseTabWhenOtherTabHasListener) {
- NavigateToDataURL(CLOSE_TAB_WHEN_OTHER_TAB_HAS_LISTENER, L"second_tab");
-
- scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
-
- int tab_count;
- EXPECT_TRUE(browser_proxy->GetTabCount(&tab_count));
- EXPECT_EQ(tab_count, 2);
-
- scoped_ptr<TabProxy> second_tab(browser_proxy->GetActiveTab());
- EXPECT_TRUE(second_tab.get()!= NULL);
- EXPECT_TRUE(second_tab->Close(true));
-
- scoped_ptr<TabProxy> first_tab(browser_proxy->GetActiveTab());
- std::wstring title;
- EXPECT_TRUE(first_tab.get() != NULL);
- EXPECT_TRUE(first_tab->GetTabTitle(&title));
- EXPECT_EQ(title, L"only_one_unload");
+ NavigateToDataURL(CLOSE_TAB_WHEN_OTHER_TAB_HAS_LISTENER, L"only_one_unload");
+ int window_count;
+ automation()->GetBrowserWindowCount(&window_count);
+ ASSERT_EQ(2, window_count);
+
+ scoped_ptr<BrowserProxy> popup_browser_proxy(
+ automation()->GetBrowserWindow(1));
+ ASSERT_TRUE(popup_browser_proxy.get());
+ int popup_tab_count;
+ EXPECT_TRUE(popup_browser_proxy->GetTabCount(&popup_tab_count));
+ EXPECT_EQ(1, popup_tab_count);
+ scoped_ptr<TabProxy> popup_tab(popup_browser_proxy->GetActiveTab());
+ std::wstring popup_title;
+ ASSERT_TRUE(popup_tab.get() != NULL);
+ EXPECT_TRUE(popup_tab->GetTabTitle(&popup_title));
+ EXPECT_EQ(std::wstring(L"popup"), popup_title);
+ EXPECT_TRUE(popup_tab->Close(true));
+
+ scoped_ptr<BrowserProxy> main_browser_proxy(
+ automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(main_browser_proxy.get());
+ int main_tab_count;
+ EXPECT_TRUE(main_browser_proxy->GetTabCount(&main_tab_count));
+ EXPECT_EQ(1, main_tab_count);
+ scoped_ptr<TabProxy> main_tab(main_browser_proxy->GetActiveTab());
+ std::wstring main_title;
+ ASSERT_TRUE(main_tab.get() != NULL);
+ EXPECT_TRUE(main_tab->GetTabTitle(&main_title));
+ EXPECT_EQ(std::wstring(L"only_one_unload"), main_title);
}
// TODO(ojan): Add tests for unload/beforeunload that have multiple tabs