diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-26 01:10:30 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-26 01:10:30 +0000 |
commit | 4fe437b31b141afa9a0c44d58ffe8b138028efd7 (patch) | |
tree | af45d8e43ad298e3d951a01bd20c1a4c5c4e8da9 /chrome/worker/worker_uitest.cc | |
parent | 5b207166bf9869e901a0cb10655617965ee37883 (diff) | |
download | chromium_src-4fe437b31b141afa9a0c44d58ffe8b138028efd7.zip chromium_src-4fe437b31b141afa9a0c44d58ffe8b138028efd7.tar.gz chromium_src-4fe437b31b141afa9a0c44d58ffe8b138028efd7.tar.bz2 |
Changed shared worker code so incognito windows do not have access to non-incognito shared workers.
BUG=27883
TEST=added new uitest
Review URL: http://codereview.chromium.org/441022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker/worker_uitest.cc')
-rw-r--r-- | chrome/worker/worker_uitest.cc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc index 93ceca2..d2a8309 100644 --- a/chrome/worker/worker_uitest.cc +++ b/chrome/worker/worker_uitest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/string_util.h" +#include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/worker_host/worker_service.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/automation/browser_proxy.h" @@ -28,6 +29,30 @@ class WorkerTest : public UILayoutTest { ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); } + void RunIncognitoTest(const std::wstring& test_case) { + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + // Open an Incognito window. + int window_count; + ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); + scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1)); + scoped_refptr<TabProxy> tab(incognito->GetTab(0)); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + ASSERT_EQ(2, window_count); + + GURL url = GetTestUrl(L"workers", test_case); + ASSERT_TRUE(tab->NavigateToURL(url)); + + std::string value = WaitUntilCookieNonEmpty(tab.get(), url, + kTestCompleteCookie, kTestIntervalMs, kTestWaitTimeoutMs); + + // Close the incognito window + ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + ASSERT_EQ(1, window_count); + + ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); + } + bool WaitForProcessCountToBe(int tabs, int workers) { // The 1 is for the browser process. int number_of_processes = 1 + workers + @@ -65,6 +90,14 @@ TEST_F(WorkerTest, MultipleWorkers) { RunTest(L"multi_worker.html"); } +// Incognito windows should not share workers with non-incognito windows +TEST_F(WorkerTest, IncognitoSharedWorkers) { + // Load a non-incognito tab and have it create a shared worker + RunTest(L"incognito_worker.html"); + // Incognito worker should not share with non-incognito + RunIncognitoTest(L"incognito_worker.html"); +} + #if defined(OS_LINUX) || defined (OS_MACOSX) #define WorkerFastLayoutTests DISABLED_WorkerFastLayoutTests #endif @@ -165,8 +198,14 @@ TEST_F(WorkerTest, SharedWorkerFastLayoutTests) { resource_dir = resource_dir.AppendASCII("resources"); AddResourceForLayoutTest(js_dir, resource_dir); - for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) + for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) { RunLayoutTest(kLayoutTestFiles[i], false); + // Shared workers will error out if we ever have more than one tab open. + int window_count = 0; + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + ASSERT_EQ(1, window_count); + EXPECT_EQ(1, GetTabCount()); + } } TEST_F(WorkerTest, WorkerHttpLayoutTests) { |