summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/app_process_apitest.cc
diff options
context:
space:
mode:
authorjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 11:31:40 +0000
committerjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 11:31:40 +0000
commit12ea9b27f4b143c59b6cb749f729025e484e7c5d (patch)
treef63cdf60d6767fa2be6c4c6cf455d3a49ba069c0 /chrome/browser/extensions/app_process_apitest.cc
parentd6aa6b6b5ee96766e099ea83a897faea2ca784af (diff)
downloadchromium_src-12ea9b27f4b143c59b6cb749f729025e484e7c5d.zip
chromium_src-12ea9b27f4b143c59b6cb749f729025e484e7c5d.tar.gz
chromium_src-12ea9b27f4b143c59b6cb749f729025e484e7c5d.tar.bz2
Fix a few test failures when landing http://trac.webkit.org/changeset/57178.
http://trac.webkit.org/changeset/57178 broke some tests in browser_test and ui_test. This patch is same as the patch in http://codereview.chromium.org/3136019/show except test RedirectTest.ClientCancelled. RedirectTest.ClientCancelled was broken on windows platform when landing the original patch. So I revert it. After digging in code, I found the root cause of why the test was broken on windows platform. Please refer to http://crbug.com/53091 for details. So I add FAILS_ prefix to RedirectTest.ClientCancelled on windows platform. BUG=17655 TEST=RedirectTest.ClientCancelled, AppApiTest.AppProcess, ExtensionBrowserTest.WindowOpenExtension, ExtensionBrowserTest.WindowOpenInvalidExtension Review URL: http://codereview.chromium.org/3186023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/app_process_apitest.cc')
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc36
1 files changed, 22 insertions, 14 deletions
diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc
index 4a0014b..2062b10 100644
--- a/chrome/browser/extensions/app_process_apitest.cc
+++ b/chrome/browser/extensions/app_process_apitest.cc
@@ -4,6 +4,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_process_manager.h"
@@ -19,7 +20,9 @@ class AppApiTest : public ExtensionApiTest {
// Simulates a page calling window.open on an URL, and waits for the navigation.
static void WindowOpenHelper(Browser* browser,
- RenderViewHost* opener_host, const GURL& url) {
+ RenderViewHost* opener_host,
+ const GURL& url,
+ bool newtab_process_should_equal_opener) {
bool result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
opener_host, L"",
@@ -28,12 +31,21 @@ static void WindowOpenHelper(Browser* browser,
&result);
ASSERT_TRUE(result);
- // Now the current tab should be the new tab.
- TabContents* newtab = browser->GetSelectedTabContents();
+ // The above window.open call is not user-initiated, it will create
+ // a popup window instead of a new tab in current window.
+ // Now the active tab in last active window should be the new tab.
+ Browser* last_active_browser = BrowserList::GetLastActive();
+ EXPECT_TRUE(last_active_browser);
+ TabContents* newtab = last_active_browser->GetSelectedTabContents();
+ EXPECT_TRUE(newtab);
if (!newtab->controller().GetLastCommittedEntry() ||
newtab->controller().GetLastCommittedEntry()->url() != url)
ui_test_utils::WaitForNavigation(&newtab->controller());
EXPECT_EQ(url, newtab->controller().GetLastCommittedEntry()->url());
+ if (newtab_process_should_equal_opener)
+ EXPECT_EQ(opener_host->process(), newtab->render_view_host()->process());
+ else
+ EXPECT_NE(opener_host->process(), newtab->render_view_host()->process());
}
// Simulates a page navigating itself to an URL, and waits for the navigation.
@@ -55,6 +67,9 @@ static void NavigateTabHelper(TabContents* contents, const GURL& url) {
}
IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kDisablePopupBlocking);
+
host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(test_server()->Start());
@@ -82,20 +97,13 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) {
browser()->GetTabContentsAt(3)->render_view_host()->process());
// Now let's do the same using window.open. The same should happen.
+ ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile()));
WindowOpenHelper(browser(), host,
- base_url.Resolve("path1/empty.html"));
+ base_url.Resolve("path1/empty.html"), true);
WindowOpenHelper(browser(), host,
- base_url.Resolve("path2/empty.html"));
+ base_url.Resolve("path2/empty.html"), true);
WindowOpenHelper(browser(), host,
- base_url.Resolve("path3/empty.html"));
-
- ASSERT_EQ(7, browser()->tab_count());
- EXPECT_EQ(host->process(),
- browser()->GetTabContentsAt(4)->render_view_host()->process());
- EXPECT_EQ(host->process(),
- browser()->GetTabContentsAt(5)->render_view_host()->process());
- EXPECT_NE(host->process(),
- browser()->GetTabContentsAt(6)->render_view_host()->process());
+ base_url.Resolve("path3/empty.html"), false);
// Now let's have these pages navigate, into or out of the extension web
// extent. They should switch processes.