Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: chrome/common/extensions/extension_manifests_unittest.cc

Issue 9150008: Introduce background.scripts feature for extension manifests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready to land Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); 977 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis();
978 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); 978 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin();
979 i != apis.end(); ++i) 979 i != apis.end(); ++i)
980 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); 980 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions());
981 } 981 }
982 982
983 TEST_F(ExtensionManifestTest, BackgroundPage) { 983 TEST_F(ExtensionManifestTest, BackgroundPage) {
984 scoped_refptr<Extension> extension( 984 scoped_refptr<Extension> extension(
985 LoadAndExpectSuccess("background_page.json")); 985 LoadAndExpectSuccess("background_page.json"));
986 ASSERT_TRUE(extension); 986 ASSERT_TRUE(extension);
987 EXPECT_EQ("/foo.html", extension->background_url().path()); 987 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
988 988
989 std::string error; 989 std::string error;
990 scoped_ptr<DictionaryValue> manifest( 990 scoped_ptr<DictionaryValue> manifest(
991 LoadManifestFile("background_page_legacy.json", &error)); 991 LoadManifestFile("background_page_legacy.json", &error));
992 ASSERT_TRUE(manifest.get()); 992 ASSERT_TRUE(manifest.get());
993 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); 993 extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
994 ASSERT_TRUE(extension); 994 ASSERT_TRUE(extension);
995 EXPECT_EQ("/foo.html", extension->background_url().path()); 995 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
996 996
997 manifest->SetInteger(keys::kManifestVersion, 2); 997 manifest->SetInteger(keys::kManifestVersion, 2);
998 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); 998 extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
999 ASSERT_TRUE(extension); 999 ASSERT_TRUE(extension);
1000 EXPECT_FALSE(extension->background_url().is_valid()); 1000 EXPECT_FALSE(extension->GetBackgroundURL().is_valid());
1001 }
1002
1003 TEST_F(ExtensionManifestTest, BackgroundScripts) {
1004 std::string error;
1005 scoped_ptr<DictionaryValue> manifest(
1006 LoadManifestFile("background_scripts.json", &error));
1007 ASSERT_TRUE(manifest.get());
1008
1009 scoped_refptr<Extension> extension(
1010 LoadAndExpectSuccess(Manifest(manifest.get(), "")));
1011 ASSERT_TRUE(extension);
1012 EXPECT_EQ(2u, extension->background_scripts().size());
1013 EXPECT_EQ("foo.js", extension->background_scripts()[0u]);
1014 EXPECT_EQ("bar/baz.js", extension->background_scripts()[1u]);
1015
1016 EXPECT_TRUE(extension->has_background_page());
1017 EXPECT_EQ(std::string("/") +
1018 extension_filenames::kGeneratedBackgroundPageFilename,
1019 extension->GetBackgroundURL().path());
1020
1021 manifest->SetString("background_page", "monkey.html");
1022 LoadAndExpectError(Manifest(manifest.get(), ""),
1023 errors::kInvalidBackgroundCombination);
1001 } 1024 }
1002 1025
1003 TEST_F(ExtensionManifestTest, PageActionManifestVersion2) { 1026 TEST_F(ExtensionManifestTest, PageActionManifestVersion2) {
1004 scoped_refptr<Extension> extension( 1027 scoped_refptr<Extension> extension(
1005 LoadAndExpectSuccess("page_action_manifest_version_2.json")); 1028 LoadAndExpectSuccess("page_action_manifest_version_2.json"));
1006 ASSERT_TRUE(extension.get()); 1029 ASSERT_TRUE(extension.get());
1007 ASSERT_TRUE(extension->page_action()); 1030 ASSERT_TRUE(extension->page_action());
1008 1031
1009 EXPECT_EQ("", extension->page_action()->id()); 1032 EXPECT_EQ("", extension->page_action()->id());
1010 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size()); 1033 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size());
1011 EXPECT_EQ("", extension->page_action()->GetTitle( 1034 EXPECT_EQ("", extension->page_action()->GetTitle(
1012 ExtensionAction::kDefaultTabId)); 1035 ExtensionAction::kDefaultTabId));
1013 EXPECT_FALSE(extension->page_action()->HasPopup( 1036 EXPECT_FALSE(extension->page_action()->HasPopup(
1014 ExtensionAction::kDefaultTabId)); 1037 ExtensionAction::kDefaultTabId));
1015 1038
1016 LoadAndExpectError("page_action_manifest_version_2b.json", 1039 LoadAndExpectError("page_action_manifest_version_2b.json",
1017 errors::kInvalidPageActionPopup); 1040 errors::kInvalidPageActionPopup);
1018 } 1041 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_file_util_unittest.cc ('k') | chrome/test/data/extensions/api_test/alert/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698