| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 8 #include "content/browser/dom_storage/local_storage_context_mojo.h" | 8 #include "content/browser/dom_storage/local_storage_context_mojo.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/dom_storage/dom_storage_types.h" | 10 #include "content/common/dom_storage/dom_storage_types.h" |
| 11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/storage_partition.h" | 12 #include "content/public/browser/storage_partition.h" |
| 13 #include "content/public/common/content_paths.h" | 13 #include "content/public/common/content_paths.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 16 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
| 17 #include "content/public/test/content_browser_test_utils.h" | 17 #include "content/public/test/content_browser_test_utils.h" |
| 18 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 // This browser test is aimed towards exercising the DOMStorage system | 22 // This browser test is aimed towards exercising the DOMStorage system |
| 23 // from end-to-end. | 23 // from end-to-end. |
| 24 class DOMStorageBrowserTest : public ContentBrowserTest { | 24 class DOMStorageBrowserTest : public ContentBrowserTest { |
| 25 public: | 25 public: |
| 26 DOMStorageBrowserTest() {} | 26 DOMStorageBrowserTest() {} |
| 27 | 27 |
| 28 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 29 ContentBrowserTest::SetUpCommandLine(command_line); |
| 30 command_line->AppendSwitch(switches::kDisableMojoLocalStorage); |
| 31 } |
| 32 |
| 28 void SimpleTest(const GURL& test_url, bool incognito) { | 33 void SimpleTest(const GURL& test_url, bool incognito) { |
| 29 // The test page will perform tests then navigate to either | 34 // The test page will perform tests then navigate to either |
| 30 // a #pass or #fail ref. | 35 // a #pass or #fail ref. |
| 31 Shell* the_browser = incognito ? CreateOffTheRecordBrowser() : shell(); | 36 Shell* the_browser = incognito ? CreateOffTheRecordBrowser() : shell(); |
| 32 NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2); | 37 NavigateToURLBlockUntilNavigationsComplete(the_browser, test_url, 2); |
| 33 std::string result = | 38 std::string result = |
| 34 the_browser->web_contents()->GetLastCommittedURL().ref(); | 39 the_browser->web_contents()->GetLastCommittedURL().ref(); |
| 35 if (result != "pass") { | 40 if (result != "pass") { |
| 36 std::string js_result; | 41 std::string js_result; |
| 37 ASSERT_TRUE(ExecuteScriptAndExtractString( | 42 ASSERT_TRUE(ExecuteScriptAndExtractString( |
| 38 the_browser, "window.domAutomationController.send(getLog())", | 43 the_browser, "window.domAutomationController.send(getLog())", |
| 39 &js_result)); | 44 &js_result)); |
| 40 FAIL() << "Failed: " << js_result; | 45 FAIL() << "Failed: " << js_result; |
| 41 } | 46 } |
| 42 } | 47 } |
| 43 }; | 48 }; |
| 44 | 49 |
| 45 class MojoDOMStorageBrowserTest : public DOMStorageBrowserTest { | 50 class MojoDOMStorageBrowserTest : public DOMStorageBrowserTest { |
| 46 public: | 51 public: |
| 47 void SetUpCommandLine(base::CommandLine* command_line) override { | 52 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 48 ContentBrowserTest::SetUpCommandLine(command_line); | 53 ContentBrowserTest::SetUpCommandLine(command_line); |
| 49 command_line->AppendSwitch(switches::kMojoLocalStorage); | |
| 50 } | 54 } |
| 51 | 55 |
| 52 LocalStorageContextMojo* context() { | 56 LocalStorageContextMojo* context() { |
| 53 return static_cast<DOMStorageContextWrapper*>( | 57 return static_cast<DOMStorageContextWrapper*>( |
| 54 BrowserContext::GetDefaultStoragePartition( | 58 BrowserContext::GetDefaultStoragePartition( |
| 55 shell()->web_contents()->GetBrowserContext()) | 59 shell()->web_contents()->GetBrowserContext()) |
| 56 ->GetDOMStorageContext()) | 60 ->GetDOMStorageContext()) |
| 57 ->mojo_state_; | 61 ->mojo_state_; |
| 58 } | 62 } |
| 59 | 63 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); | 117 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); |
| 114 } | 118 } |
| 115 | 119 |
| 116 class DOMStorageMigrationBrowserTest : public DOMStorageBrowserTest { | 120 class DOMStorageMigrationBrowserTest : public DOMStorageBrowserTest { |
| 117 public: | 121 public: |
| 118 void SetUpCommandLine(base::CommandLine* command_line) override { | 122 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 119 ContentBrowserTest::SetUpCommandLine(command_line); | 123 ContentBrowserTest::SetUpCommandLine(command_line); |
| 120 // Only enable mojo local storage if this is not a PRE_ test. | 124 // Only enable mojo local storage if this is not a PRE_ test. |
| 121 const testing::TestInfo* test = | 125 const testing::TestInfo* test = |
| 122 testing::UnitTest::GetInstance()->current_test_info(); | 126 testing::UnitTest::GetInstance()->current_test_info(); |
| 123 if (!base::StartsWith(test->name(), "PRE_", base::CompareCase::SENSITIVE)) | 127 if (base::StartsWith(test->name(), "PRE_", base::CompareCase::SENSITIVE)) |
| 124 command_line->AppendSwitch(switches::kMojoLocalStorage); | 128 command_line->AppendSwitch(switches::kDisableMojoLocalStorage); |
| 125 } | 129 } |
| 126 }; | 130 }; |
| 127 | 131 |
| 128 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, PRE_DataMigrates) { | 132 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, PRE_DataMigrates) { |
| 129 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito); | 133 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito); |
| 130 } | 134 } |
| 131 | 135 |
| 132 // http://crbug.com/654704 PRE_ tests aren't supported on Android. | 136 // http://crbug.com/654704 PRE_ tests aren't supported on Android. |
| 133 #if defined(OS_ANDROID) | 137 #if defined(OS_ANDROID) |
| 134 #define MAYBE_DataMigrates DISABLED_DataMigrates | 138 #define MAYBE_DataMigrates DISABLED_DataMigrates |
| 135 #else | 139 #else |
| 136 #define MAYBE_DataMigrates DataMigrates | 140 #define MAYBE_DataMigrates DataMigrates |
| 137 #endif | 141 #endif |
| 138 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, MAYBE_DataMigrates) { | 142 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, MAYBE_DataMigrates) { |
| 139 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); | 143 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); |
| 140 } | 144 } |
| 141 | 145 |
| 142 } // namespace content | 146 } // namespace content |
| OLD | NEW |