summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 12:23:23 +0000
committerjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 12:23:23 +0000
commit8dfdaa5482445b106448630ed7dc0bb39ce43837 (patch)
treec5ecfb1ba7031d7840d9c255dc1f4a8fbd5334bf
parent1c6fae025f3a008d7f0a14a3a8cc034a92c359ed (diff)
downloadchromium_src-8dfdaa5482445b106448630ed7dc0bb39ce43837.zip
chromium_src-8dfdaa5482445b106448630ed7dc0bb39ce43837.tar.gz
chromium_src-8dfdaa5482445b106448630ed7dc0bb39ce43837.tar.bz2
Add a browser test for popup blocker to test blank-post blocked. For the details, please refer to https://bugs.webkit.org/show_bug.cgi?id=44969.
BUG=34414 test=popup-blocked-to-post-blank Review URL: http://codereview.chromium.org/3291012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59215 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/popup_blocker_browsertest.cc44
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/test/data/popup_blocker/popup-blocked-to-post-blank.html18
3 files changed, 63 insertions, 0 deletions
diff --git a/chrome/browser/popup_blocker_browsertest.cc b/chrome/browser/popup_blocker_browsertest.cc
new file mode 100644
index 0000000..2276f5f
--- /dev/null
+++ b/chrome/browser/popup_blocker_browsertest.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/message_loop.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("popup_blocker");
+
+typedef InProcessBrowserTest PopupBlockerBrowserTest;
+
+IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupBlockedPostBlank) {
+ FilePath file_name(FILE_PATH_LITERAL("popup-blocked-to-post-blank.html"));
+ FilePath test_dir(kTestDir);
+ GURL url(ui_test_utils::GetTestUrl(test_dir, file_name));
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ // If the popup blocker blocked the blank post, there should be only one
+ // tab in only one browser window and the URL of current tab must be equal
+ // to the original URL.
+ EXPECT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile()));
+ EXPECT_EQ(1, browser()->tab_count());
+ TabContents* cur_tab = browser()->GetSelectedTabContents();
+ ASSERT_TRUE(cur_tab);
+ EXPECT_EQ(url, cur_tab->GetURL());
+}
+
+} // namespace
+
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index cde188b..e600596 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1766,6 +1766,7 @@
'browser/in_process_webkit/indexed_db_browsertest.cc',
'browser/net/cookie_policy_browsertest.cc',
'browser/net/ftp_browsertest.cc',
+ 'browser/popup_blocker_browsertest.cc',
'browser/printing/print_dialog_cloud_uitest.cc',
'browser/renderer_host/test/render_process_host_browsertest.cc',
'browser/renderer_host/test/render_view_host_manager_browsertest.cc',
diff --git a/chrome/test/data/popup_blocker/popup-blocked-to-post-blank.html b/chrome/test/data/popup_blocker/popup-blocked-to-post-blank.html
new file mode 100644
index 0000000..08c190b
--- /dev/null
+++ b/chrome/test/data/popup_blocker/popup-blocked-to-post-blank.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>Popup Blocked Post Blank</title>
+<script>
+function test() {
+ // We rely on sequential ordering of POST processing.
+ var form = document.getElementById('form');
+ form.submit();
+}
+</script>
+</head>
+<body onload="test()">
+If the POST pop-up was not blocked then there will be an warning message displayed in a new tab. Otherwise, the test passes.
+<form id="form" action="data:text/html,<title>Popup Success!</title>you should not see this message if popup blocker is enabled" target="_blank">
+<input type="submit" value="Submit to new window"/>
+</form>
+</body>
+</html> \ No newline at end of file