| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/command_line.h" | |
| 6 #include "chrome/browser/ui/browser.h" | |
| 7 #include "chrome/test/base/ui_test_utils.h" | |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | |
| 9 #include "content/browser/tab_contents/tab_contents.h" | |
| 10 #include "content/public/common/content_switches.h" | |
| 11 #include "content/test/layout_browsertest.h" | |
| 12 #include "webkit/dom_storage/dom_storage_types.h" | |
| 13 | |
| 14 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND | |
| 15 // TODO(michaeln) Ensure they pass. | |
| 16 #else | |
| 17 static const char* kRootFiles[] = { | |
| 18 "clear.html", | |
| 19 // "complex-keys.html", // Output too big for a cookie. crbug.com/33472 | |
| 20 // "complex-values.html", // crbug.com/33472 | |
| 21 "quota.html", | |
| 22 "remove-item.html", | |
| 23 "window-attributes-exist.html", | |
| 24 NULL | |
| 25 }; | |
| 26 | |
| 27 static const char* kEventsFiles[] = { | |
| 28 // "basic-body-attribute.html", // crbug.com/33472 | |
| 29 // "basic.html", // crbug.com/33472 | |
| 30 // "basic-setattribute.html", // crbug.com/33472 | |
| 31 "case-sensitive.html", | |
| 32 "documentURI.html", | |
| 33 NULL | |
| 34 }; | |
| 35 | |
| 36 static const char* kStorageFiles[] = { | |
| 37 "delete-removal.html", | |
| 38 "enumerate-storage.html", | |
| 39 "enumerate-with-length-and-key.html", | |
| 40 "index-get-and-set.html", | |
| 41 "simple-usage.html", | |
| 42 "string-conversion.html", | |
| 43 // "window-open.html", // TODO(jorlow): Fix | |
| 44 NULL | |
| 45 }; | |
| 46 | |
| 47 class DOMStorageTestBase : public InProcessBrowserLayoutTest { | |
| 48 protected: | |
| 49 DOMStorageTestBase(const FilePath& test_case_dir) | |
| 50 : InProcessBrowserLayoutTest(FilePath(), test_case_dir) { | |
| 51 } | |
| 52 | |
| 53 virtual ~DOMStorageTestBase() {} | |
| 54 | |
| 55 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 56 command_line->AppendSwitch(switches::kDisablePopupBlocking); | |
| 57 } | |
| 58 | |
| 59 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
| 60 InProcessBrowserLayoutTest::SetUpInProcessBrowserTestFixture(); | |
| 61 AddResourceForLayoutTest( | |
| 62 FilePath().AppendASCII("fast").AppendASCII("js"), | |
| 63 FilePath().AppendASCII("resources")); | |
| 64 } | |
| 65 | |
| 66 // This is somewhat of a hack because we're running a real browser that | |
| 67 // actually persists the LocalStorage state vs. DRT and TestShell which don't. | |
| 68 // The correct fix is to fix the LayoutTests, but similar patches have been | |
| 69 // rejected in the past. | |
| 70 void ClearDOMStorage() { | |
| 71 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | |
| 72 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | |
| 73 L"localStorage.clear();sessionStorage.clear();")); | |
| 74 } | |
| 75 | |
| 76 // Runs each test in an array of strings until it hits a NULL. | |
| 77 void RunTests(const char** files) { | |
| 78 while (*files) { | |
| 79 RunLayoutTest(*files); | |
| 80 ClearDOMStorage(); | |
| 81 ++files; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 FilePath test_dir_; | |
| 86 }; | |
| 87 | |
| 88 class DOMStorageTest : public DOMStorageTestBase { | |
| 89 public: | |
| 90 DOMStorageTest() | |
| 91 : DOMStorageTestBase(FilePath().AppendASCII("storage"). | |
| 92 AppendASCII("domstorage")) { | |
| 93 } | |
| 94 virtual ~DOMStorageTest() {} | |
| 95 }; | |
| 96 | |
| 97 | |
| 98 // http://crbug.com/113611 | |
| 99 IN_PROC_BROWSER_TEST_F(DOMStorageTest, FAILS_RootLayoutTests) { | |
| 100 AddResourceForLayoutTest(FilePath(), FilePath().AppendASCII("script-tests")); | |
| 101 RunTests(kRootFiles); | |
| 102 } | |
| 103 | |
| 104 class DOMStorageTestEvents : public DOMStorageTestBase { | |
| 105 public: | |
| 106 DOMStorageTestEvents() | |
| 107 : DOMStorageTestBase(FilePath().AppendASCII("storage"). | |
| 108 AppendASCII("domstorage"). | |
| 109 AppendASCII("events")) { | |
| 110 } | |
| 111 virtual ~DOMStorageTestEvents() {} | |
| 112 }; | |
| 113 | |
| 114 // Flakily fails on all platforms. http://crbug.com/102641 | |
| 115 IN_PROC_BROWSER_TEST_F(DOMStorageTestEvents, DISABLED_EventLayoutTests) { | |
| 116 AddResourceForLayoutTest( | |
| 117 FilePath(), | |
| 118 FilePath().AppendASCII("storage").AppendASCII("domstorage"). | |
| 119 AppendASCII("script-tests")); | |
| 120 RunTests(kEventsFiles); | |
| 121 } | |
| 122 | |
| 123 class LocalStorageTest : public DOMStorageTestBase { | |
| 124 public: | |
| 125 LocalStorageTest() | |
| 126 : DOMStorageTestBase(FilePath().AppendASCII("storage"). | |
| 127 AppendASCII("domstorage"). | |
| 128 AppendASCII("localstorage")) { | |
| 129 } | |
| 130 virtual ~LocalStorageTest() {} | |
| 131 }; | |
| 132 | |
| 133 #if defined(OS_LINUX) | |
| 134 // http://crbug.com/104872 | |
| 135 #define MAYBE_LocalStorageLayoutTests FAILS_LocalStorageLayoutTests | |
| 136 #else | |
| 137 #define MAYBE_LocalStorageLayoutTests LocalStorageLayoutTests | |
| 138 #endif | |
| 139 | |
| 140 IN_PROC_BROWSER_TEST_F(LocalStorageTest, MAYBE_LocalStorageLayoutTests) { | |
| 141 RunTests(kStorageFiles); | |
| 142 } | |
| 143 | |
| 144 class SessionStorageTest : public DOMStorageTestBase { | |
| 145 public: | |
| 146 SessionStorageTest() | |
| 147 : DOMStorageTestBase(FilePath().AppendASCII("storage"). | |
| 148 AppendASCII("domstorage"). | |
| 149 AppendASCII("sessionstorage")) { | |
| 150 } | |
| 151 virtual ~SessionStorageTest() {} | |
| 152 }; | |
| 153 | |
| 154 #if defined(OS_LINUX) | |
| 155 // http://crbug.com/104872 | |
| 156 #define MAYBE_SessionStorageLayoutTests FAILS_SessionStorageLayoutTests | |
| 157 #else | |
| 158 #define MAYBE_SessionStorageLayoutTests SessionStorageLayoutTests | |
| 159 #endif | |
| 160 | |
| 161 IN_PROC_BROWSER_TEST_F(SessionStorageTest, MAYBE_SessionStorageLayoutTests) { | |
| 162 RunTests(kStorageFiles); | |
| 163 } | |
| 164 | |
| 165 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND | |
| OLD | NEW |