// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <memory> #include "base/command_line.h" #include "base/strings/stringprintf.h" #include "base/test/values_test_util.h" #include "chrome/browser/extensions/test_extension_environment.h" #include "chrome/common/extensions/permissions/chrome_permission_message_provider.h" #include "components/version_info/version_info.h" #include "extensions/common/extension.h" #include "extensions/common/features/feature_channel.h" #include "extensions/common/features/simple_feature.h" #include "extensions/common/permissions/permission_message_test_util.h" #include "extensions/common/permissions/permissions_data.h" #include "extensions/common/switches.h" #include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/gtest/include/gtest/gtest.h" namespace extensions { const char kAllowlistedExtensionID[] = …; // Tests that ChromePermissionMessageProvider produces the expected messages for // various combinations of app/extension permissions. class PermissionMessageCombinationsUnittest : public testing::Test { … }; // Test that the USB, Bluetooth and Serial permissions do not coalesce on their // own, but do coalesce when more than 1 is present. TEST_F(PermissionMessageCombinationsUnittest, USBSerialBluetoothCoalescing) { … } // Test that the History permission takes precedence over the Tabs permission, // and that the Sessions permission modifies the Tabs permission message. TEST_F(PermissionMessageCombinationsUnittest, TabsHistorySessionsCoalescing) { … } // Test that the fileSystem permission produces no messages by itself, unless it // has both the 'write' and 'directory' additional permissions, in which case it // displays a message. TEST_F(PermissionMessageCombinationsUnittest, FileSystemReadWriteCoalescing) { … } // Check that host permission messages are generated correctly when URLs are // entered as permissions. TEST_F(PermissionMessageCombinationsUnittest, HostsPermissionMessages) { … } // Check that permission messages are generated correctly for // SocketsManifestPermission, which has host-like permission messages. TEST_F(PermissionMessageCombinationsUnittest, SocketsManifestPermissionMessages) { … } // Check that permission messages are generated correctly for // MediaGalleriesPermission (an API permission with custom messages). TEST_F(PermissionMessageCombinationsUnittest, MediaGalleriesPermissionMessages) { … } // TODO(sashab): Add tests for SettingsOverrideAPIPermission (an API permission // with custom messages). // Check that permission messages are generated correctly for SocketPermission // (an API permission with custom messages). TEST_F(PermissionMessageCombinationsUnittest, SocketPermissionMessages) { … } // Check that permission messages are generated correctly for // USBDevicePermission (an API permission with custom messages). TEST_F(PermissionMessageCombinationsUnittest, USBDevicePermissionMessages) { … } // Test that hosted apps are not given any messages for host permissions. TEST_F(PermissionMessageCombinationsUnittest, PackagedAppsHaveNoHostPermissions) { … } // Test various apps with lots of permissions, including those with no // permission messages, or those that only apply to apps or extensions even when // the given manifest is for a different type. TEST_F(PermissionMessageCombinationsUnittest, PermissionMessageCombos) { … } // Tests that the deprecated 'plugins' manifest key produces no permission. TEST_F(PermissionMessageCombinationsUnittest, PluginPermission) { … } TEST_F(PermissionMessageCombinationsUnittest, ClipboardPermissionMessages) { … } TEST_F(PermissionMessageCombinationsUnittest, NewTabPagePermissionMessages) { … } TEST_F(PermissionMessageCombinationsUnittest, DeclarativeNetRequestFeedbackPermissionMessages) { … } // TODO(sashab): Add a test that checks that messages are generated correctly // for withheld permissions, when an app is granted the 'all sites' permission. // TODO(sashab): Add a test that ensures that all permissions that can generate // a coalesced message can also generate a message on their own (i.e. ensure // that no permissions only modify other permissions). // TODO(sashab): Add a test for every permission message combination that can // generate a message. // TODO(aboxhall): Add tests for the automation API permission messages. } // namespace extensions