| Index: content/browser/dom_storage/dom_storage_browsertest.cc
|
| ===================================================================
|
| --- content/browser/dom_storage/dom_storage_browsertest.cc (revision 130532)
|
| +++ content/browser/dom_storage/dom_storage_browsertest.cc (working copy)
|
| @@ -2,164 +2,55 @@
|
| // 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 "base/path_service.h"
|
| #include "chrome/browser/ui/browser.h"
|
| +#include "chrome/test/base/in_process_browser_test.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 "content/public/common/content_paths.h"
|
| +#include "net/base/net_util.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) {
|
| +// This browser test is aimed towards exercising the DomStorage system
|
| +// from end-to-end.
|
| +class DomStorageBrowserTest : public InProcessBrowserTest {
|
| + public:
|
| + DomStorageBrowserTest() {
|
| + EnableDOMAutomation();
|
| }
|
|
|
| - virtual ~DOMStorageTestBase() {}
|
| -
|
| - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
|
| - command_line->AppendSwitch(switches::kDisablePopupBlocking);
|
| + GURL GetTestURL(const char* name) {
|
| + FilePath file_name = FilePath().AppendASCII(name);
|
| + FilePath dir;
|
| + PathService::Get(content::DIR_TEST_DATA, &dir);
|
| + return net::FilePathToFileURL(
|
| + dir.Append(FILE_PATH_LITERAL("dom_storage")).Append(file_name));
|
| }
|
|
|
| - 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;
|
| + void SimpleTest(const GURL& test_url, bool incognito) {
|
| + // The test page will perform tests then navigate to either
|
| + // a #pass or #fail ref.
|
| + Browser* the_browser = incognito ? CreateIncognitoBrowser() : browser();
|
| + ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
|
| + the_browser, test_url, 2);
|
| + std::string result = the_browser->GetSelectedWebContents()->GetURL().ref();
|
| + if (result != "pass") {
|
| + std::string js_result;
|
| + ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
|
| + the_browser->GetSelectedWebContents()->GetRenderViewHost(), L"",
|
| + L"window.domAutomationController.send(getLog())", &js_result));
|
| + FAIL() << "Failed: " << js_result;
|
| }
|
| }
|
| -
|
| - FilePath test_dir_;
|
| };
|
|
|
| -class DOMStorageTest : public DOMStorageTestBase {
|
| - public:
|
| - DOMStorageTest()
|
| - : DOMStorageTestBase(FilePath().AppendASCII("storage").
|
| - AppendASCII("domstorage")) {
|
| - }
|
| - virtual ~DOMStorageTest() {}
|
| -};
|
| +static const bool kIncognito = true;
|
| +static const bool kNotIncognito = false;
|
|
|
| -
|
| -// http://crbug.com/113611
|
| -IN_PROC_BROWSER_TEST_F(DOMStorageTest, FAILS_RootLayoutTests) {
|
| - AddResourceForLayoutTest(FilePath(), FilePath().AppendASCII("script-tests"));
|
| - RunTests(kRootFiles);
|
| +IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheck) {
|
| + SimpleTest(GetTestURL("sanity_check.html"), kNotIncognito);
|
| }
|
|
|
| -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);
|
| +IN_PROC_BROWSER_TEST_F(DomStorageBrowserTest, SanityCheckIncognito) {
|
| + SimpleTest(GetTestURL("sanity_check.html"), kIncognito);
|
| }
|
| -
|
| -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
|
|
|