diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/extensions/app_process_apitest.cc | 36 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_browsertests_misc.cc | 7 | ||||
-rw-r--r-- | chrome/browser/history/redirect_uitest.cc | 27 |
3 files changed, 52 insertions, 18 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) diff --git a/chrome/browser/history/redirect_uitest.cc b/chrome/browser/history/redirect_uitest.cc index 7e3ac11..4be6025 100644 --- a/chrome/browser/history/redirect_uitest.cc +++ b/chrome/browser/history/redirect_uitest.cc @@ -13,10 +13,14 @@ #include "base/string_util.h" #include "base/string16.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/view_ids.h" +#include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" #include "net/base/net_util.h" #include "net/test/test_server.h" +#include "views/event.h" namespace { @@ -105,6 +109,8 @@ TEST_F(RedirectTest, ClientEmptyReferer) { // Tests to make sure a location change when a pending redirect exists isn't // flagged as a redirect. +#if defined(OS_WIN) || defined(OS_LINUX) +// SimulateOSClick is broken on the Mac: http://crbug.com/45162 TEST_F(RedirectTest, ClientCancelled) { FilePath first_path(test_data_directory_); first_path = first_path.AppendASCII("cancelled_redirect_test.html"); @@ -113,10 +119,26 @@ TEST_F(RedirectTest, ClientCancelled) { NavigateToURLBlockUntilNavigationsComplete(first_url, 1); - NavigateToURL(GURL("javascript:click()")); // User initiated location change. - + scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); + ASSERT_TRUE(browser.get()); + scoped_refptr<WindowProxy> window = browser->GetWindow(); + ASSERT_TRUE(window.get()); scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); ASSERT_TRUE(tab_proxy.get()); + int64 last_nav_time = 0; + EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&last_nav_time)); + // Simulate a click to force to make a user-initiated location change; + // otherwise, a non user-initiated in-page location change will be treated + // as client redirect and the redirect will be recoreded, which can cause + // this test failed. + gfx::Rect tab_view_bounds; + ASSERT_TRUE(browser->BringToFront()); + ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, + true)); + ASSERT_TRUE( + window->SimulateOSClick(tab_view_bounds.CenterPoint(), + views::Event::EF_LEFT_BUTTON_DOWN)); + EXPECT_TRUE(tab_proxy->WaitForNavigation(last_nav_time)); std::vector<GURL> redirects; ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); @@ -140,6 +162,7 @@ TEST_F(RedirectTest, ClientCancelled) { StringToLowerASCII(current_path.value())); EXPECT_EQ(final_ref, current_url.ref()); } +#endif // Tests a client->server->server redirect TEST_F(RedirectTest, ClientServerServer) { |