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 "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/test/values_test_util.h" | 7 #include "base/test/values_test_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/extensions/features/feature_channel.h" | 9 #include "chrome/common/extensions/features/feature_channel.h" |
10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
12 #include "extensions/common/constants.h" | 12 #include "extensions/common/constants.h" |
13 #include "extensions/common/error_utils.h" | 13 #include "extensions/common/error_utils.h" |
14 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
15 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
16 #include "extensions/common/manifest_handlers/background_info.h" | 16 #include "extensions/common/manifest_handlers/background_info.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class ExtensionManifestServiceWorkerTest : public ExtensionManifestTest { | 21 class ExtensionManifestServiceWorkerTest : public ExtensionManifestTest { |
22 public: | 22 public: |
23 ExtensionManifestServiceWorkerTest() | 23 ExtensionManifestServiceWorkerTest() |
24 : trunk_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} | 24 : trunk_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {} |
25 | 25 |
26 void AddServiceWorkerCommandLineSwitch() { | 26 void AddServiceWorkerCommandLineSwitch() { |
27 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( | 27 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( |
28 switches::kEnableServiceWorker)); | 28 switches::kEnableExperimentalWebPlatformFeatures)); |
29 CommandLine::ForCurrentProcess()->AppendSwitch( | 29 CommandLine::ForCurrentProcess()->AppendSwitch( |
30 switches::kEnableServiceWorker); | 30 switches::kEnableExperimentalWebPlatformFeatures); |
31 } | 31 } |
32 | 32 |
33 // "app.service_worker" is restricted to trunk in _manifest_features.json. | 33 // "app.service_worker" is restricted to trunk in _manifest_features.json. |
34 extensions::ScopedCurrentChannel trunk_channel_; | 34 extensions::ScopedCurrentChannel trunk_channel_; |
35 }; | 35 }; |
36 | 36 |
37 // Checks that a service_worker key is ignored without enable-service-worker | 37 // Checks that a service_worker key is ignored without |
38 // switch. When service workers are enabled by default please remove this | 38 // enable-experimental-web-platform-features switch. When service workers are |
39 // test. | 39 // enabled by default please remove this test. |
40 TEST_F(ExtensionManifestServiceWorkerTest, ServiceWorkerCommandLineRequired) { | 40 TEST_F(ExtensionManifestServiceWorkerTest, ServiceWorkerCommandLineRequired) { |
41 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( | 41 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( |
42 ::switches::kEnableServiceWorker)); | 42 ::switches::kEnableExperimentalWebPlatformFeatures)); |
43 LoadFromStringAndExpectError( | 43 LoadFromStringAndExpectError( |
44 "{" | 44 "{" |
45 " 'name': ''," | 45 " 'name': ''," |
46 " 'manifest_version': 2," | 46 " 'manifest_version': 2," |
47 " 'version': '1'," | 47 " 'version': '1'," |
48 " 'app': {" | 48 " 'app': {" |
49 " 'service_worker': {" | 49 " 'service_worker': {" |
50 " 'script': 'service_worker.js'" | 50 " 'script': 'service_worker.js'" |
51 " }" | 51 " }" |
52 " }" | 52 " }" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 " }," | 119 " }," |
120 " 'background': {" | 120 " 'background': {" |
121 " 'scripts': [ 'background.js' ]" | 121 " 'scripts': [ 'background.js' ]" |
122 " }" | 122 " }" |
123 " }" | 123 " }" |
124 "}", | 124 "}", |
125 manifest_errors::kInvalidBackgroundCombination); | 125 manifest_errors::kInvalidBackgroundCombination); |
126 } | 126 } |
127 | 127 |
128 } // namespace extensions | 128 } // namespace extensions |
OLD | NEW |