| 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/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); | 980 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); |
| 981 i != apis.end(); ++i) | 981 i != apis.end(); ++i) |
| 982 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); | 982 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); |
| 983 } | 983 } |
| 984 | 984 |
| 985 TEST_F(ExtensionManifestTest, BackgroundPage) { | 985 TEST_F(ExtensionManifestTest, BackgroundPage) { |
| 986 scoped_refptr<Extension> extension( | 986 scoped_refptr<Extension> extension( |
| 987 LoadAndExpectSuccess("background_page.json")); | 987 LoadAndExpectSuccess("background_page.json")); |
| 988 ASSERT_TRUE(extension); | 988 ASSERT_TRUE(extension); |
| 989 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path()); | 989 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path()); |
| 990 EXPECT_TRUE(extension->allow_background_js_access()); |
| 990 | 991 |
| 991 std::string error; | 992 std::string error; |
| 992 scoped_ptr<DictionaryValue> manifest( | 993 scoped_ptr<DictionaryValue> manifest( |
| 993 LoadManifestFile("background_page_legacy.json", &error)); | 994 LoadManifestFile("background_page_legacy.json", &error)); |
| 994 ASSERT_TRUE(manifest.get()); | 995 ASSERT_TRUE(manifest.get()); |
| 995 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); | 996 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); |
| 996 ASSERT_TRUE(extension); | 997 ASSERT_TRUE(extension); |
| 997 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path()); | 998 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path()); |
| 998 | 999 |
| 999 manifest->SetInteger(keys::kManifestVersion, 2); | 1000 manifest->SetInteger(keys::kManifestVersion, 2); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1020 EXPECT_TRUE(extension->has_background_page()); | 1021 EXPECT_TRUE(extension->has_background_page()); |
| 1021 EXPECT_EQ(std::string("/") + | 1022 EXPECT_EQ(std::string("/") + |
| 1022 extension_filenames::kGeneratedBackgroundPageFilename, | 1023 extension_filenames::kGeneratedBackgroundPageFilename, |
| 1023 extension->GetBackgroundURL().path()); | 1024 extension->GetBackgroundURL().path()); |
| 1024 | 1025 |
| 1025 manifest->SetString("background_page", "monkey.html"); | 1026 manifest->SetString("background_page", "monkey.html"); |
| 1026 LoadAndExpectError(Manifest(manifest.get(), ""), | 1027 LoadAndExpectError(Manifest(manifest.get(), ""), |
| 1027 errors::kInvalidBackgroundCombination); | 1028 errors::kInvalidBackgroundCombination); |
| 1028 } | 1029 } |
| 1029 | 1030 |
| 1031 TEST_F(ExtensionManifestTest, BackgroundAllowNoJsAccess) { |
| 1032 scoped_refptr<Extension> extension; |
| 1033 extension = LoadAndExpectSuccess("background_allow_no_js_access.json"); |
| 1034 ASSERT_TRUE(extension); |
| 1035 EXPECT_FALSE(extension->allow_background_js_access()); |
| 1036 } |
| 1037 |
| 1030 TEST_F(ExtensionManifestTest, PageActionManifestVersion2) { | 1038 TEST_F(ExtensionManifestTest, PageActionManifestVersion2) { |
| 1031 scoped_refptr<Extension> extension( | 1039 scoped_refptr<Extension> extension( |
| 1032 LoadAndExpectSuccess("page_action_manifest_version_2.json")); | 1040 LoadAndExpectSuccess("page_action_manifest_version_2.json")); |
| 1033 ASSERT_TRUE(extension.get()); | 1041 ASSERT_TRUE(extension.get()); |
| 1034 ASSERT_TRUE(extension->page_action()); | 1042 ASSERT_TRUE(extension->page_action()); |
| 1035 | 1043 |
| 1036 EXPECT_EQ("", extension->page_action()->id()); | 1044 EXPECT_EQ("", extension->page_action()->id()); |
| 1037 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size()); | 1045 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size()); |
| 1038 EXPECT_EQ("", extension->page_action()->GetTitle( | 1046 EXPECT_EQ("", extension->page_action()->GetTitle( |
| 1039 ExtensionAction::kDefaultTabId)); | 1047 ExtensionAction::kDefaultTabId)); |
| 1040 EXPECT_FALSE(extension->page_action()->HasPopup( | 1048 EXPECT_FALSE(extension->page_action()->HasPopup( |
| 1041 ExtensionAction::kDefaultTabId)); | 1049 ExtensionAction::kDefaultTabId)); |
| 1042 | 1050 |
| 1043 LoadAndExpectError("page_action_manifest_version_2b.json", | 1051 LoadAndExpectError("page_action_manifest_version_2b.json", |
| 1044 errors::kInvalidPageActionPopup); | 1052 errors::kInvalidPageActionPopup); |
| 1045 } | 1053 } |
| OLD | NEW |