diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 20:34:25 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 20:34:25 +0000 |
commit | 100a0095898381f0efb3d441a7f533ed96923042 (patch) | |
tree | e9dd922e4e4a20f2dca067e794e5b489b9bf2d2d /chrome/worker | |
parent | 6d2721fbdbddd4d35616d9b7774945a3cf42375b (diff) | |
download | chromium_src-100a0095898381f0efb3d441a7f533ed96923042.zip chromium_src-100a0095898381f0efb3d441a7f533ed96923042.tar.gz chromium_src-100a0095898381f0efb3d441a7f533ed96923042.tar.bz2 |
Refactored code to allow associating workers with multiple renderers.
SharedWorkers now gracefully handle http auth requests after their
initial window has closed.
BUG=27660
TEST=WorkerHttpAuth,SharedWorkerHttpAuth uitests
Review URL: http://codereview.chromium.org/509016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker')
-rw-r--r-- | chrome/worker/worker_uitest.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc index 204c106..3978e75 100644 --- a/chrome/worker/worker_uitest.cc +++ b/chrome/worker/worker_uitest.cc @@ -9,6 +9,7 @@ #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_layout_test.h" +#include "net/url_request/url_request_unittest.h" static const char kTestCompleteCookie[] = "status"; static const char kTestCompleteSuccess[] = "OK"; @@ -136,6 +137,15 @@ class WorkerTest : public UILayoutTest { GURL about_url(std::string("file://localhost/")); EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(about_url)); } + + bool NavigateAndWaitForAuth(TabProxy* tab, const GURL& url) { + // Pass a large number of navigations to tell the tab to block until an auth + // dialog pops up. + bool timeout = false; + tab->NavigateToURLWithTimeout(url, 100, kTestWaitTimeoutMs, &timeout); + EXPECT_FALSE(timeout); + return tab->NeedsAuth(); + } }; @@ -173,6 +183,32 @@ TEST_F(WorkerTest, IncognitoSharedWorkers) { RunIncognitoTest(L"incognito_worker.html"); } +const wchar_t kDocRoot[] = L"chrome/test/data/workers"; + +// Make sure that auth dialog is displayed from worker context. +TEST_F(WorkerTest, WorkerHttpAuth) { + scoped_refptr<HTTPTestServer> server = + HTTPTestServer::CreateServer(kDocRoot, NULL); + + ASSERT_TRUE(NULL != server.get()); + scoped_refptr<TabProxy> tab(GetActiveTab()); + GURL url = server->TestServerPage("files/worker_auth.html"); + EXPECT_TRUE(NavigateAndWaitForAuth(tab, url)); +} + +// Make sure that auth dialog is displayed from shared worker context. +TEST_F(WorkerTest, SharedWorkerHttpAuth) { + scoped_refptr<HTTPTestServer> server = + HTTPTestServer::CreateServer(kDocRoot, NULL); + ASSERT_TRUE(NULL != server.get()); + scoped_refptr<TabProxy> tab(GetActiveTab()); + EXPECT_EQ(1, GetTabCount()); + GURL url = server->TestServerPage("files/shared_worker_auth.html"); + EXPECT_TRUE(NavigateAndWaitForAuth(tab, url)); + // TODO(atwilson): Add support to automation framework to test for auth + // dialogs displayed by non-navigating tabs. +} + #if defined(OS_LINUX) // Crashes on Linux - http://crbug.com/22898 #define WorkerFastLayoutTests0 DISABLED_WorkerFastLayoutTests0 |