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

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: 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); 1009 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis();
1010 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); 1010 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin();
1011 i != apis.end(); ++i) 1011 i != apis.end(); ++i)
1012 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); 1012 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions());
1013 } 1013 }
1014 1014
1015 TEST_F(ExtensionManifestTest, BackgroundPage) { 1015 TEST_F(ExtensionManifestTest, BackgroundPage) {
1016 scoped_refptr<Extension> extension( 1016 scoped_refptr<Extension> extension(
1017 LoadAndExpectSuccess("background_page.json")); 1017 LoadAndExpectSuccess("background_page.json"));
1018 ASSERT_TRUE(extension); 1018 ASSERT_TRUE(extension);
1019 EXPECT_EQ("/foo.html", extension->background_url().path()); 1019 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
1020 1020
1021 std::string error; 1021 std::string error;
1022 scoped_ptr<DictionaryValue> manifest( 1022 scoped_ptr<DictionaryValue> manifest(
1023 LoadManifestFile("background_page_legacy.json", &error)); 1023 LoadManifestFile("background_page_legacy.json", &error));
1024 ASSERT_TRUE(manifest.get()); 1024 ASSERT_TRUE(manifest.get());
1025 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); 1025 extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
1026 ASSERT_TRUE(extension); 1026 ASSERT_TRUE(extension);
1027 EXPECT_EQ("/foo.html", extension->background_url().path()); 1027 EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
1028 1028
1029 manifest->SetInteger(keys::kManifestVersion, 2); 1029 manifest->SetInteger(keys::kManifestVersion, 2);
1030 extension = LoadAndExpectSuccess(Manifest(manifest.get(), "")); 1030 extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
1031 ASSERT_TRUE(extension); 1031 ASSERT_TRUE(extension);
1032 EXPECT_FALSE(extension->background_url().is_valid()); 1032 EXPECT_FALSE(extension->GetBackgroundURL().is_valid());
1033 }
1034
1035 TEST_F(ExtensionManifestTest, BackgroundScripts) {
1036 scoped_refptr<Extension> extension(
1037 LoadAndExpectSuccess("background_scripts.json"));
1038 ASSERT_TRUE(extension);
1039 EXPECT_EQ(2u, extension->background_scripts().size());
1040 EXPECT_EQ("foo.js", extension->background_scripts()[0u]);
1041 EXPECT_EQ("bar/baz.js", extension->background_scripts()[1u]);
1042
1043 EXPECT_TRUE(extension->has_background_page());
1044 EXPECT_EQ(std::string("/") +
1045 extension_filenames::kGeneratedBackgroundPageFilename,
1046 extension->GetBackgroundURL().path());
1033 } 1047 }
1034 1048
1035 TEST_F(ExtensionManifestTest, PageActionManifestVersion2) { 1049 TEST_F(ExtensionManifestTest, PageActionManifestVersion2) {
1036 scoped_refptr<Extension> extension( 1050 scoped_refptr<Extension> extension(
1037 LoadAndExpectSuccess("page_action_manifest_version_2.json")); 1051 LoadAndExpectSuccess("page_action_manifest_version_2.json"));
1038 ASSERT_TRUE(extension.get()); 1052 ASSERT_TRUE(extension.get());
1039 ASSERT_TRUE(extension->page_action()); 1053 ASSERT_TRUE(extension->page_action());
1040 1054
1041 EXPECT_EQ("", extension->page_action()->id()); 1055 EXPECT_EQ("", extension->page_action()->id());
1042 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size()); 1056 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size());
1043 EXPECT_EQ("", extension->page_action()->GetTitle( 1057 EXPECT_EQ("", extension->page_action()->GetTitle(
1044 ExtensionAction::kDefaultTabId)); 1058 ExtensionAction::kDefaultTabId));
1045 EXPECT_FALSE(extension->page_action()->HasPopup( 1059 EXPECT_FALSE(extension->page_action()->HasPopup(
1046 ExtensionAction::kDefaultTabId)); 1060 ExtensionAction::kDefaultTabId));
1047 1061
1048 LoadAndExpectError("page_action_manifest_version_2b.json", 1062 LoadAndExpectError("page_action_manifest_version_2b.json",
1049 errors::kInvalidPageActionPopup); 1063 errors::kInvalidPageActionPopup);
1050 } 1064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698