diff options
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | content/browser/in_process_webkit/dom_storage_browsertest.cc | 165 | ||||
-rw-r--r-- | content/browser/in_process_webkit/dom_storage_uitest.cc | 222 | ||||
-rw-r--r-- | content/test/data/layout_tests/clear_dom_storage.html | 7 |
4 files changed, 166 insertions, 230 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 573b005..1966bc9 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -836,7 +836,6 @@ 'test/ui/named_interface_uitest.cc', 'test/ui/npapi_uitest.cc', 'test/ui/sandbox_uitests.cc', - '../content/browser/in_process_webkit/dom_storage_uitest.cc', '../content/browser/renderer_host/resource_dispatcher_host_uitest.cc', # DON'T ADD NEW FILES! SEE NOTE AT TOP OF SECTION. ], @@ -2963,6 +2962,7 @@ '../content/browser/device_orientation/device_orientation_browsertest.cc', '../content/browser/download/mhtml_generation_browsertest.cc', '../content/browser/fileapi/file_system_browsertest.cc', + '../content/browser/in_process_webkit/dom_storage_browsertest.cc', '../content/browser/in_process_webkit/indexed_db_browsertest.cc', '../content/browser/in_process_webkit/indexed_db_layout_browsertest.cc', '../content/browser/indexed_db/idbbindingutilities_browsertest.cc', diff --git a/content/browser/in_process_webkit/dom_storage_browsertest.cc b/content/browser/in_process_webkit/dom_storage_browsertest.cc new file mode 100644 index 0000000..7e19035 --- /dev/null +++ b/content/browser/in_process_webkit/dom_storage_browsertest.cc @@ -0,0 +1,165 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/test/base/ui_test_utils.h" +#include "content/browser/renderer_host/render_view_host_impl.h" +#include "content/browser/tab_contents/tab_contents.h" +#include "content/public/common/content_switches.h" +#include "content/test/layout_browsertest.h" +#include "webkit/dom_storage/dom_storage_types.h" + +#ifdef ENABLE_NEW_DOM_STORAGE_BACKEND +// TODO(michaeln) Ensure they pass. +#else +static const char* kRootFiles[] = { + "clear.html", +// "complex-keys.html", // Output too big for a cookie. crbug.com/33472 +// "complex-values.html", // crbug.com/33472 + "quota.html", + "remove-item.html", + "window-attributes-exist.html", + NULL +}; + +static const char* kEventsFiles[] = { +// "basic-body-attribute.html", // crbug.com/33472 +// "basic.html", // crbug.com/33472 +// "basic-setattribute.html", // crbug.com/33472 + "case-sensitive.html", + "documentURI.html", + NULL +}; + +static const char* kStorageFiles[] = { + "delete-removal.html", + "enumerate-storage.html", + "enumerate-with-length-and-key.html", + "index-get-and-set.html", + "simple-usage.html", + "string-conversion.html", +// "window-open.html", // TODO(jorlow): Fix + NULL +}; + +class DOMStorageTestBase : public InProcessBrowserLayoutTest { + protected: + DOMStorageTestBase(const FilePath& test_case_dir) + : InProcessBrowserLayoutTest(FilePath(), test_case_dir) { + } + + virtual ~DOMStorageTestBase() {} + + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + command_line->AppendSwitch(switches::kDisablePopupBlocking); + } + + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { + InProcessBrowserLayoutTest::SetUpInProcessBrowserTestFixture(); + AddResourceForLayoutTest( + FilePath().AppendASCII("fast").AppendASCII("js"), + FilePath().AppendASCII("resources")); + } + + // This is somewhat of a hack because we're running a real browser that + // actually persists the LocalStorage state vs. DRT and TestShell which don't. + // The correct fix is to fix the LayoutTests, but similar patches have been + // rejected in the past. + void ClearDOMStorage() { + ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( + browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", + L"localStorage.clear();sessionStorage.clear();")); + } + + // Runs each test in an array of strings until it hits a NULL. + void RunTests(const char** files) { + while (*files) { + RunLayoutTest(*files); + ClearDOMStorage(); + ++files; + } + } + + FilePath test_dir_; +}; + +class DOMStorageTest : public DOMStorageTestBase { + public: + DOMStorageTest() + : DOMStorageTestBase(FilePath().AppendASCII("storage"). + AppendASCII("domstorage")) { + } + virtual ~DOMStorageTest() {} +}; + + +// http://crbug.com/113611 +IN_PROC_BROWSER_TEST_F(DOMStorageTest, FAILS_RootLayoutTests) { + AddResourceForLayoutTest(FilePath(), FilePath().AppendASCII("script-tests")); + RunTests(kRootFiles); +} + +class DOMStorageTestEvents : public DOMStorageTestBase { + public: + DOMStorageTestEvents() + : DOMStorageTestBase(FilePath().AppendASCII("storage"). + AppendASCII("domstorage"). + AppendASCII("events")) { + } + virtual ~DOMStorageTestEvents() {} +}; + +// Flakily fails on all platforms. http://crbug.com/102641 +IN_PROC_BROWSER_TEST_F(DOMStorageTestEvents, DISABLED_EventLayoutTests) { + AddResourceForLayoutTest( + FilePath(), + FilePath().AppendASCII("storage").AppendASCII("domstorage"). + AppendASCII("script-tests")); + RunTests(kEventsFiles); +} + +class LocalStorageTest : public DOMStorageTestBase { + public: + LocalStorageTest() + : DOMStorageTestBase(FilePath().AppendASCII("storage"). + AppendASCII("domstorage"). + AppendASCII("localstorage")) { + } + virtual ~LocalStorageTest() {} +}; + +#if defined(OS_LINUX) +// http://crbug.com/104872 +#define MAYBE_LocalStorageLayoutTests FAILS_LocalStorageLayoutTests +#else +#define MAYBE_LocalStorageLayoutTests LocalStorageLayoutTests +#endif + +IN_PROC_BROWSER_TEST_F(LocalStorageTest, MAYBE_LocalStorageLayoutTests) { + RunTests(kStorageFiles); +} + +class SessionStorageTest : public DOMStorageTestBase { + public: + SessionStorageTest() + : DOMStorageTestBase(FilePath().AppendASCII("storage"). + AppendASCII("domstorage"). + AppendASCII("sessionstorage")) { + } + virtual ~SessionStorageTest() {} +}; + +#if defined(OS_LINUX) +// http://crbug.com/104872 +#define MAYBE_SessionStorageLayoutTests FAILS_SessionStorageLayoutTests +#else +#define MAYBE_SessionStorageLayoutTests SessionStorageLayoutTests +#endif + +IN_PROC_BROWSER_TEST_F(SessionStorageTest, MAYBE_SessionStorageLayoutTests) { + RunTests(kStorageFiles); +} + +#endif // ENABLE_NEW_DOM_STORAGE_BACKEND diff --git a/content/browser/in_process_webkit/dom_storage_uitest.cc b/content/browser/in_process_webkit/dom_storage_uitest.cc deleted file mode 100644 index aac6796..0000000 --- a/content/browser/in_process_webkit/dom_storage_uitest.cc +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/path_service.h" -#include "base/test/test_timeouts.h" -#include "chrome/test/automation/tab_proxy.h" -#include "chrome/test/ui/ui_layout_test.h" -#include "content/public/common/content_paths.h" -#include "content/public/common/content_switches.h" -#include "net/base/net_util.h" -#include "webkit/dom_storage/dom_storage_types.h" - -#ifdef ENABLE_NEW_DOM_STORAGE_BACKEND -// No longer applicable. -#else - -static const char* kRootFiles[] = { - "clear.html", -// "complex-keys.html", // Output too big for a cookie. crbug.com/33472 -// "complex-values.html", // crbug.com/33472 - "quota.html", - "remove-item.html", - "window-attributes-exist.html", - NULL -}; - -static const char* kEventsFiles[] = { -// "basic-body-attribute.html", // crbug.com/33472 -// "basic.html", // crbug.com/33472 -// "basic-setattribute.html", // crbug.com/33472 - "case-sensitive.html", - "documentURI.html", - NULL -}; - -static const char* kStorageFiles[] = { - "delete-removal.html", - "enumerate-storage.html", - "enumerate-with-length-and-key.html", - "index-get-and-set.html", - "simple-usage.html", - "string-conversion.html", -// "window-open.html", // TODO(jorlow): Fix - NULL -}; - -class DOMStorageTest : public UILayoutTest { - protected: - DOMStorageTest() - : UILayoutTest(), - test_dir_(FilePath(). - AppendASCII("storage").AppendASCII("domstorage")) { - } - - virtual ~DOMStorageTest() { } - - virtual void SetUp() { - launch_arguments_.AppendSwitch(switches::kDisablePopupBlocking); - UILayoutTest::SetUp(); - } - - // We require fast/js/resources for most of the DOM Storage layout tests. - // Add those to the list to be copied. - void AddJSTestResources() { - // Add other paths our tests require. - FilePath js_dir = FilePath(). - AppendASCII("fast").AppendASCII("js"); - AddResourceForLayoutTest(js_dir, FilePath().AppendASCII("resources")); - } - - // This is somewhat of a hack because we're running a real browser that - // actually persists the LocalStorage state vs. DRT and TestShell which don't. - // The correct fix is to fix the LayoutTests, but similar patches have been - // rejected in the past. - void ClearDOMStorage() { - scoped_refptr<TabProxy> tab(GetActiveTab()); - ASSERT_TRUE(tab.get()); - - FilePath dir; - PathService::Get(content::DIR_TEST_DATA, &dir); - GURL url = net::FilePathToFileURL( - dir.AppendASCII("layout_tests").AppendASCII("clear_dom_storage.html")); - - ASSERT_TRUE(tab->SetCookie(url, "")); - ASSERT_TRUE(tab->NavigateToURL(url)); - - WaitUntilCookieNonEmpty(tab.get(), url, "cleared", - TestTimeouts::action_max_timeout_ms()); - } - - // Runs each test in an array of strings until it hits a NULL. - void RunTests(const char** files) { - while (*files) { - ClearDOMStorage(); - RunLayoutTest(*files, kNoHttpPort); - ++files; - } - } - - FilePath test_dir_; -}; - - -// http://crbug.com/113611 -TEST_F(DOMStorageTest, FAILS_RootLayoutTests) { - InitializeForLayoutTest(test_dir_, FilePath(), kNoHttpPort); - AddJSTestResources(); - AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("script-tests")); - RunTests(kRootFiles); -} - -// Flakily fails on all platforms. http://crbug.com/102641 -TEST_F(DOMStorageTest, DISABLED_EventLayoutTests) { - InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("events"), - kNoHttpPort); - AddJSTestResources(); - AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("events"). - AppendASCII("resources")); - AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("events"). - AppendASCII("script-tests")); - RunTests(kEventsFiles); -} - -#if defined(OS_LINUX) -// http://crbug.com/104872 -#define MAYBE_LocalStorageLayoutTests FAILS_LocalStorageLayoutTests -#else -#define MAYBE_LocalStorageLayoutTests LocalStorageLayoutTests -#endif - -TEST_F(DOMStorageTest, MAYBE_LocalStorageLayoutTests) { - InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage"), - kNoHttpPort); - AddJSTestResources(); - AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage"). - AppendASCII("resources")); - RunTests(kStorageFiles); -} - -#if defined(OS_LINUX) -// http://crbug.com/104872 -#define MAYBE_SessionStorageLayoutTests FAILS_SessionStorageLayoutTests -#else -#define MAYBE_SessionStorageLayoutTests SessionStorageLayoutTests -#endif - -TEST_F(DOMStorageTest, MAYBE_SessionStorageLayoutTests) { - InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage"), - kNoHttpPort); - AddJSTestResources(); - AddResourceForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage"). - AppendASCII("resources")); - RunTests(kStorageFiles); -} - -class DomStorageEmptyDatabaseTest : public UITest { - protected: - FilePath StorageDir() const { - FilePath storage_dir = user_data_dir(); - storage_dir = storage_dir.AppendASCII("Default"); - storage_dir = storage_dir.AppendASCII("Local Storage"); - return storage_dir; - } - - bool StorageDirIsEmpty() const { - FilePath storage_dir = StorageDir(); - if (!file_util::DirectoryExists(storage_dir)) - return true; - return file_util::IsDirectoryEmpty(storage_dir); - } - - GURL TestUrl() const { - FilePath test_dir = test_data_directory_; - FilePath test_file = test_dir.AppendASCII("dom_storage_empty_db.html"); - return net::FilePathToFileURL(test_file); - } -}; - -TEST_F(DomStorageEmptyDatabaseTest, EmptyDirAfterClear) { - NavigateToURL(TestUrl()); - ASSERT_TRUE(StorageDirIsEmpty()); - - NavigateToURL(GURL("javascript:set()")); - NavigateToURL(GURL("javascript:clear()")); - QuitBrowser(); - EXPECT_TRUE(StorageDirIsEmpty()); -} - -TEST_F(DomStorageEmptyDatabaseTest, EmptyDirAfterGet) { - NavigateToURL(TestUrl()); - ASSERT_TRUE(StorageDirIsEmpty()); - - NavigateToURL(GURL("javascript:get()")); - QuitBrowser(); - EXPECT_TRUE(StorageDirIsEmpty()); -} - -#if defined(OS_WIN) -// Flaky, see http://crbug.com/73776 -#define MAYBE_NonEmptyDirAfterSet DISABLED_NonEmptyDirAfterSet -#else -#define MAYBE_NonEmptyDirAfterSet NonEmptyDirAfterSet -#endif -TEST_F(DomStorageEmptyDatabaseTest, MAYBE_NonEmptyDirAfterSet) { - NavigateToURL(TestUrl()); - ASSERT_TRUE(StorageDirIsEmpty()); - - NavigateToURL(GURL("javascript:set()")); - QuitBrowser(); - EXPECT_FALSE(StorageDirIsEmpty()); - - LaunchBrowserAndServer(); - NavigateToURL(TestUrl()); - NavigateToURL(GURL("javascript:clear()")); - QuitBrowser(); - EXPECT_TRUE(StorageDirIsEmpty()); -} - -#endif // ENABLE_NEW_DOM_STORAGE_BACKEND diff --git a/content/test/data/layout_tests/clear_dom_storage.html b/content/test/data/layout_tests/clear_dom_storage.html deleted file mode 100644 index da41289..0000000 --- a/content/test/data/layout_tests/clear_dom_storage.html +++ /dev/null @@ -1,7 +0,0 @@ -<script> -if (window.localStorage) - localStorage.clear(); -if (window.sessionStorage) - sessionStorage.clear(); -document.cookie = "cleared=true"; -</script> |