| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" |
| 7 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 8 #include "chrome/test/automation/tab_proxy.h" | 9 #include "chrome/test/automation/tab_proxy.h" |
| 9 #include "chrome/test/base/ui_test_utils.h" | |
| 10 #include "chrome/test/ui/ui_layout_test.h" | 10 #include "chrome/test/ui/ui_layout_test.h" |
| 11 #include "content/public/common/content_paths.h" |
| 11 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 12 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
| 13 #include "webkit/dom_storage/dom_storage_types.h" | 14 #include "webkit/dom_storage/dom_storage_types.h" |
| 14 | 15 |
| 15 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND | 16 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND |
| 16 // No longer applicable. | 17 // No longer applicable. |
| 17 #else | 18 #else |
| 18 | 19 |
| 19 static const char* kRootFiles[] = { | 20 static const char* kRootFiles[] = { |
| 20 "clear.html", | 21 "clear.html", |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 72 } |
| 72 | 73 |
| 73 // This is somewhat of a hack because we're running a real browser that | 74 // This is somewhat of a hack because we're running a real browser that |
| 74 // actually persists the LocalStorage state vs. DRT and TestShell which don't. | 75 // actually persists the LocalStorage state vs. DRT and TestShell which don't. |
| 75 // The correct fix is to fix the LayoutTests, but similar patches have been | 76 // The correct fix is to fix the LayoutTests, but similar patches have been |
| 76 // rejected in the past. | 77 // rejected in the past. |
| 77 void ClearDOMStorage() { | 78 void ClearDOMStorage() { |
| 78 scoped_refptr<TabProxy> tab(GetActiveTab()); | 79 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 79 ASSERT_TRUE(tab.get()); | 80 ASSERT_TRUE(tab.get()); |
| 80 | 81 |
| 81 const FilePath dir(FILE_PATH_LITERAL("layout_tests")); | 82 FilePath dir; |
| 82 const FilePath file(FILE_PATH_LITERAL("clear_dom_storage.html")); | 83 PathService::Get(content::DIR_TEST_DATA, &dir); |
| 83 GURL url = ui_test_utils::GetTestUrl(dir, file); | 84 GURL url = net::FilePathToFileURL( |
| 85 dir.AppendASCII("layout_tests").AppendASCII("clear_dom_storage.html")); |
| 86 |
| 84 ASSERT_TRUE(tab->SetCookie(url, "")); | 87 ASSERT_TRUE(tab->SetCookie(url, "")); |
| 85 ASSERT_TRUE(tab->NavigateToURL(url)); | 88 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 86 | 89 |
| 87 WaitUntilCookieNonEmpty(tab.get(), url, "cleared", | 90 WaitUntilCookieNonEmpty(tab.get(), url, "cleared", |
| 88 TestTimeouts::action_max_timeout_ms()); | 91 TestTimeouts::action_max_timeout_ms()); |
| 89 } | 92 } |
| 90 | 93 |
| 91 // Runs each test in an array of strings until it hits a NULL. | 94 // Runs each test in an array of strings until it hits a NULL. |
| 92 void RunTests(const char** files) { | 95 void RunTests(const char** files) { |
| 93 while (*files) { | 96 while (*files) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 EXPECT_FALSE(StorageDirIsEmpty()); | 213 EXPECT_FALSE(StorageDirIsEmpty()); |
| 211 | 214 |
| 212 LaunchBrowserAndServer(); | 215 LaunchBrowserAndServer(); |
| 213 NavigateToURL(TestUrl()); | 216 NavigateToURL(TestUrl()); |
| 214 NavigateToURL(GURL("javascript:clear()")); | 217 NavigateToURL(GURL("javascript:clear()")); |
| 215 QuitBrowser(); | 218 QuitBrowser(); |
| 216 EXPECT_TRUE(StorageDirIsEmpty()); | 219 EXPECT_TRUE(StorageDirIsEmpty()); |
| 217 } | 220 } |
| 218 | 221 |
| 219 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND | 222 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND |
| OLD | NEW |