summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-20 09:41:15 +0000
committerjnd@google.com <jnd@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-20 09:41:15 +0000
commit55b7aa7ec74e0d4365f3a36b486a0cf10a202060 (patch)
tree850d94f3561015ba499f39b9c1d837e0bb8d36d9 /chrome/browser/extensions
parentb55269846dd1c99ce9165c4f13f895326ea16501 (diff)
downloadchromium_src-55b7aa7ec74e0d4365f3a36b486a0cf10a202060.zip
chromium_src-55b7aa7ec74e0d4365f3a36b486a0cf10a202060.tar.gz
chromium_src-55b7aa7ec74e0d4365f3a36b486a0cf10a202060.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. In the test RedirectTest.ClientCancelled, it needs a user-initiated event to trigger the redirect, now it uses "javaScript:click()". When landing r57178, the call of window.open which is inside the call of javaScript:click() was treated as non user-initiated, so the in-page location change was treated as client redirect and the redirect was recoreded, that is why this test was failed when landing r57178. (Please refer to the logic in FrameLoaderClientImpl::dispatchDidNavigateWithinPage.) In the tests AppApiTest.AppProcess, ExtensionBrowserTest.WindowOpenExtension and ExtensionBrowserTest.WindowOpenInvalidExtension, they assume the new tabs opened by window.open in current window. But when landing r57178, since those calls of window.open were treated as non user-initiated, the disposition type of new tabs were changed to Popup, which caused a few new tabs were created instead of a few new tabs in current window (Please refer to RenderView::show), which cause those tests were failed when landing r57178.), that is why those tests were failed when landing r57178. BUG=17655 TEST=RedirectTest.ClientCancelled, AppApiTest.AppProcess, ExtensionBrowserTest.WindowOpenExtension, ExtensionBrowserTest.WindowOpenInvalidExtension Review URL: http://codereview.chromium.org/3136019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc36
-rw-r--r--chrome/browser/extensions/extension_browsertests_misc.cc7
2 files changed, 27 insertions, 16 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.
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index 4ede48d..9076447 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -614,8 +614,11 @@ static TabContents* WindowOpenHelper(Browser* browser, const GURL& start_url,
L"window.domAutomationController.send(true);", &result);
EXPECT_TRUE(result);
- // Now the current tab should be the new tab.
- TabContents* newtab = browser->GetSelectedTabContents();
+ // 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);
GURL expected_url = start_url.Resolve(newtab_url);
if (!newtab->controller().GetLastCommittedEntry() ||
newtab->controller().GetLastCommittedEntry()->url() != expected_url)