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 "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/extensions/background_info.h" | 11 #include "chrome/common/extensions/background_info.h" |
12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_manifest_constants.h" | 13 #include "chrome/common/extensions/extension_manifest_constants.h" |
14 #include "chrome/common/extensions/features/base_feature_provider.h" | 14 #include "chrome/common/extensions/features/base_feature_provider.h" |
15 #include "chrome/common/extensions/features/feature.h" | 15 #include "chrome/common/extensions/features/feature.h" |
| 16 #include "extensions/common/constants.h" |
16 #include "extensions/common/error_utils.h" | 17 #include "extensions/common/error_utils.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace errors = extension_manifest_errors; | 20 namespace errors = extension_manifest_errors; |
20 namespace keys = extension_manifest_keys; | 21 namespace keys = extension_manifest_keys; |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 class ExtensionManifestBackgroundTest : public ExtensionManifestTest { | 25 class ExtensionManifestBackgroundTest : public ExtensionManifestTest { |
25 }; | 26 }; |
(...skipping 13 matching lines...) Expand all Loading... |
39 LoadAndExpectSuccess(Manifest(manifest.get(), ""))); | 40 LoadAndExpectSuccess(Manifest(manifest.get(), ""))); |
40 ASSERT_TRUE(extension.get()); | 41 ASSERT_TRUE(extension.get()); |
41 const std::vector<std::string>& background_scripts = | 42 const std::vector<std::string>& background_scripts = |
42 BackgroundInfo::GetBackgroundScripts(extension.get()); | 43 BackgroundInfo::GetBackgroundScripts(extension.get()); |
43 ASSERT_EQ(2u, background_scripts.size()); | 44 ASSERT_EQ(2u, background_scripts.size()); |
44 EXPECT_EQ("foo.js", background_scripts[0u]); | 45 EXPECT_EQ("foo.js", background_scripts[0u]); |
45 EXPECT_EQ("bar/baz.js", background_scripts[1u]); | 46 EXPECT_EQ("bar/baz.js", background_scripts[1u]); |
46 | 47 |
47 EXPECT_TRUE(BackgroundInfo::HasBackgroundPage(extension.get())); | 48 EXPECT_TRUE(BackgroundInfo::HasBackgroundPage(extension.get())); |
48 EXPECT_EQ( | 49 EXPECT_EQ( |
49 std::string("/") + extension_filenames::kGeneratedBackgroundPageFilename, | 50 std::string("/") + kGeneratedBackgroundPageFilename, |
50 BackgroundInfo::GetBackgroundURL(extension.get()).path()); | 51 BackgroundInfo::GetBackgroundURL(extension.get()).path()); |
51 | 52 |
52 manifest->SetString("background_page", "monkey.html"); | 53 manifest->SetString("background_page", "monkey.html"); |
53 LoadAndExpectError(Manifest(manifest.get(), ""), | 54 LoadAndExpectError(Manifest(manifest.get(), ""), |
54 errors::kInvalidBackgroundCombination); | 55 errors::kInvalidBackgroundCombination); |
55 } | 56 } |
56 | 57 |
57 TEST_F(ExtensionManifestBackgroundTest, BackgroundPage) { | 58 TEST_F(ExtensionManifestBackgroundTest, BackgroundPage) { |
58 scoped_refptr<Extension> extension( | 59 scoped_refptr<Extension> extension( |
59 LoadAndExpectSuccess("background_page.json")); | 60 LoadAndExpectSuccess("background_page.json")); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); | 107 EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension.get())); |
107 | 108 |
108 base::ListValue* permissions = new base::ListValue(); | 109 base::ListValue* permissions = new base::ListValue(); |
109 permissions->Append(new base::StringValue("webRequest")); | 110 permissions->Append(new base::StringValue("webRequest")); |
110 manifest->Set(keys::kPermissions, permissions); | 111 manifest->Set(keys::kPermissions, permissions); |
111 LoadAndExpectError(Manifest(manifest.get(), ""), | 112 LoadAndExpectError(Manifest(manifest.get(), ""), |
112 errors::kWebRequestConflictsWithLazyBackground); | 113 errors::kWebRequestConflictsWithLazyBackground); |
113 } | 114 } |
114 | 115 |
115 } // namespace extensions | 116 } // namespace extensions |
OLD | NEW |