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

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

Issue 8654001: Reland restrict extension features based on the extension type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 scoped_refptr<Extension> extension(LoadAndExpectSuccess("sidebar.json")); 581 scoped_refptr<Extension> extension(LoadAndExpectSuccess("sidebar.json"));
582 ASSERT_TRUE(extension->sidebar_defaults() != NULL); 582 ASSERT_TRUE(extension->sidebar_defaults() != NULL);
583 EXPECT_EQ(extension->sidebar_defaults()->default_title(), 583 EXPECT_EQ(extension->sidebar_defaults()->default_title(),
584 ASCIIToUTF16("Default title")); 584 ASCIIToUTF16("Default title"));
585 EXPECT_EQ(extension->sidebar_defaults()->default_icon_path(), 585 EXPECT_EQ(extension->sidebar_defaults()->default_icon_path(),
586 "icon.png"); 586 "icon.png");
587 EXPECT_EQ(extension->url().spec() + "sidebar.html", 587 EXPECT_EQ(extension->url().spec() + "sidebar.html",
588 extension->sidebar_defaults()->default_page().spec()); 588 extension->sidebar_defaults()->default_page().spec());
589 } 589 }
590 590
591 TEST_F(ExtensionManifestTest, DisallowHybridApps) { 591 TEST_F(ExtensionManifestTest, BackgroundPermission) {
592 LoadAndExpectError("disallow_hybrid_1.json", 592 LoadAndExpectError("background_permission.json",
593 ExtensionErrorUtils::FormatErrorMessage(
594 errors::kHostedAppsCannotIncludeExtensionFeatures,
595 keys::kBrowserAction));
596 LoadAndExpectError("disallow_hybrid_2.json",
597 errors::kBackgroundPermissionNeeded); 593 errors::kBackgroundPermissionNeeded);
598 } 594 }
599 595
600 TEST_F(ExtensionManifestTest, OptionsPageInApps) { 596 TEST_F(ExtensionManifestTest, OptionsPageInApps) {
601 scoped_refptr<Extension> extension; 597 scoped_refptr<Extension> extension;
602 598
603 // Allow options page with absolute URL in hosted apps. 599 // Allow options page with absolute URL in hosted apps.
604 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); 600 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json");
605 EXPECT_STREQ("http", 601 EXPECT_STREQ("http",
606 extension->options_url().scheme().c_str()); 602 extension->options_url().scheme().c_str());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 TEST_F(ExtensionManifestTest, NormalizeIconPaths) { 731 TEST_F(ExtensionManifestTest, NormalizeIconPaths) {
736 scoped_refptr<Extension> extension( 732 scoped_refptr<Extension> extension(
737 LoadAndExpectSuccess("normalize_icon_paths.json")); 733 LoadAndExpectSuccess("normalize_icon_paths.json"));
738 EXPECT_EQ("16.png", 734 EXPECT_EQ("16.png",
739 extension->icons().Get(16, ExtensionIconSet::MATCH_EXACTLY)); 735 extension->icons().Get(16, ExtensionIconSet::MATCH_EXACTLY));
740 EXPECT_EQ("48.png", 736 EXPECT_EQ("48.png",
741 extension->icons().Get(48, ExtensionIconSet::MATCH_EXACTLY)); 737 extension->icons().Get(48, ExtensionIconSet::MATCH_EXACTLY));
742 } 738 }
743 739
744 TEST_F(ExtensionManifestTest, DisallowMultipleUISurfaces) { 740 TEST_F(ExtensionManifestTest, DisallowMultipleUISurfaces) {
745 LoadAndExpectError("multiple_ui_surfaces_1.json", errors::kOneUISurfaceOnly); 741 LoadAndExpectError("multiple_ui_surfaces.json", errors::kOneUISurfaceOnly);
746 LoadAndExpectError("multiple_ui_surfaces_2.json", errors::kOneUISurfaceOnly);
747 LoadAndExpectError("multiple_ui_surfaces_3.json", errors::kOneUISurfaceOnly);
748 } 742 }
749 743
750 TEST_F(ExtensionManifestTest, ParseHomepageURLs) { 744 TEST_F(ExtensionManifestTest, ParseHomepageURLs) {
751 scoped_refptr<Extension> extension( 745 scoped_refptr<Extension> extension(
752 LoadAndExpectSuccess("homepage_valid.json")); 746 LoadAndExpectSuccess("homepage_valid.json"));
753 LoadAndExpectError("homepage_empty.json", 747 LoadAndExpectError("homepage_empty.json",
754 extension_manifest_errors::kInvalidHomepageURL); 748 extension_manifest_errors::kInvalidHomepageURL);
755 LoadAndExpectError("homepage_invalid.json", 749 LoadAndExpectError("homepage_invalid.json",
756 extension_manifest_errors::kInvalidHomepageURL); 750 extension_manifest_errors::kInvalidHomepageURL);
757 LoadAndExpectError("homepage_bad_schema.json", 751 LoadAndExpectError("homepage_bad_schema.json",
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // This guy is identical to the previous but doesn't ask for any 988 // This guy is identical to the previous but doesn't ask for any
995 // platform-app-only permissions. We should be able to load him and ask 989 // platform-app-only permissions. We should be able to load him and ask
996 // questions about his permissions. 990 // questions about his permissions.
997 scoped_refptr<Extension> extension( 991 scoped_refptr<Extension> extension(
998 LoadAndExpectSuccess("not_platform_app.json")); 992 LoadAndExpectSuccess("not_platform_app.json"));
999 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); 993 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis();
1000 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); 994 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin();
1001 i != apis.end(); ++i) 995 i != apis.end(); ++i)
1002 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); 996 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions());
1003 } 997 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698