| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/strings/string_split.h" | |
| 8 #include "base/strings/string_util.h" | |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "base/test/values_test_util.h" | 7 #include "base/test/values_test_util.h" |
| 11 #include "chrome/browser/extensions/test_extension_environment.h" | 8 #include "chrome/browser/extensions/test_extension_environment.h" |
| 12 #include "chrome/common/extensions/permissions/chrome_permission_message_provide
r.h" | 9 #include "chrome/common/extensions/permissions/chrome_permission_message_provide
r.h" |
| 13 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
| 11 #include "extensions/common/permissions/permission_message_test_util.h" |
| 14 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
| 15 #include "extensions/common/switches.h" | 13 #include "extensions/common/switches.h" |
| 16 #include "testing/gmock/include/gmock/gmock-matchers.h" | 14 #include "testing/gmock/include/gmock/gmock-matchers.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 16 |
| 19 using testing::Contains; | |
| 20 using testing::Eq; | |
| 21 | |
| 22 namespace extensions { | 17 namespace extensions { |
| 23 | 18 |
| 24 // Tests that ChromePermissionMessageProvider produces the expected messages for | 19 // Tests that ChromePermissionMessageProvider produces the expected messages for |
| 25 // various combinations of app/extension permissions. | 20 // various combinations of app/extension permissions. |
| 26 class PermissionMessageCombinationsUnittest : public testing::Test { | 21 class PermissionMessageCombinationsUnittest : public testing::Test { |
| 27 public: | 22 public: |
| 28 PermissionMessageCombinationsUnittest() | 23 PermissionMessageCombinationsUnittest() |
| 29 : message_provider_(new ChromePermissionMessageProvider()) {} | 24 : message_provider_(new ChromePermissionMessageProvider()) {} |
| 30 ~PermissionMessageCombinationsUnittest() override {} | 25 ~PermissionMessageCombinationsUnittest() override {} |
| 31 | 26 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 *base::test::ParseJson(json_manifest_with_double_quotes)); | 42 *base::test::ParseJson(json_manifest_with_double_quotes)); |
| 48 // Add the app to any whitelists so we can test all permissions. | 43 // Add the app to any whitelists so we can test all permissions. |
| 49 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 44 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 50 switches::kWhitelistedExtensionID, app_->id()); | 45 switches::kWhitelistedExtensionID, app_->id()); |
| 51 } | 46 } |
| 52 | 47 |
| 53 // Checks whether the currently installed app or extension produces the given | 48 // Checks whether the currently installed app or extension produces the given |
| 54 // permission messages. Call this after installing an app with the expected | 49 // permission messages. Call this after installing an app with the expected |
| 55 // permission messages. The messages are tested for existence in any order. | 50 // permission messages. The messages are tested for existence in any order. |
| 56 testing::AssertionResult CheckManifestProducesPermissions() { | 51 testing::AssertionResult CheckManifestProducesPermissions() { |
| 57 return CheckManifestProducesPermissions( | 52 return VerifyNoPermissionMessages(app_->permissions_data()); |
| 58 std::vector<std::string>(), GetPermissionMessages(), | |
| 59 GetCoalescedPermissionMessages(), "messages"); | |
| 60 } | 53 } |
| 61 testing::AssertionResult CheckManifestProducesPermissions( | 54 testing::AssertionResult CheckManifestProducesPermissions( |
| 62 const std::string& expected_message_1) { | 55 const std::string& expected_message_1) { |
| 63 std::vector<std::string> expected_messages; | 56 return VerifyOnePermissionMessage(app_->permissions_data(), |
| 64 expected_messages.push_back(expected_message_1); | 57 expected_message_1); |
| 65 return CheckManifestProducesPermissions( | |
| 66 expected_messages, GetPermissionMessages(), | |
| 67 GetCoalescedPermissionMessages(), "messages"); | |
| 68 } | 58 } |
| 69 testing::AssertionResult CheckManifestProducesPermissions( | 59 testing::AssertionResult CheckManifestProducesPermissions( |
| 70 const std::string& expected_message_1, | 60 const std::string& expected_message_1, |
| 71 const std::string& expected_message_2) { | 61 const std::string& expected_message_2) { |
| 72 std::vector<std::string> expected_messages; | 62 return VerifyTwoPermissionMessages(app_->permissions_data(), |
| 73 expected_messages.push_back(expected_message_1); | 63 expected_message_1, |
| 74 expected_messages.push_back(expected_message_2); | 64 expected_message_2, |
| 75 return CheckManifestProducesPermissions( | 65 false); |
| 76 expected_messages, GetPermissionMessages(), | |
| 77 GetCoalescedPermissionMessages(), "messages"); | |
| 78 } | 66 } |
| 79 testing::AssertionResult CheckManifestProducesPermissions( | 67 testing::AssertionResult CheckManifestProducesPermissions( |
| 80 const std::string& expected_message_1, | 68 const std::string& expected_message_1, |
| 81 const std::string& expected_message_2, | 69 const std::string& expected_message_2, |
| 82 const std::string& expected_message_3) { | 70 const std::string& expected_message_3) { |
| 83 std::vector<std::string> expected_messages; | 71 std::vector<std::string> expected_messages; |
| 84 expected_messages.push_back(expected_message_1); | 72 expected_messages.push_back(expected_message_1); |
| 85 expected_messages.push_back(expected_message_2); | 73 expected_messages.push_back(expected_message_2); |
| 86 expected_messages.push_back(expected_message_3); | 74 expected_messages.push_back(expected_message_3); |
| 87 return CheckManifestProducesPermissions( | 75 return VerifyPermissionMessages(app_->permissions_data(), |
| 88 expected_messages, GetPermissionMessages(), | 76 expected_messages, |
| 89 GetCoalescedPermissionMessages(), "messages"); | 77 false); |
| 90 } | 78 } |
| 91 testing::AssertionResult CheckManifestProducesPermissions( | 79 testing::AssertionResult CheckManifestProducesPermissions( |
| 92 const std::string& expected_message_1, | 80 const std::string& expected_message_1, |
| 93 const std::string& expected_message_2, | 81 const std::string& expected_message_2, |
| 94 const std::string& expected_message_3, | 82 const std::string& expected_message_3, |
| 95 const std::string& expected_message_4) { | 83 const std::string& expected_message_4) { |
| 96 std::vector<std::string> expected_messages; | 84 std::vector<std::string> expected_messages; |
| 97 expected_messages.push_back(expected_message_1); | 85 expected_messages.push_back(expected_message_1); |
| 98 expected_messages.push_back(expected_message_2); | 86 expected_messages.push_back(expected_message_2); |
| 99 expected_messages.push_back(expected_message_3); | 87 expected_messages.push_back(expected_message_3); |
| 100 expected_messages.push_back(expected_message_4); | 88 expected_messages.push_back(expected_message_4); |
| 101 return CheckManifestProducesPermissions( | 89 return VerifyPermissionMessages(app_->permissions_data(), |
| 102 expected_messages, GetPermissionMessages(), | 90 expected_messages, |
| 103 GetCoalescedPermissionMessages(), "messages"); | 91 false); |
| 104 } | 92 } |
| 105 testing::AssertionResult CheckManifestProducesPermissions( | 93 testing::AssertionResult CheckManifestProducesPermissions( |
| 106 const std::string& expected_message_1, | 94 const std::string& expected_message_1, |
| 107 const std::string& expected_message_2, | 95 const std::string& expected_message_2, |
| 108 const std::string& expected_message_3, | 96 const std::string& expected_message_3, |
| 109 const std::string& expected_message_4, | 97 const std::string& expected_message_4, |
| 110 const std::string& expected_message_5) { | 98 const std::string& expected_message_5) { |
| 111 std::vector<std::string> expected_messages; | 99 std::vector<std::string> expected_messages; |
| 112 expected_messages.push_back(expected_message_1); | 100 expected_messages.push_back(expected_message_1); |
| 113 expected_messages.push_back(expected_message_2); | 101 expected_messages.push_back(expected_message_2); |
| 114 expected_messages.push_back(expected_message_3); | 102 expected_messages.push_back(expected_message_3); |
| 115 expected_messages.push_back(expected_message_4); | 103 expected_messages.push_back(expected_message_4); |
| 116 expected_messages.push_back(expected_message_5); | 104 expected_messages.push_back(expected_message_5); |
| 117 return CheckManifestProducesPermissions( | 105 return VerifyPermissionMessages(app_->permissions_data(), |
| 118 expected_messages, GetPermissionMessages(), | 106 expected_messages, |
| 119 GetCoalescedPermissionMessages(), "messages"); | 107 false); |
| 120 } | 108 } |
| 121 | 109 testing::AssertionResult CheckManifestProducesPermissions( |
| 122 // Checks whether the currently installed app or extension produces the given | 110 const std::string& expected_message_1, |
| 123 // host permission messages. Call this after installing an app with the | 111 const std::vector<std::string>& expected_submessages_1) { |
| 124 // expected permission messages. The messages are tested for existence in any | 112 return VerifyOnePermissionMessageWithSubmessages(app_->permissions_data(), |
| 125 // order. | 113 expected_message_1, |
| 126 testing::AssertionResult CheckManifestProducesHostPermissions() { | 114 expected_submessages_1); |
| 127 return CheckManifestProducesPermissions( | |
| 128 std::vector<std::string>(), GetHostPermissionMessages(), | |
| 129 GetCoalescedHostPermissionMessages(), "host messages"); | |
| 130 } | 115 } |
| 131 testing::AssertionResult CheckManifestProducesHostPermissions( | 116 testing::AssertionResult CheckManifestProducesPermissions( |
| 132 const std::string& expected_message_1) { | |
| 133 std::vector<std::string> expected_messages; | |
| 134 expected_messages.push_back(expected_message_1); | |
| 135 return CheckManifestProducesPermissions( | |
| 136 expected_messages, GetHostPermissionMessages(), | |
| 137 GetCoalescedHostPermissionMessages(), "host messages"); | |
| 138 } | |
| 139 testing::AssertionResult CheckManifestProducesHostPermissions( | |
| 140 const std::string& expected_message_1, | 117 const std::string& expected_message_1, |
| 141 const std::string& expected_message_2) { | 118 const std::vector<std::string>& expected_submessages_1, |
| 119 const std::string& expected_message_2, |
| 120 const std::vector<std::string>& expected_submessages_2) { |
| 142 std::vector<std::string> expected_messages; | 121 std::vector<std::string> expected_messages; |
| 143 expected_messages.push_back(expected_message_1); | 122 expected_messages.push_back(expected_message_1); |
| 144 expected_messages.push_back(expected_message_2); | 123 expected_messages.push_back(expected_message_2); |
| 145 return CheckManifestProducesPermissions( | 124 std::vector<std::vector<std::string>> expected_submessages; |
| 146 expected_messages, GetHostPermissionMessages(), | 125 expected_submessages.push_back(expected_submessages_1); |
| 147 GetCoalescedHostPermissionMessages(), "host messages"); | 126 expected_submessages.push_back(expected_submessages_2); |
| 127 return VerifyPermissionMessagesWithSubmessages(app_->permissions_data(), |
| 128 expected_messages, |
| 129 expected_submessages, |
| 130 false); |
| 148 } | 131 } |
| 149 testing::AssertionResult CheckManifestProducesHostPermissions( | 132 testing::AssertionResult CheckManifestProducesPermissions( |
| 150 const std::string& expected_message_1, | 133 const std::string& expected_message_1, |
| 134 const std::vector<std::string>& expected_submessages_1, |
| 151 const std::string& expected_message_2, | 135 const std::string& expected_message_2, |
| 152 const std::string& expected_message_3) { | 136 const std::vector<std::string>& expected_submessages_2, |
| 137 const std::string& expected_message_3, |
| 138 const std::vector<std::string>& expected_submessages_3) { |
| 153 std::vector<std::string> expected_messages; | 139 std::vector<std::string> expected_messages; |
| 154 expected_messages.push_back(expected_message_1); | 140 expected_messages.push_back(expected_message_1); |
| 155 expected_messages.push_back(expected_message_2); | 141 expected_messages.push_back(expected_message_2); |
| 156 expected_messages.push_back(expected_message_3); | 142 expected_messages.push_back(expected_message_3); |
| 157 return CheckManifestProducesPermissions( | 143 std::vector<std::vector<std::string>> expected_submessages; |
| 158 expected_messages, GetHostPermissionMessages(), | 144 expected_submessages.push_back(expected_submessages_1); |
| 159 GetCoalescedHostPermissionMessages(), "host messages"); | 145 expected_submessages.push_back(expected_submessages_2); |
| 146 expected_submessages.push_back(expected_submessages_3); |
| 147 return VerifyPermissionMessagesWithSubmessages(app_->permissions_data(), |
| 148 expected_messages, |
| 149 expected_submessages, |
| 150 false); |
| 160 } | 151 } |
| 161 testing::AssertionResult CheckManifestProducesHostPermissions( | 152 testing::AssertionResult CheckManifestProducesPermissions( |
| 162 const std::string& expected_message_1, | 153 const std::string& expected_message_1, |
| 154 const std::vector<std::string>& expected_submessages_1, |
| 163 const std::string& expected_message_2, | 155 const std::string& expected_message_2, |
| 156 const std::vector<std::string>& expected_submessages_2, |
| 164 const std::string& expected_message_3, | 157 const std::string& expected_message_3, |
| 165 const std::string& expected_message_4) { | 158 const std::vector<std::string>& expected_submessages_3, |
| 159 const std::string& expected_message_4, |
| 160 const std::vector<std::string>& expected_submessages_4) { |
| 166 std::vector<std::string> expected_messages; | 161 std::vector<std::string> expected_messages; |
| 167 expected_messages.push_back(expected_message_1); | 162 expected_messages.push_back(expected_message_1); |
| 168 expected_messages.push_back(expected_message_2); | 163 expected_messages.push_back(expected_message_2); |
| 169 expected_messages.push_back(expected_message_3); | 164 expected_messages.push_back(expected_message_3); |
| 170 expected_messages.push_back(expected_message_4); | 165 expected_messages.push_back(expected_message_4); |
| 171 return CheckManifestProducesPermissions( | 166 std::vector<std::vector<std::string>> expected_submessages; |
| 172 expected_messages, GetHostPermissionMessages(), | 167 expected_submessages.push_back(expected_submessages_1); |
| 173 GetCoalescedHostPermissionMessages(), "host messages"); | 168 expected_submessages.push_back(expected_submessages_2); |
| 169 expected_submessages.push_back(expected_submessages_3); |
| 170 expected_submessages.push_back(expected_submessages_4); |
| 171 return VerifyPermissionMessagesWithSubmessages(app_->permissions_data(), |
| 172 expected_messages, |
| 173 expected_submessages, |
| 174 false); |
| 174 } | 175 } |
| 175 testing::AssertionResult CheckManifestProducesHostPermissions( | 176 testing::AssertionResult CheckManifestProducesPermissions( |
| 176 const std::string& expected_message_1, | 177 const std::string& expected_message_1, |
| 178 const std::vector<std::string>& expected_submessages_1, |
| 177 const std::string& expected_message_2, | 179 const std::string& expected_message_2, |
| 180 const std::vector<std::string>& expected_submessages_2, |
| 178 const std::string& expected_message_3, | 181 const std::string& expected_message_3, |
| 182 const std::vector<std::string>& expected_submessages_3, |
| 179 const std::string& expected_message_4, | 183 const std::string& expected_message_4, |
| 180 const std::string& expected_message_5) { | 184 const std::vector<std::string>& expected_submessages_4, |
| 185 const std::string& expected_message_5, |
| 186 const std::vector<std::string>& expected_submessages_5) { |
| 181 std::vector<std::string> expected_messages; | 187 std::vector<std::string> expected_messages; |
| 182 expected_messages.push_back(expected_message_1); | 188 expected_messages.push_back(expected_message_1); |
| 183 expected_messages.push_back(expected_message_2); | 189 expected_messages.push_back(expected_message_2); |
| 184 expected_messages.push_back(expected_message_3); | 190 expected_messages.push_back(expected_message_3); |
| 185 expected_messages.push_back(expected_message_4); | 191 expected_messages.push_back(expected_message_4); |
| 186 expected_messages.push_back(expected_message_5); | 192 expected_messages.push_back(expected_message_5); |
| 187 return CheckManifestProducesPermissions( | 193 std::vector<std::vector<std::string>> expected_submessages; |
| 188 expected_messages, GetHostPermissionMessages(), | 194 expected_submessages.push_back(expected_submessages_1); |
| 189 GetCoalescedHostPermissionMessages(), "host messages"); | 195 expected_submessages.push_back(expected_submessages_2); |
| 196 expected_submessages.push_back(expected_submessages_3); |
| 197 expected_submessages.push_back(expected_submessages_4); |
| 198 expected_submessages.push_back(expected_submessages_5); |
| 199 return VerifyPermissionMessagesWithSubmessages(app_->permissions_data(), |
| 200 expected_messages, |
| 201 expected_submessages, |
| 202 false); |
| 190 } | 203 } |
| 191 | 204 |
| 192 private: | 205 private: |
| 193 std::vector<base::string16> GetPermissionMessages() { | |
| 194 return app_->permissions_data()->GetPermissionMessageStrings(); | |
| 195 } | |
| 196 | |
| 197 std::vector<base::string16> GetCoalescedPermissionMessages() { | |
| 198 CoalescedPermissionMessages messages = | |
| 199 app_->permissions_data()->GetCoalescedPermissionMessages(); | |
| 200 std::vector<base::string16> message_strings; | |
| 201 for (const auto& message : messages) { | |
| 202 message_strings.push_back(message.message()); | |
| 203 } | |
| 204 return message_strings; | |
| 205 } | |
| 206 | |
| 207 std::vector<base::string16> GetHostPermissionMessages() { | |
| 208 std::vector<base::string16> details = | |
| 209 app_->permissions_data()->GetPermissionMessageDetailsStrings(); | |
| 210 // If we have a host permission, exactly one message will contain the | |
| 211 // details for it. | |
| 212 for (const auto& host_string : details) { | |
| 213 if (!host_string.empty()) { | |
| 214 // The host_string will be a newline-separated string of entries. | |
| 215 std::vector<base::string16> pieces; | |
| 216 base::SplitString(host_string, base::char16('\n'), &pieces); | |
| 217 return pieces; | |
| 218 } | |
| 219 } | |
| 220 return std::vector<base::string16>(); | |
| 221 } | |
| 222 | |
| 223 std::vector<base::string16> GetCoalescedHostPermissionMessages() { | |
| 224 // If we have a host permission, exactly one message will contain the | |
| 225 // details for it. | |
| 226 CoalescedPermissionMessages messages = | |
| 227 app_->permissions_data()->GetCoalescedPermissionMessages(); | |
| 228 for (const auto& message : messages) { | |
| 229 if (!message.submessages().empty()) | |
| 230 return message.submessages(); | |
| 231 } | |
| 232 return std::vector<base::string16>(); | |
| 233 } | |
| 234 | |
| 235 // TODO(sashab): Remove the legacy messages from this function once the legacy | |
| 236 // messages system is no longer used. | |
| 237 testing::AssertionResult CheckManifestProducesPermissions( | |
| 238 const std::vector<std::string>& expected_messages, | |
| 239 const std::vector<base::string16>& actual_legacy_messages, | |
| 240 const std::vector<base::string16>& actual_messages, | |
| 241 const std::string& message_type_name) { | |
| 242 // Check the new messages system matches the legacy one. | |
| 243 if (actual_legacy_messages.size() != actual_messages.size()) { | |
| 244 // Message: Got 2 messages in the legacy system { "Bar", "Baz" }, but 0 in | |
| 245 // the new system {} | |
| 246 return testing::AssertionFailure() | |
| 247 << "Got " << actual_legacy_messages.size() << " " | |
| 248 << message_type_name << " in the legacy system " | |
| 249 << MessagesVectorToString(actual_legacy_messages) << ", but " | |
| 250 << actual_messages.size() << " in the new system " | |
| 251 << MessagesVectorToString(actual_messages); | |
| 252 } | |
| 253 | |
| 254 for (const auto& actual_message : actual_messages) { | |
| 255 if (std::find(actual_legacy_messages.begin(), | |
| 256 actual_legacy_messages.end(), | |
| 257 actual_message) == actual_legacy_messages.end()) { | |
| 258 // Message: Got { "Foo" } in the legacy messages system, but { "Bar", | |
| 259 // "Baz" } in the new system | |
| 260 return testing::AssertionFailure() | |
| 261 << "Got " << MessagesVectorToString(actual_legacy_messages) | |
| 262 << " in the legacy " << message_type_name << " system, but " | |
| 263 << MessagesVectorToString(actual_messages) | |
| 264 << " in the new system"; | |
| 265 } | |
| 266 } | |
| 267 | |
| 268 // Check the non-legacy & actual messages are equal. | |
| 269 if (expected_messages.size() != actual_messages.size()) { | |
| 270 // Message: Expected 7 messages, got 5 | |
| 271 return testing::AssertionFailure() | |
| 272 << "Expected " << expected_messages.size() << " " | |
| 273 << message_type_name << ", got " << actual_messages.size() << ": " | |
| 274 << MessagesVectorToString(actual_messages); | |
| 275 } | |
| 276 | |
| 277 for (const auto& expected_message : expected_messages) { | |
| 278 if (std::find(actual_messages.begin(), actual_messages.end(), | |
| 279 base::ASCIIToUTF16(expected_message)) == | |
| 280 actual_messages.end()) { | |
| 281 // Message: Expected messages to contain "Foo", got { "Bar", "Baz" } | |
| 282 return testing::AssertionFailure() | |
| 283 << "Expected " << message_type_name << " to contain \"" | |
| 284 << expected_message << "\", got " | |
| 285 << MessagesVectorToString(actual_messages); | |
| 286 } | |
| 287 } | |
| 288 | |
| 289 return testing::AssertionSuccess(); | |
| 290 } | |
| 291 | |
| 292 // Returns the vector of messages in a human-readable string format, e.g.: | |
| 293 // { "Bar", "Baz" } | |
| 294 base::string16 MessagesVectorToString( | |
| 295 const std::vector<base::string16>& messages) { | |
| 296 if (messages.empty()) | |
| 297 return base::ASCIIToUTF16("{}"); | |
| 298 return base::ASCIIToUTF16("{ \"") + | |
| 299 JoinString(messages, base::ASCIIToUTF16("\", \"")) + | |
| 300 base::ASCIIToUTF16("\" }"); | |
| 301 } | |
| 302 | |
| 303 extensions::TestExtensionEnvironment env_; | 206 extensions::TestExtensionEnvironment env_; |
| 304 scoped_ptr<ChromePermissionMessageProvider> message_provider_; | 207 scoped_ptr<ChromePermissionMessageProvider> message_provider_; |
| 305 scoped_refptr<const Extension> app_; | 208 scoped_refptr<const Extension> app_; |
| 306 | 209 |
| 307 DISALLOW_COPY_AND_ASSIGN(PermissionMessageCombinationsUnittest); | 210 DISALLOW_COPY_AND_ASSIGN(PermissionMessageCombinationsUnittest); |
| 308 }; | 211 }; |
| 309 | 212 |
| 310 // Test that the USB, Bluetooth and Serial permissions do not coalesce on their | 213 // Test that the USB, Bluetooth and Serial permissions do not coalesce on their |
| 311 // own, but do coalesce when more than 1 is present. | 214 // own, but do coalesce when more than 1 is present. |
| 312 TEST_F(PermissionMessageCombinationsUnittest, USBSerialBluetoothCoalescing) { | 215 TEST_F(PermissionMessageCombinationsUnittest, USBSerialBluetoothCoalescing) { |
| 313 // Test that the USB permission does not coalesce on its own. | 216 // Test that the USB permission does not coalesce on its own. |
| 314 CreateAndInstall( | 217 CreateAndInstall( |
| 315 "{" | 218 "{" |
| 316 " 'app': {" | 219 " 'app': {" |
| 317 " 'background': {" | 220 " 'background': {" |
| 318 " 'scripts': ['background.js']" | 221 " 'scripts': ['background.js']" |
| 319 " }" | 222 " }" |
| 320 " }," | 223 " }," |
| 321 " 'permissions': [" | 224 " 'permissions': [" |
| 322 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }" | 225 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }" |
| 323 " ]" | 226 " ]" |
| 324 "}"); | 227 "}"); |
| 325 ASSERT_TRUE(CheckManifestProducesPermissions( | 228 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 326 "Access USB devices from an unknown vendor")); | 229 "Access USB devices from an unknown vendor")); |
| 327 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 328 | 230 |
| 329 CreateAndInstall( | 231 CreateAndInstall( |
| 330 "{" | 232 "{" |
| 331 " 'app': {" | 233 " 'app': {" |
| 332 " 'background': {" | 234 " 'background': {" |
| 333 " 'scripts': ['background.js']" | 235 " 'scripts': ['background.js']" |
| 334 " }" | 236 " }" |
| 335 " }," | 237 " }," |
| 336 " 'permissions': [" | 238 " 'permissions': [" |
| 337 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }" | 239 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }" |
| 338 " ]" | 240 " ]" |
| 339 "}"); | 241 "}"); |
| 340 ASSERT_TRUE(CheckManifestProducesPermissions( | 242 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 341 "Access USB devices from an unknown vendor")); | 243 "Access USB devices from an unknown vendor")); |
| 342 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 343 | 244 |
| 344 // Test that the serial permission does not coalesce on its own. | 245 // Test that the serial permission does not coalesce on its own. |
| 345 CreateAndInstall( | 246 CreateAndInstall( |
| 346 "{" | 247 "{" |
| 347 " 'app': {" | 248 " 'app': {" |
| 348 " 'background': {" | 249 " 'background': {" |
| 349 " 'scripts': ['background.js']" | 250 " 'scripts': ['background.js']" |
| 350 " }" | 251 " }" |
| 351 " }," | 252 " }," |
| 352 " 'permissions': [" | 253 " 'permissions': [" |
| 353 " 'serial'" | 254 " 'serial'" |
| 354 " ]" | 255 " ]" |
| 355 "}"); | 256 "}"); |
| 356 ASSERT_TRUE(CheckManifestProducesPermissions("Access your serial devices")); | 257 ASSERT_TRUE(CheckManifestProducesPermissions("Access your serial devices")); |
| 357 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 358 | 258 |
| 359 // Test that the bluetooth permission does not coalesce on its own. | 259 // Test that the bluetooth permission does not coalesce on its own. |
| 360 CreateAndInstall( | 260 CreateAndInstall( |
| 361 "{" | 261 "{" |
| 362 " 'app': {" | 262 " 'app': {" |
| 363 " 'background': {" | 263 " 'background': {" |
| 364 " 'scripts': ['background.js']" | 264 " 'scripts': ['background.js']" |
| 365 " }" | 265 " }" |
| 366 " }," | 266 " }," |
| 367 " 'bluetooth': {}" | 267 " 'bluetooth': {}" |
| 368 "}"); | 268 "}"); |
| 369 ASSERT_TRUE(CheckManifestProducesPermissions( | 269 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 370 "Access information about Bluetooth devices paired with your system and " | 270 "Access information about Bluetooth devices paired with your system and " |
| 371 "discover nearby Bluetooth devices.")); | 271 "discover nearby Bluetooth devices.")); |
| 372 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 373 | 272 |
| 374 // Test that the bluetooth permission does not coalesce on its own, even | 273 // Test that the bluetooth permission does not coalesce on its own, even |
| 375 // when it specifies additional permissions. | 274 // when it specifies additional permissions. |
| 376 CreateAndInstall( | 275 CreateAndInstall( |
| 377 "{" | 276 "{" |
| 378 " 'app': {" | 277 " 'app': {" |
| 379 " 'background': {" | 278 " 'background': {" |
| 380 " 'scripts': ['background.js']" | 279 " 'scripts': ['background.js']" |
| 381 " }" | 280 " }" |
| 382 " }," | 281 " }," |
| 383 " 'bluetooth': {" | 282 " 'bluetooth': {" |
| 384 " 'uuids': ['1105', '1106']" | 283 " 'uuids': ['1105', '1106']" |
| 385 " }" | 284 " }" |
| 386 "}"); | 285 "}"); |
| 387 ASSERT_TRUE(CheckManifestProducesPermissions( | 286 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 388 "Access information about Bluetooth devices paired with your system and " | 287 "Access information about Bluetooth devices paired with your system and " |
| 389 "discover nearby Bluetooth devices.")); | 288 "discover nearby Bluetooth devices.")); |
| 390 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 391 | 289 |
| 392 // Test that the USB and Serial permissions coalesce. | 290 // Test that the USB and Serial permissions coalesce. |
| 393 CreateAndInstall( | 291 CreateAndInstall( |
| 394 "{" | 292 "{" |
| 395 " 'app': {" | 293 " 'app': {" |
| 396 " 'background': {" | 294 " 'background': {" |
| 397 " 'scripts': ['background.js']" | 295 " 'scripts': ['background.js']" |
| 398 " }" | 296 " }" |
| 399 " }," | 297 " }," |
| 400 " 'permissions': [" | 298 " 'permissions': [" |
| 401 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }," | 299 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }," |
| 402 " 'serial'" | 300 " 'serial'" |
| 403 " ]" | 301 " ]" |
| 404 "}"); | 302 "}"); |
| 405 ASSERT_TRUE(CheckManifestProducesPermissions( | 303 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 406 "Access USB devices from an unknown vendor", | 304 "Access USB devices from an unknown vendor", |
| 407 "Access your serial devices")); | 305 "Access your serial devices")); |
| 408 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 409 | 306 |
| 410 // Test that the USB, Serial and Bluetooth permissions coalesce. | 307 // Test that the USB, Serial and Bluetooth permissions coalesce. |
| 411 CreateAndInstall( | 308 CreateAndInstall( |
| 412 "{" | 309 "{" |
| 413 " 'app': {" | 310 " 'app': {" |
| 414 " 'background': {" | 311 " 'background': {" |
| 415 " 'scripts': ['background.js']" | 312 " 'scripts': ['background.js']" |
| 416 " }" | 313 " }" |
| 417 " }," | 314 " }," |
| 418 " 'permissions': [" | 315 " 'permissions': [" |
| 419 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }," | 316 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }," |
| 420 " 'serial'" | 317 " 'serial'" |
| 421 " ]," | 318 " ]," |
| 422 " 'bluetooth': {}" | 319 " 'bluetooth': {}" |
| 423 "}"); | 320 "}"); |
| 424 ASSERT_TRUE(CheckManifestProducesPermissions( | 321 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 425 "Access USB devices from an unknown vendor", | 322 "Access USB devices from an unknown vendor", |
| 426 "Access your Bluetooth and Serial devices")); | 323 "Access your Bluetooth and Serial devices")); |
| 427 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 428 | 324 |
| 429 // Test that the USB, Serial and Bluetooth permissions coalesce even when | 325 // Test that the USB, Serial and Bluetooth permissions coalesce even when |
| 430 // Bluetooth specifies multiple additional permissions. | 326 // Bluetooth specifies multiple additional permissions. |
| 431 CreateAndInstall( | 327 CreateAndInstall( |
| 432 "{" | 328 "{" |
| 433 " 'app': {" | 329 " 'app': {" |
| 434 " 'background': {" | 330 " 'background': {" |
| 435 " 'scripts': ['background.js']" | 331 " 'scripts': ['background.js']" |
| 436 " }" | 332 " }" |
| 437 " }," | 333 " }," |
| 438 " 'permissions': [" | 334 " 'permissions': [" |
| 439 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }," | 335 " { 'usbDevices': [{ 'vendorId': 123, 'productId': 456 }] }," |
| 440 " 'serial'" | 336 " 'serial'" |
| 441 " ]," | 337 " ]," |
| 442 " 'bluetooth': {" | 338 " 'bluetooth': {" |
| 443 " 'uuids': ['1105', '1106']," | 339 " 'uuids': ['1105', '1106']," |
| 444 " 'socket': true," | 340 " 'socket': true," |
| 445 " 'low_energy': true" | 341 " 'low_energy': true" |
| 446 " }" | 342 " }" |
| 447 "}"); | 343 "}"); |
| 448 ASSERT_TRUE(CheckManifestProducesPermissions( | 344 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 449 "Access USB devices from an unknown vendor", | 345 "Access USB devices from an unknown vendor", |
| 450 "Access your Bluetooth and Serial devices")); | 346 "Access your Bluetooth and Serial devices")); |
| 451 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 452 } | 347 } |
| 453 | 348 |
| 454 // Test that the History permission takes precedence over the Tabs permission, | 349 // Test that the History permission takes precedence over the Tabs permission, |
| 455 // and that the Sessions permission modifies this final message. | 350 // and that the Sessions permission modifies this final message. |
| 456 TEST_F(PermissionMessageCombinationsUnittest, TabsHistorySessionsCoalescing) { | 351 TEST_F(PermissionMessageCombinationsUnittest, TabsHistorySessionsCoalescing) { |
| 457 CreateAndInstall( | 352 CreateAndInstall( |
| 458 "{" | 353 "{" |
| 459 " 'permissions': [" | 354 " 'permissions': [" |
| 460 " 'tabs'" | 355 " 'tabs'" |
| 461 " ]" | 356 " ]" |
| 462 "}"); | 357 "}"); |
| 463 ASSERT_TRUE(CheckManifestProducesPermissions("Read your browsing history")); | 358 ASSERT_TRUE(CheckManifestProducesPermissions("Read your browsing history")); |
| 464 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 465 | 359 |
| 466 CreateAndInstall( | 360 CreateAndInstall( |
| 467 "{" | 361 "{" |
| 468 " 'permissions': [" | 362 " 'permissions': [" |
| 469 " 'tabs', 'sessions'" | 363 " 'tabs', 'sessions'" |
| 470 " ]" | 364 " ]" |
| 471 "}"); | 365 "}"); |
| 472 ASSERT_TRUE(CheckManifestProducesPermissions( | 366 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 473 "Read your browsing history on all your signed-in devices")); | 367 "Read your browsing history on all your signed-in devices")); |
| 474 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 475 | 368 |
| 476 CreateAndInstall( | 369 CreateAndInstall( |
| 477 "{" | 370 "{" |
| 478 " 'permissions': [" | 371 " 'permissions': [" |
| 479 " 'tabs', 'history'" | 372 " 'tabs', 'history'" |
| 480 " ]" | 373 " ]" |
| 481 "}"); | 374 "}"); |
| 482 ASSERT_TRUE(CheckManifestProducesPermissions( | 375 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 483 "Read and change your browsing history")); | 376 "Read and change your browsing history")); |
| 484 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 485 | 377 |
| 486 CreateAndInstall( | 378 CreateAndInstall( |
| 487 "{" | 379 "{" |
| 488 " 'permissions': [" | 380 " 'permissions': [" |
| 489 " 'tabs', 'history', 'sessions'" | 381 " 'tabs', 'history', 'sessions'" |
| 490 " ]" | 382 " ]" |
| 491 "}"); | 383 "}"); |
| 492 ASSERT_TRUE(CheckManifestProducesPermissions( | 384 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 493 "Read and change your browsing history on all your signed-in devices")); | 385 "Read and change your browsing history on all your signed-in devices")); |
| 494 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 495 } | 386 } |
| 496 | 387 |
| 497 // Test that the fileSystem permission produces no messages by itself, unless it | 388 // Test that the fileSystem permission produces no messages by itself, unless it |
| 498 // has both the 'write' and 'directory' additional permissions, in which case it | 389 // has both the 'write' and 'directory' additional permissions, in which case it |
| 499 // displays a message. | 390 // displays a message. |
| 500 TEST_F(PermissionMessageCombinationsUnittest, FileSystemReadWriteCoalescing) { | 391 TEST_F(PermissionMessageCombinationsUnittest, FileSystemReadWriteCoalescing) { |
| 501 CreateAndInstall( | 392 CreateAndInstall( |
| 502 "{" | 393 "{" |
| 503 " 'app': {" | 394 " 'app': {" |
| 504 " 'background': {" | 395 " 'background': {" |
| 505 " 'scripts': ['background.js']" | 396 " 'scripts': ['background.js']" |
| 506 " }" | 397 " }" |
| 507 " }," | 398 " }," |
| 508 " 'permissions': [" | 399 " 'permissions': [" |
| 509 " 'fileSystem'" | 400 " 'fileSystem'" |
| 510 " ]" | 401 " ]" |
| 511 "}"); | 402 "}"); |
| 512 ASSERT_TRUE(CheckManifestProducesPermissions()); | 403 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 513 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 514 | 404 |
| 515 CreateAndInstall( | 405 CreateAndInstall( |
| 516 "{" | 406 "{" |
| 517 " 'app': {" | 407 " 'app': {" |
| 518 " 'background': {" | 408 " 'background': {" |
| 519 " 'scripts': ['background.js']" | 409 " 'scripts': ['background.js']" |
| 520 " }" | 410 " }" |
| 521 " }," | 411 " }," |
| 522 " 'permissions': [" | 412 " 'permissions': [" |
| 523 " 'fileSystem', {'fileSystem': ['retainEntries', 'write']}" | 413 " 'fileSystem', {'fileSystem': ['retainEntries', 'write']}" |
| 524 " ]" | 414 " ]" |
| 525 "}"); | 415 "}"); |
| 526 ASSERT_TRUE(CheckManifestProducesPermissions()); | 416 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 527 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 528 | 417 |
| 529 CreateAndInstall( | 418 CreateAndInstall( |
| 530 "{" | 419 "{" |
| 531 " 'app': {" | 420 " 'app': {" |
| 532 " 'background': {" | 421 " 'background': {" |
| 533 " 'scripts': ['background.js']" | 422 " 'scripts': ['background.js']" |
| 534 " }" | 423 " }" |
| 535 " }," | 424 " }," |
| 536 " 'permissions': [" | 425 " 'permissions': [" |
| 537 " 'fileSystem', {'fileSystem': [" | 426 " 'fileSystem', {'fileSystem': [" |
| 538 " 'retainEntries', 'write', 'directory'" | 427 " 'retainEntries', 'write', 'directory'" |
| 539 " ]}" | 428 " ]}" |
| 540 " ]" | 429 " ]" |
| 541 "}"); | 430 "}"); |
| 542 ASSERT_TRUE(CheckManifestProducesPermissions( | 431 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 543 "Write to files and folders that you open in the application")); | 432 "Write to files and folders that you open in the application")); |
| 544 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 545 } | 433 } |
| 546 | 434 |
| 547 // Check that host permission messages are generated correctly when URLs are | 435 // Check that host permission messages are generated correctly when URLs are |
| 548 // entered as permissions. | 436 // entered as permissions. |
| 549 TEST_F(PermissionMessageCombinationsUnittest, HostsPermissionMessages) { | 437 TEST_F(PermissionMessageCombinationsUnittest, HostsPermissionMessages) { |
| 550 CreateAndInstall( | 438 CreateAndInstall( |
| 551 "{" | 439 "{" |
| 552 " 'permissions': [" | 440 " 'permissions': [" |
| 553 " 'http://www.blogger.com/'," | 441 " 'http://www.blogger.com/'," |
| 554 " ]" | 442 " ]" |
| 555 "}"); | 443 "}"); |
| 556 ASSERT_TRUE(CheckManifestProducesPermissions( | 444 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 557 "Read and change your data on www.blogger.com")); | 445 "Read and change your data on www.blogger.com")); |
| 558 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 559 | 446 |
| 560 CreateAndInstall( | 447 CreateAndInstall( |
| 561 "{" | 448 "{" |
| 562 " 'permissions': [" | 449 " 'permissions': [" |
| 563 " 'http://*.google.com/'," | 450 " 'http://*.google.com/'," |
| 564 " ]" | 451 " ]" |
| 565 "}"); | 452 "}"); |
| 566 ASSERT_TRUE(CheckManifestProducesPermissions( | 453 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 567 "Read and change your data on all google.com sites")); | 454 "Read and change your data on all google.com sites")); |
| 568 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 569 | 455 |
| 570 CreateAndInstall( | 456 CreateAndInstall( |
| 571 "{" | 457 "{" |
| 572 " 'permissions': [" | 458 " 'permissions': [" |
| 573 " 'http://www.blogger.com/'," | 459 " 'http://www.blogger.com/'," |
| 574 " 'http://*.google.com/'," | 460 " 'http://*.google.com/'," |
| 575 " ]" | 461 " ]" |
| 576 "}"); | 462 "}"); |
| 577 ASSERT_TRUE(CheckManifestProducesPermissions( | 463 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 578 "Read and change your data on all google.com sites and " | 464 "Read and change your data on all google.com sites and " |
| 579 "www.blogger.com")); | 465 "www.blogger.com")); |
| 580 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 581 | 466 |
| 582 CreateAndInstall( | 467 CreateAndInstall( |
| 583 "{" | 468 "{" |
| 584 " 'permissions': [" | 469 " 'permissions': [" |
| 585 " 'http://www.blogger.com/'," | 470 " 'http://www.blogger.com/'," |
| 586 " 'http://*.google.com/'," | 471 " 'http://*.google.com/'," |
| 587 " 'http://*.news.com/'," | 472 " 'http://*.news.com/'," |
| 588 " ]" | 473 " ]" |
| 589 "}"); | 474 "}"); |
| 590 ASSERT_TRUE(CheckManifestProducesPermissions( | 475 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 591 "Read and change your data on all google.com sites, all news.com sites, " | 476 "Read and change your data on all google.com sites, all news.com sites, " |
| 592 "and www.blogger.com")); | 477 "and www.blogger.com")); |
| 593 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 594 | 478 |
| 595 CreateAndInstall( | 479 CreateAndInstall( |
| 596 "{" | 480 "{" |
| 597 " 'permissions': [" | 481 " 'permissions': [" |
| 598 " 'http://www.blogger.com/'," | 482 " 'http://www.blogger.com/'," |
| 599 " 'http://*.google.com/'," | 483 " 'http://*.google.com/'," |
| 600 " 'http://*.news.com/'," | 484 " 'http://*.news.com/'," |
| 601 " 'http://www.foobar.com/'," | 485 " 'http://www.foobar.com/'," |
| 602 " ]" | 486 " ]" |
| 603 "}"); | 487 "}"); |
| 488 std::vector<std::string> submessages; |
| 489 submessages.push_back("All google.com sites"); |
| 490 submessages.push_back("All news.com sites"); |
| 491 submessages.push_back("www.blogger.com"); |
| 492 submessages.push_back("www.foobar.com"); |
| 604 ASSERT_TRUE(CheckManifestProducesPermissions( | 493 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 605 "Read and change your data on a number of websites")); | 494 "Read and change your data on a number of websites", submessages)); |
| 606 ASSERT_TRUE(CheckManifestProducesHostPermissions( | |
| 607 "All google.com sites", "All news.com sites", "www.blogger.com", | |
| 608 "www.foobar.com")); | |
| 609 | 495 |
| 610 CreateAndInstall( | 496 CreateAndInstall( |
| 611 "{" | 497 "{" |
| 612 " 'permissions': [" | 498 " 'permissions': [" |
| 613 " 'http://www.blogger.com/'," | 499 " 'http://www.blogger.com/'," |
| 614 " 'http://*.google.com/'," | 500 " 'http://*.google.com/'," |
| 615 " 'http://*.news.com/'," | 501 " 'http://*.news.com/'," |
| 616 " 'http://www.foobar.com/'," | 502 " 'http://www.foobar.com/'," |
| 617 " 'http://*.go.com/'," | 503 " 'http://*.go.com/'," |
| 618 " ]" | 504 " ]" |
| 619 "}"); | 505 "}"); |
| 506 submessages.clear(); |
| 507 submessages.push_back("All go.com sites"); |
| 508 submessages.push_back("All google.com sites"); |
| 509 submessages.push_back("All news.com sites"); |
| 510 submessages.push_back("www.blogger.com"); |
| 511 submessages.push_back("www.foobar.com"); |
| 620 ASSERT_TRUE(CheckManifestProducesPermissions( | 512 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 621 "Read and change your data on a number of websites")); | 513 "Read and change your data on a number of websites", submessages)); |
| 622 ASSERT_TRUE(CheckManifestProducesHostPermissions( | |
| 623 "All go.com sites", "All google.com sites", "All news.com sites", | |
| 624 "www.blogger.com", "www.foobar.com")); | |
| 625 | 514 |
| 626 CreateAndInstall( | 515 CreateAndInstall( |
| 627 "{" | 516 "{" |
| 628 " 'permissions': [" | 517 " 'permissions': [" |
| 629 " 'http://*.go.com/'," | 518 " 'http://*.go.com/'," |
| 630 " 'chrome://favicon/'," | 519 " 'chrome://favicon/'," |
| 631 " ]" | 520 " ]" |
| 632 "}"); | 521 "}"); |
| 633 ASSERT_TRUE(CheckManifestProducesPermissions( | 522 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 634 "Read and change your data on all go.com sites", | 523 "Read and change your data on all go.com sites", |
| 635 "Read the icons of the websites you visit")); | 524 "Read the icons of the websites you visit")); |
| 636 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 637 | 525 |
| 638 // Having the 'all sites' permission doesn't change the permission message, | 526 // Having the 'all sites' permission doesn't change the permission message, |
| 639 // since its pseudo-granted at runtime. | 527 // since its pseudo-granted at runtime. |
| 640 CreateAndInstall( | 528 CreateAndInstall( |
| 641 "{" | 529 "{" |
| 642 " 'permissions': [" | 530 " 'permissions': [" |
| 643 " 'http://*.go.com/'," | 531 " 'http://*.go.com/'," |
| 644 " 'chrome://favicon/'," | 532 " 'chrome://favicon/'," |
| 645 " 'http://*.*'," | 533 " 'http://*.*'," |
| 646 " ]" | 534 " ]" |
| 647 "}"); | 535 "}"); |
| 648 ASSERT_TRUE(CheckManifestProducesPermissions( | 536 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 649 "Read and change your data on all go.com sites", | 537 "Read and change your data on all go.com sites", |
| 650 "Read the icons of the websites you visit")); | 538 "Read the icons of the websites you visit")); |
| 651 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 652 } | 539 } |
| 653 | 540 |
| 654 // Check that permission messages are generated correctly for | 541 // Check that permission messages are generated correctly for |
| 655 // SocketsManifestPermission, which has host-like permission messages. | 542 // SocketsManifestPermission, which has host-like permission messages. |
| 656 TEST_F(PermissionMessageCombinationsUnittest, | 543 TEST_F(PermissionMessageCombinationsUnittest, |
| 657 SocketsManifestPermissionMessages) { | 544 SocketsManifestPermissionMessages) { |
| 658 CreateAndInstall( | 545 CreateAndInstall( |
| 659 "{" | 546 "{" |
| 660 " 'app': {" | 547 " 'app': {" |
| 661 " 'background': {" | 548 " 'background': {" |
| 662 " 'scripts': ['background.js']" | 549 " 'scripts': ['background.js']" |
| 663 " }" | 550 " }" |
| 664 " }," | 551 " }," |
| 665 " 'sockets': {" | 552 " 'sockets': {" |
| 666 " 'udp': {'send': '*'}," | 553 " 'udp': {'send': '*'}," |
| 667 " }" | 554 " }" |
| 668 "}"); | 555 "}"); |
| 669 ASSERT_TRUE(CheckManifestProducesPermissions( | 556 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 670 "Exchange data with any computer on the local network or internet")); | 557 "Exchange data with any computer on the local network or internet")); |
| 671 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 672 | 558 |
| 673 CreateAndInstall( | 559 CreateAndInstall( |
| 674 "{" | 560 "{" |
| 675 " 'app': {" | 561 " 'app': {" |
| 676 " 'background': {" | 562 " 'background': {" |
| 677 " 'scripts': ['background.js']" | 563 " 'scripts': ['background.js']" |
| 678 " }" | 564 " }" |
| 679 " }," | 565 " }," |
| 680 " 'sockets': {" | 566 " 'sockets': {" |
| 681 " 'udp': {'send': ':99'}," | 567 " 'udp': {'send': ':99'}," |
| 682 " }" | 568 " }" |
| 683 "}"); | 569 "}"); |
| 684 ASSERT_TRUE(CheckManifestProducesPermissions( | 570 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 685 "Exchange data with any computer on the local network or internet")); | 571 "Exchange data with any computer on the local network or internet")); |
| 686 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 687 | 572 |
| 688 CreateAndInstall( | 573 CreateAndInstall( |
| 689 "{" | 574 "{" |
| 690 " 'app': {" | 575 " 'app': {" |
| 691 " 'background': {" | 576 " 'background': {" |
| 692 " 'scripts': ['background.js']" | 577 " 'scripts': ['background.js']" |
| 693 " }" | 578 " }" |
| 694 " }," | 579 " }," |
| 695 " 'sockets': {" | 580 " 'sockets': {" |
| 696 " 'tcp': {'connect': '127.0.0.1:80'}," | 581 " 'tcp': {'connect': '127.0.0.1:80'}," |
| 697 " }" | 582 " }" |
| 698 "}"); | 583 "}"); |
| 699 ASSERT_TRUE(CheckManifestProducesPermissions( | 584 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 700 "Exchange data with the computer named 127.0.0.1")); | 585 "Exchange data with the computer named 127.0.0.1")); |
| 701 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 702 | 586 |
| 703 CreateAndInstall( | 587 CreateAndInstall( |
| 704 "{" | 588 "{" |
| 705 " 'app': {" | 589 " 'app': {" |
| 706 " 'background': {" | 590 " 'background': {" |
| 707 " 'scripts': ['background.js']" | 591 " 'scripts': ['background.js']" |
| 708 " }" | 592 " }" |
| 709 " }," | 593 " }," |
| 710 " 'sockets': {" | 594 " 'sockets': {" |
| 711 " 'tcp': {'connect': 'www.example.com:23'}," | 595 " 'tcp': {'connect': 'www.example.com:23'}," |
| 712 " }" | 596 " }" |
| 713 "}"); | 597 "}"); |
| 714 ASSERT_TRUE(CheckManifestProducesPermissions( | 598 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 715 "Exchange data with the computer named www.example.com")); | 599 "Exchange data with the computer named www.example.com")); |
| 716 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 717 | 600 |
| 718 CreateAndInstall( | 601 CreateAndInstall( |
| 719 "{" | 602 "{" |
| 720 " 'app': {" | 603 " 'app': {" |
| 721 " 'background': {" | 604 " 'background': {" |
| 722 " 'scripts': ['background.js']" | 605 " 'scripts': ['background.js']" |
| 723 " }" | 606 " }" |
| 724 " }," | 607 " }," |
| 725 " 'sockets': {" | 608 " 'sockets': {" |
| 726 " 'tcpServer': {'listen': '127.0.0.1:80'}" | 609 " 'tcpServer': {'listen': '127.0.0.1:80'}" |
| 727 " }" | 610 " }" |
| 728 "}"); | 611 "}"); |
| 729 ASSERT_TRUE(CheckManifestProducesPermissions( | 612 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 730 "Exchange data with the computer named 127.0.0.1")); | 613 "Exchange data with the computer named 127.0.0.1")); |
| 731 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 732 | 614 |
| 733 CreateAndInstall( | 615 CreateAndInstall( |
| 734 "{" | 616 "{" |
| 735 " 'app': {" | 617 " 'app': {" |
| 736 " 'background': {" | 618 " 'background': {" |
| 737 " 'scripts': ['background.js']" | 619 " 'scripts': ['background.js']" |
| 738 " }" | 620 " }" |
| 739 " }," | 621 " }," |
| 740 " 'sockets': {" | 622 " 'sockets': {" |
| 741 " 'tcpServer': {'listen': ':8080'}" | 623 " 'tcpServer': {'listen': ':8080'}" |
| 742 " }" | 624 " }" |
| 743 "}"); | 625 "}"); |
| 744 ASSERT_TRUE(CheckManifestProducesPermissions( | 626 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 745 "Exchange data with any computer on the local network or internet")); | 627 "Exchange data with any computer on the local network or internet")); |
| 746 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 747 | 628 |
| 748 CreateAndInstall( | 629 CreateAndInstall( |
| 749 "{" | 630 "{" |
| 750 " 'app': {" | 631 " 'app': {" |
| 751 " 'background': {" | 632 " 'background': {" |
| 752 " 'scripts': ['background.js']" | 633 " 'scripts': ['background.js']" |
| 753 " }" | 634 " }" |
| 754 " }," | 635 " }," |
| 755 " 'sockets': {" | 636 " 'sockets': {" |
| 756 " 'tcpServer': {" | 637 " 'tcpServer': {" |
| 757 " 'listen': [" | 638 " 'listen': [" |
| 758 " '127.0.0.1:80'," | 639 " '127.0.0.1:80'," |
| 759 " 'www.google.com'," | 640 " 'www.google.com'," |
| 760 " 'www.example.com:*'," | 641 " 'www.example.com:*'," |
| 761 " 'www.foo.com:200'," | 642 " 'www.foo.com:200'," |
| 762 " 'www.bar.com:200'" | 643 " 'www.bar.com:200'" |
| 763 " ]" | 644 " ]" |
| 764 " }" | 645 " }" |
| 765 " }" | 646 " }" |
| 766 "}"); | 647 "}"); |
| 767 ASSERT_TRUE(CheckManifestProducesPermissions( | 648 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 768 "Exchange data with the computers named: 127.0.0.1 www.bar.com " | 649 "Exchange data with the computers named: 127.0.0.1 www.bar.com " |
| 769 "www.example.com www.foo.com www.google.com")); | 650 "www.example.com www.foo.com www.google.com")); |
| 770 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 771 | 651 |
| 772 CreateAndInstall( | 652 CreateAndInstall( |
| 773 "{" | 653 "{" |
| 774 " 'app': {" | 654 " 'app': {" |
| 775 " 'background': {" | 655 " 'background': {" |
| 776 " 'scripts': ['background.js']" | 656 " 'scripts': ['background.js']" |
| 777 " }" | 657 " }" |
| 778 " }," | 658 " }," |
| 779 " 'sockets': {" | 659 " 'sockets': {" |
| 780 " 'tcp': {" | 660 " 'tcp': {" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 793 " 'www.example.com:*'," | 673 " 'www.example.com:*'," |
| 794 " 'www.foo.com:200'," | 674 " 'www.foo.com:200'," |
| 795 " ]" | 675 " ]" |
| 796 " }" | 676 " }" |
| 797 " }" | 677 " }" |
| 798 "}"); | 678 "}"); |
| 799 ASSERT_TRUE(CheckManifestProducesPermissions( | 679 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 800 "Exchange data with the computers named: 127.0.0.1 www.abc.com " | 680 "Exchange data with the computers named: 127.0.0.1 www.abc.com " |
| 801 "www.example.com www.foo.com www.freestuff.com www.google.com " | 681 "www.example.com www.foo.com www.freestuff.com www.google.com " |
| 802 "www.mywebsite.com www.test.com")); | 682 "www.mywebsite.com www.test.com")); |
| 803 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 804 | 683 |
| 805 CreateAndInstall( | 684 CreateAndInstall( |
| 806 "{" | 685 "{" |
| 807 " 'app': {" | 686 " 'app': {" |
| 808 " 'background': {" | 687 " 'background': {" |
| 809 " 'scripts': ['background.js']" | 688 " 'scripts': ['background.js']" |
| 810 " }" | 689 " }" |
| 811 " }," | 690 " }," |
| 812 " 'sockets': {" | 691 " 'sockets': {" |
| 813 " 'tcp': {'send': '*:*'}," | 692 " 'tcp': {'send': '*:*'}," |
| 814 " 'tcpServer': {'listen': '*:*'}," | 693 " 'tcpServer': {'listen': '*:*'}," |
| 815 " }" | 694 " }" |
| 816 "}"); | 695 "}"); |
| 817 ASSERT_TRUE(CheckManifestProducesPermissions( | 696 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 818 "Exchange data with any computer on the local network or internet")); | 697 "Exchange data with any computer on the local network or internet")); |
| 819 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 820 } | 698 } |
| 821 | 699 |
| 822 // Check that permission messages are generated correctly for | 700 // Check that permission messages are generated correctly for |
| 823 // MediaGalleriesPermission (an API permission with custom messages). | 701 // MediaGalleriesPermission (an API permission with custom messages). |
| 824 TEST_F(PermissionMessageCombinationsUnittest, | 702 TEST_F(PermissionMessageCombinationsUnittest, |
| 825 MediaGalleriesPermissionMessages) { | 703 MediaGalleriesPermissionMessages) { |
| 826 CreateAndInstall( | 704 CreateAndInstall( |
| 827 "{" | 705 "{" |
| 828 " 'app': {" | 706 " 'app': {" |
| 829 " 'background': {" | 707 " 'background': {" |
| 830 " 'scripts': ['background.js']" | 708 " 'scripts': ['background.js']" |
| 831 " }" | 709 " }" |
| 832 " }," | 710 " }," |
| 833 " 'permissions': [" | 711 " 'permissions': [" |
| 834 " { 'mediaGalleries': ['read'] }" | 712 " { 'mediaGalleries': ['read'] }" |
| 835 " ]" | 713 " ]" |
| 836 "}"); | 714 "}"); |
| 837 ASSERT_TRUE(CheckManifestProducesPermissions()); | 715 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 838 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 839 | 716 |
| 840 CreateAndInstall( | 717 CreateAndInstall( |
| 841 "{" | 718 "{" |
| 842 " 'app': {" | 719 " 'app': {" |
| 843 " 'background': {" | 720 " 'background': {" |
| 844 " 'scripts': ['background.js']" | 721 " 'scripts': ['background.js']" |
| 845 " }" | 722 " }" |
| 846 " }," | 723 " }," |
| 847 " 'permissions': [" | 724 " 'permissions': [" |
| 848 " { 'mediaGalleries': ['read', 'allAutoDetected'] }" | 725 " { 'mediaGalleries': ['read', 'allAutoDetected'] }" |
| 849 " ]" | 726 " ]" |
| 850 "}"); | 727 "}"); |
| 851 ASSERT_TRUE(CheckManifestProducesPermissions( | 728 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 852 "Access photos, music, and other media from your computer")); | 729 "Access photos, music, and other media from your computer")); |
| 853 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 854 | 730 |
| 855 // TODO(sashab): Add a test for the | 731 // TODO(sashab): Add a test for the |
| 856 // IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE message (generated | 732 // IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_WRITE message (generated |
| 857 // with the 'read' and 'copyTo' permissions, but not the 'delete' permission), | 733 // with the 'read' and 'copyTo' permissions, but not the 'delete' permission), |
| 858 // if it's possible to get this message. Otherwise, remove it from the code. | 734 // if it's possible to get this message. Otherwise, remove it from the code. |
| 859 | 735 |
| 860 CreateAndInstall( | 736 CreateAndInstall( |
| 861 "{" | 737 "{" |
| 862 " 'app': {" | 738 " 'app': {" |
| 863 " 'background': {" | 739 " 'background': {" |
| 864 " 'scripts': ['background.js']" | 740 " 'scripts': ['background.js']" |
| 865 " }" | 741 " }" |
| 866 " }," | 742 " }," |
| 867 " 'permissions': [" | 743 " 'permissions': [" |
| 868 " { 'mediaGalleries': ['read', 'delete', 'allAutoDetected'] }" | 744 " { 'mediaGalleries': ['read', 'delete', 'allAutoDetected'] }" |
| 869 " ]" | 745 " ]" |
| 870 "}"); | 746 "}"); |
| 871 ASSERT_TRUE(CheckManifestProducesPermissions( | 747 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 872 "Read and delete photos, music, and other media from your computer")); | 748 "Read and delete photos, music, and other media from your computer")); |
| 873 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 874 | 749 |
| 875 CreateAndInstall( | 750 CreateAndInstall( |
| 876 "{" | 751 "{" |
| 877 " 'app': {" | 752 " 'app': {" |
| 878 " 'background': {" | 753 " 'background': {" |
| 879 " 'scripts': ['background.js']" | 754 " 'scripts': ['background.js']" |
| 880 " }" | 755 " }" |
| 881 " }," | 756 " }," |
| 882 " 'permissions': [" | 757 " 'permissions': [" |
| 883 " { 'mediaGalleries':" | 758 " { 'mediaGalleries':" |
| 884 " [ 'read', 'delete', 'copyTo', 'allAutoDetected' ] }" | 759 " [ 'read', 'delete', 'copyTo', 'allAutoDetected' ] }" |
| 885 " ]" | 760 " ]" |
| 886 "}"); | 761 "}"); |
| 887 ASSERT_TRUE(CheckManifestProducesPermissions( | 762 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 888 "Read, change and delete photos, music, and other media from your " | 763 "Read, change and delete photos, music, and other media from your " |
| 889 "computer")); | 764 "computer")); |
| 890 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 891 | 765 |
| 892 // Without the allAutoDetected permission, there should be no install-time | 766 // Without the allAutoDetected permission, there should be no install-time |
| 893 // permission messages. | 767 // permission messages. |
| 894 CreateAndInstall( | 768 CreateAndInstall( |
| 895 "{" | 769 "{" |
| 896 " 'app': {" | 770 " 'app': {" |
| 897 " 'background': {" | 771 " 'background': {" |
| 898 " 'scripts': ['background.js']" | 772 " 'scripts': ['background.js']" |
| 899 " }" | 773 " }" |
| 900 " }," | 774 " }," |
| 901 " 'permissions': [" | 775 " 'permissions': [" |
| 902 " { 'mediaGalleries': ['read', 'delete', 'copyTo'] }" | 776 " { 'mediaGalleries': ['read', 'delete', 'copyTo'] }" |
| 903 " ]" | 777 " ]" |
| 904 "}"); | 778 "}"); |
| 905 ASSERT_TRUE(CheckManifestProducesPermissions()); | 779 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 906 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 907 } | 780 } |
| 908 | 781 |
| 909 // TODO(sashab): Add tests for SettingsOverrideAPIPermission (an API permission | 782 // TODO(sashab): Add tests for SettingsOverrideAPIPermission (an API permission |
| 910 // with custom messages). | 783 // with custom messages). |
| 911 | 784 |
| 912 // Check that permission messages are generated correctly for SocketPermission | 785 // Check that permission messages are generated correctly for SocketPermission |
| 913 // (an API permission with custom messages). | 786 // (an API permission with custom messages). |
| 914 TEST_F(PermissionMessageCombinationsUnittest, SocketPermissionMessages) { | 787 TEST_F(PermissionMessageCombinationsUnittest, SocketPermissionMessages) { |
| 915 CreateAndInstall( | 788 CreateAndInstall( |
| 916 "{" | 789 "{" |
| 917 " 'app': {" | 790 " 'app': {" |
| 918 " 'background': {" | 791 " 'background': {" |
| 919 " 'scripts': ['background.js']" | 792 " 'scripts': ['background.js']" |
| 920 " }" | 793 " }" |
| 921 " }," | 794 " }," |
| 922 " 'permissions': [" | 795 " 'permissions': [" |
| 923 " { 'socket': ['tcp-connect:*:*'] }" | 796 " { 'socket': ['tcp-connect:*:*'] }" |
| 924 " ]" | 797 " ]" |
| 925 "}"); | 798 "}"); |
| 926 ASSERT_TRUE(CheckManifestProducesPermissions( | 799 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 927 "Exchange data with any computer on the local network or internet")); | 800 "Exchange data with any computer on the local network or internet")); |
| 928 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 929 | 801 |
| 930 CreateAndInstall( | 802 CreateAndInstall( |
| 931 "{" | 803 "{" |
| 932 " 'app': {" | 804 " 'app': {" |
| 933 " 'background': {" | 805 " 'background': {" |
| 934 " 'scripts': ['background.js']" | 806 " 'scripts': ['background.js']" |
| 935 " }" | 807 " }" |
| 936 " }," | 808 " }," |
| 937 " 'permissions': [" | 809 " 'permissions': [" |
| 938 " { 'socket': [" | 810 " { 'socket': [" |
| 939 " 'tcp-connect:*:443'," | 811 " 'tcp-connect:*:443'," |
| 940 " 'tcp-connect:*:50032'," | 812 " 'tcp-connect:*:50032'," |
| 941 " 'tcp-connect:*:23'," | 813 " 'tcp-connect:*:23'," |
| 942 " ] }" | 814 " ] }" |
| 943 " ]" | 815 " ]" |
| 944 "}"); | 816 "}"); |
| 945 ASSERT_TRUE(CheckManifestProducesPermissions( | 817 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 946 "Exchange data with any computer on the local network or internet")); | 818 "Exchange data with any computer on the local network or internet")); |
| 947 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 948 | 819 |
| 949 CreateAndInstall( | 820 CreateAndInstall( |
| 950 "{" | 821 "{" |
| 951 " 'app': {" | 822 " 'app': {" |
| 952 " 'background': {" | 823 " 'background': {" |
| 953 " 'scripts': ['background.js']" | 824 " 'scripts': ['background.js']" |
| 954 " }" | 825 " }" |
| 955 " }," | 826 " }," |
| 956 " 'permissions': [" | 827 " 'permissions': [" |
| 957 " { 'socket': ['tcp-connect:foo.example.com:443'] }" | 828 " { 'socket': ['tcp-connect:foo.example.com:443'] }" |
| 958 " ]" | 829 " ]" |
| 959 "}"); | 830 "}"); |
| 960 ASSERT_TRUE(CheckManifestProducesPermissions( | 831 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 961 "Exchange data with the computer named foo.example.com")); | 832 "Exchange data with the computer named foo.example.com")); |
| 962 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 963 | 833 |
| 964 CreateAndInstall( | 834 CreateAndInstall( |
| 965 "{" | 835 "{" |
| 966 " 'app': {" | 836 " 'app': {" |
| 967 " 'background': {" | 837 " 'background': {" |
| 968 " 'scripts': ['background.js']" | 838 " 'scripts': ['background.js']" |
| 969 " }" | 839 " }" |
| 970 " }," | 840 " }," |
| 971 " 'permissions': [" | 841 " 'permissions': [" |
| 972 " { 'socket': ['tcp-connect:foo.example.com:443', 'udp-send-to'] }" | 842 " { 'socket': ['tcp-connect:foo.example.com:443', 'udp-send-to'] }" |
| 973 " ]" | 843 " ]" |
| 974 "}"); | 844 "}"); |
| 975 ASSERT_TRUE(CheckManifestProducesPermissions( | 845 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 976 "Exchange data with any computer on the local network or internet")); | 846 "Exchange data with any computer on the local network or internet")); |
| 977 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 978 | 847 |
| 979 CreateAndInstall( | 848 CreateAndInstall( |
| 980 "{" | 849 "{" |
| 981 " 'app': {" | 850 " 'app': {" |
| 982 " 'background': {" | 851 " 'background': {" |
| 983 " 'scripts': ['background.js']" | 852 " 'scripts': ['background.js']" |
| 984 " }" | 853 " }" |
| 985 " }," | 854 " }," |
| 986 " 'permissions': [" | 855 " 'permissions': [" |
| 987 " { 'socket': [" | 856 " { 'socket': [" |
| 988 " 'tcp-connect:foo.example.com:443'," | 857 " 'tcp-connect:foo.example.com:443'," |
| 989 " 'udp-send-to:test.ping.com:50032'," | 858 " 'udp-send-to:test.ping.com:50032'," |
| 990 " ] }" | 859 " ] }" |
| 991 " ]" | 860 " ]" |
| 992 "}"); | 861 "}"); |
| 993 ASSERT_TRUE(CheckManifestProducesPermissions( | 862 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 994 "Exchange data with the computers named: foo.example.com test.ping.com")); | 863 "Exchange data with the computers named: foo.example.com test.ping.com")); |
| 995 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 996 | 864 |
| 997 CreateAndInstall( | 865 CreateAndInstall( |
| 998 "{" | 866 "{" |
| 999 " 'app': {" | 867 " 'app': {" |
| 1000 " 'background': {" | 868 " 'background': {" |
| 1001 " 'scripts': ['background.js']" | 869 " 'scripts': ['background.js']" |
| 1002 " }" | 870 " }" |
| 1003 " }," | 871 " }," |
| 1004 " 'permissions': [" | 872 " 'permissions': [" |
| 1005 " { 'socket': [" | 873 " { 'socket': [" |
| 1006 " 'tcp-connect:foo.example.com:443'," | 874 " 'tcp-connect:foo.example.com:443'," |
| 1007 " 'udp-send-to:test.ping.com:50032'," | 875 " 'udp-send-to:test.ping.com:50032'," |
| 1008 " 'udp-send-to:www.ping.com:50032'," | 876 " 'udp-send-to:www.ping.com:50032'," |
| 1009 " 'udp-send-to:test2.ping.com:50032'," | 877 " 'udp-send-to:test2.ping.com:50032'," |
| 1010 " 'udp-bind:test.ping.com:50032'," | 878 " 'udp-bind:test.ping.com:50032'," |
| 1011 " ] }" | 879 " ] }" |
| 1012 " ]" | 880 " ]" |
| 1013 "}"); | 881 "}"); |
| 1014 ASSERT_TRUE(CheckManifestProducesPermissions( | 882 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1015 "Exchange data with the computers named: foo.example.com test.ping.com " | 883 "Exchange data with the computers named: foo.example.com test.ping.com " |
| 1016 "test2.ping.com www.ping.com")); | 884 "test2.ping.com www.ping.com")); |
| 1017 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1018 | 885 |
| 1019 CreateAndInstall( | 886 CreateAndInstall( |
| 1020 "{" | 887 "{" |
| 1021 " 'app': {" | 888 " 'app': {" |
| 1022 " 'background': {" | 889 " 'background': {" |
| 1023 " 'scripts': ['background.js']" | 890 " 'scripts': ['background.js']" |
| 1024 " }" | 891 " }" |
| 1025 " }," | 892 " }," |
| 1026 " 'permissions': [" | 893 " 'permissions': [" |
| 1027 " { 'socket': [" | 894 " { 'socket': [" |
| 1028 " 'tcp-connect:foo.example.com:443'," | 895 " 'tcp-connect:foo.example.com:443'," |
| 1029 " 'udp-send-to:test.ping.com:50032'," | 896 " 'udp-send-to:test.ping.com:50032'," |
| 1030 " 'tcp-connect:*:23'," | 897 " 'tcp-connect:*:23'," |
| 1031 " ] }" | 898 " ] }" |
| 1032 " ]" | 899 " ]" |
| 1033 "}"); | 900 "}"); |
| 1034 ASSERT_TRUE(CheckManifestProducesPermissions( | 901 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1035 "Exchange data with any computer on the local network or internet")); | 902 "Exchange data with any computer on the local network or internet")); |
| 1036 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1037 } | 903 } |
| 1038 | 904 |
| 1039 // Check that permission messages are generated correctly for | 905 // Check that permission messages are generated correctly for |
| 1040 // USBDevicePermission (an API permission with custom messages). | 906 // USBDevicePermission (an API permission with custom messages). |
| 1041 TEST_F(PermissionMessageCombinationsUnittest, USBDevicePermissionMessages) { | 907 TEST_F(PermissionMessageCombinationsUnittest, USBDevicePermissionMessages) { |
| 1042 CreateAndInstall( | 908 CreateAndInstall( |
| 1043 "{" | 909 "{" |
| 1044 " 'app': {" | 910 " 'app': {" |
| 1045 " 'background': {" | 911 " 'background': {" |
| 1046 " 'scripts': ['background.js']" | 912 " 'scripts': ['background.js']" |
| 1047 " }" | 913 " }" |
| 1048 " }," | 914 " }," |
| 1049 " 'permissions': [" | 915 " 'permissions': [" |
| 1050 " { 'usbDevices': [" | 916 " { 'usbDevices': [" |
| 1051 " { 'vendorId': 0, 'productId': 0 }," | 917 " { 'vendorId': 0, 'productId': 0 }," |
| 1052 " ] }" | 918 " ] }" |
| 1053 " ]" | 919 " ]" |
| 1054 "}"); | 920 "}"); |
| 1055 ASSERT_TRUE(CheckManifestProducesPermissions( | 921 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1056 "Access USB devices from an unknown vendor")); | 922 "Access USB devices from an unknown vendor")); |
| 1057 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1058 | 923 |
| 1059 CreateAndInstall( | 924 CreateAndInstall( |
| 1060 "{" | 925 "{" |
| 1061 " 'app': {" | 926 " 'app': {" |
| 1062 " 'background': {" | 927 " 'background': {" |
| 1063 " 'scripts': ['background.js']" | 928 " 'scripts': ['background.js']" |
| 1064 " }" | 929 " }" |
| 1065 " }," | 930 " }," |
| 1066 " 'permissions': [" | 931 " 'permissions': [" |
| 1067 " { 'usbDevices': [" | 932 " { 'usbDevices': [" |
| 1068 " { 'vendorId': 4179, 'productId': 529 }," | 933 " { 'vendorId': 4179, 'productId': 529 }," |
| 1069 " ] }" | 934 " ] }" |
| 1070 " ]" | 935 " ]" |
| 1071 "}"); | 936 "}"); |
| 1072 ASSERT_TRUE(CheckManifestProducesPermissions( | 937 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1073 "Access USB devices from Immanuel Electronics Co., Ltd")); | 938 "Access USB devices from Immanuel Electronics Co., Ltd")); |
| 1074 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1075 | 939 |
| 1076 CreateAndInstall( | 940 CreateAndInstall( |
| 1077 "{" | 941 "{" |
| 1078 " 'app': {" | 942 " 'app': {" |
| 1079 " 'background': {" | 943 " 'background': {" |
| 1080 " 'scripts': ['background.js']" | 944 " 'scripts': ['background.js']" |
| 1081 " }" | 945 " }" |
| 1082 " }," | 946 " }," |
| 1083 " 'permissions': [" | 947 " 'permissions': [" |
| 1084 " { 'usbDevices': [" | 948 " { 'usbDevices': [" |
| 1085 " { 'vendorId': 6353, 'productId': 8192 }," | 949 " { 'vendorId': 6353, 'productId': 8192 }," |
| 1086 " ] }" | 950 " ] }" |
| 1087 " ]" | 951 " ]" |
| 1088 "}"); | 952 "}"); |
| 1089 ASSERT_TRUE( | 953 ASSERT_TRUE( |
| 1090 CheckManifestProducesPermissions("Access USB devices from Google Inc.")); | 954 CheckManifestProducesPermissions("Access USB devices from Google Inc.")); |
| 1091 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1092 | 955 |
| 1093 CreateAndInstall( | 956 CreateAndInstall( |
| 1094 "{" | 957 "{" |
| 1095 " 'app': {" | 958 " 'app': {" |
| 1096 " 'background': {" | 959 " 'background': {" |
| 1097 " 'scripts': ['background.js']" | 960 " 'scripts': ['background.js']" |
| 1098 " }" | 961 " }" |
| 1099 " }," | 962 " }," |
| 1100 " 'permissions': [" | 963 " 'permissions': [" |
| 1101 " { 'usbDevices': [" | 964 " { 'usbDevices': [" |
| 1102 " { 'vendorId': 4179, 'productId': 529 }," | 965 " { 'vendorId': 4179, 'productId': 529 }," |
| 1103 " { 'vendorId': 6353, 'productId': 8192 }," | 966 " { 'vendorId': 6353, 'productId': 8192 }," |
| 1104 " ] }" | 967 " ] }" |
| 1105 " ]" | 968 " ]" |
| 1106 "}"); | 969 "}"); |
| 970 std::vector<std::string> submessages; |
| 971 submessages.push_back("unknown devices from Immanuel Electronics Co., Ltd"); |
| 972 submessages.push_back("unknown devices from Google Inc."); |
| 1107 ASSERT_TRUE( | 973 ASSERT_TRUE( |
| 1108 CheckManifestProducesPermissions("Access any of these USB devices")); | 974 CheckManifestProducesPermissions("Access any of these USB devices", |
| 1109 | 975 submessages)); |
| 1110 // Although technically not host permissions, devices are currently stored in | |
| 1111 // the 'host permissions' (details list) for the USB permission, in the same | |
| 1112 // format. | |
| 1113 // TODO(sashab): Rename host permissions to 'details list' or 'nested | |
| 1114 // permissions', and change this test system to allow specifying each message | |
| 1115 // as well as its corresponding nested messages, if any. Also add a test that | |
| 1116 // uses this to test an app with multiple nested permission lists (e.g. both | |
| 1117 // USB and host permissions). | |
| 1118 ASSERT_TRUE(CheckManifestProducesHostPermissions( | |
| 1119 "unknown devices from Immanuel Electronics Co., Ltd", | |
| 1120 "unknown devices from Google Inc.")); | |
| 1121 | 976 |
| 1122 // TODO(sashab): Add a test with a valid product/vendor USB device. | 977 // TODO(sashab): Add a test with a valid product/vendor USB device. |
| 1123 } | 978 } |
| 1124 | 979 |
| 1125 // Test that hosted apps are not given any messages for host permissions. | 980 // Test that hosted apps are not given any messages for host permissions. |
| 1126 TEST_F(PermissionMessageCombinationsUnittest, | 981 TEST_F(PermissionMessageCombinationsUnittest, |
| 1127 PackagedAppsHaveNoHostPermissions) { | 982 PackagedAppsHaveNoHostPermissions) { |
| 1128 CreateAndInstall( | 983 CreateAndInstall( |
| 1129 "{" | 984 "{" |
| 1130 " 'app': {" | 985 " 'app': {" |
| 1131 " 'background': {" | 986 " 'background': {" |
| 1132 " 'scripts': ['background.js']" | 987 " 'scripts': ['background.js']" |
| 1133 " }" | 988 " }" |
| 1134 " }," | 989 " }," |
| 1135 " 'permissions': [" | 990 " 'permissions': [" |
| 1136 " 'http://www.blogger.com/'," | 991 " 'http://www.blogger.com/'," |
| 1137 " 'http://*.google.com/'," | 992 " 'http://*.google.com/'," |
| 1138 " ]" | 993 " ]" |
| 1139 "}"); | 994 "}"); |
| 1140 ASSERT_TRUE(CheckManifestProducesPermissions()); | 995 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 1141 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1142 | 996 |
| 1143 CreateAndInstall( | 997 CreateAndInstall( |
| 1144 "{" | 998 "{" |
| 1145 " 'app': {" | 999 " 'app': {" |
| 1146 " 'background': {" | 1000 " 'background': {" |
| 1147 " 'scripts': ['background.js']" | 1001 " 'scripts': ['background.js']" |
| 1148 " }" | 1002 " }" |
| 1149 " }," | 1003 " }," |
| 1150 " 'permissions': [" | 1004 " 'permissions': [" |
| 1151 " 'serial'," | 1005 " 'serial'," |
| 1152 " 'http://www.blogger.com/'," | 1006 " 'http://www.blogger.com/'," |
| 1153 " 'http://*.google.com/'," | 1007 " 'http://*.google.com/'," |
| 1154 " ]" | 1008 " ]" |
| 1155 "}"); | 1009 "}"); |
| 1156 ASSERT_TRUE(CheckManifestProducesPermissions("Access your serial devices")); | 1010 ASSERT_TRUE(CheckManifestProducesPermissions("Access your serial devices")); |
| 1157 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1158 } | 1011 } |
| 1159 | 1012 |
| 1160 // Test various apps with lots of permissions, including those with no | 1013 // Test various apps with lots of permissions, including those with no |
| 1161 // permission messages, or those that only apply to apps or extensions even when | 1014 // permission messages, or those that only apply to apps or extensions even when |
| 1162 // the given manifest is for a different type. | 1015 // the given manifest is for a different type. |
| 1163 TEST_F(PermissionMessageCombinationsUnittest, PermissionMessageCombos) { | 1016 TEST_F(PermissionMessageCombinationsUnittest, PermissionMessageCombos) { |
| 1164 CreateAndInstall( | 1017 CreateAndInstall( |
| 1165 "{" | 1018 "{" |
| 1166 " 'permissions': [" | 1019 " 'permissions': [" |
| 1167 " 'tabs'," | 1020 " 'tabs'," |
| 1168 " 'bookmarks'," | 1021 " 'bookmarks'," |
| 1169 " 'http://www.blogger.com/'," | 1022 " 'http://www.blogger.com/'," |
| 1170 " 'http://*.google.com/'," | 1023 " 'http://*.google.com/'," |
| 1171 " 'unlimitedStorage'," | 1024 " 'unlimitedStorage'," |
| 1172 " ]" | 1025 " ]" |
| 1173 "}"); | 1026 "}"); |
| 1174 ASSERT_TRUE(CheckManifestProducesPermissions( | 1027 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1175 "Read and change your data on all google.com sites and www.blogger.com", | 1028 "Read and change your data on all google.com sites and www.blogger.com", |
| 1176 "Read your browsing history", "Read and change your bookmarks")); | 1029 "Read your browsing history", "Read and change your bookmarks")); |
| 1177 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1178 | 1030 |
| 1179 CreateAndInstall( | 1031 CreateAndInstall( |
| 1180 "{" | 1032 "{" |
| 1181 " 'permissions': [" | 1033 " 'permissions': [" |
| 1182 " 'tabs'," | 1034 " 'tabs'," |
| 1183 " 'sessions'," | 1035 " 'sessions'," |
| 1184 " 'bookmarks'," | 1036 " 'bookmarks'," |
| 1185 " 'unlimitedStorage'," | 1037 " 'unlimitedStorage'," |
| 1186 " 'syncFileSystem'," | 1038 " 'syncFileSystem'," |
| 1187 " 'http://www.blogger.com/'," | 1039 " 'http://www.blogger.com/'," |
| 1188 " 'http://*.google.com/'," | 1040 " 'http://*.google.com/'," |
| 1189 " 'http://*.news.com/'," | 1041 " 'http://*.news.com/'," |
| 1190 " 'http://www.foobar.com/'," | 1042 " 'http://www.foobar.com/'," |
| 1191 " 'http://*.go.com/'," | 1043 " 'http://*.go.com/'," |
| 1192 " ]" | 1044 " ]" |
| 1193 "}"); | 1045 "}"); |
| 1046 std::vector<std::string> submessages; |
| 1047 submessages.push_back("All go.com sites"); |
| 1048 submessages.push_back("All google.com sites"); |
| 1049 submessages.push_back("All news.com sites"); |
| 1050 submessages.push_back("www.blogger.com"); |
| 1051 submessages.push_back("www.foobar.com"); |
| 1194 ASSERT_TRUE(CheckManifestProducesPermissions( | 1052 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1195 "Read your browsing history on all your signed-in devices", | 1053 "Read your browsing history on all your signed-in devices", |
| 1054 std::vector<std::string>(), |
| 1196 "Read and change your bookmarks", | 1055 "Read and change your bookmarks", |
| 1197 "Read and change your data on a number of websites")); | 1056 std::vector<std::string>(), |
| 1198 ASSERT_TRUE(CheckManifestProducesHostPermissions( | 1057 "Read and change your data on a number of websites", |
| 1199 "All go.com sites", "All google.com sites", "All news.com sites", | 1058 submessages)); |
| 1200 "www.blogger.com", "www.foobar.com")); | |
| 1201 | 1059 |
| 1202 CreateAndInstall( | 1060 CreateAndInstall( |
| 1203 "{" | 1061 "{" |
| 1204 " 'permissions': [" | 1062 " 'permissions': [" |
| 1205 " 'tabs'," | 1063 " 'tabs'," |
| 1206 " 'sessions'," | 1064 " 'sessions'," |
| 1207 " 'bookmarks'," | 1065 " 'bookmarks'," |
| 1208 " 'accessibilityFeatures.read'," | 1066 " 'accessibilityFeatures.read'," |
| 1209 " 'accessibilityFeatures.modify'," | 1067 " 'accessibilityFeatures.modify'," |
| 1210 " 'alarms'," | 1068 " 'alarms'," |
| 1211 " 'browsingData'," | 1069 " 'browsingData'," |
| 1212 " 'cookies'," | 1070 " 'cookies'," |
| 1213 " 'desktopCapture'," | 1071 " 'desktopCapture'," |
| 1214 " 'gcm'," | 1072 " 'gcm'," |
| 1215 " 'topSites'," | 1073 " 'topSites'," |
| 1216 " 'storage'," | 1074 " 'storage'," |
| 1217 " 'unlimitedStorage'," | 1075 " 'unlimitedStorage'," |
| 1218 " 'syncFileSystem'," | 1076 " 'syncFileSystem'," |
| 1219 " 'http://www.blogger.com/'," | 1077 " 'http://www.blogger.com/'," |
| 1220 " 'http://*.google.com/'," | 1078 " 'http://*.google.com/'," |
| 1221 " 'http://*.news.com/'," | 1079 " 'http://*.news.com/'," |
| 1222 " 'http://www.foobar.com/'," | 1080 " 'http://www.foobar.com/'," |
| 1223 " 'http://*.go.com/'," | 1081 " 'http://*.go.com/'," |
| 1224 " ]" | 1082 " ]" |
| 1225 "}"); | 1083 "}"); |
| 1226 | 1084 |
| 1085 submessages.clear(); |
| 1086 submessages.push_back("All go.com sites"); |
| 1087 submessages.push_back("All google.com sites"); |
| 1088 submessages.push_back("All news.com sites"); |
| 1089 submessages.push_back("www.blogger.com"); |
| 1090 submessages.push_back("www.foobar.com"); |
| 1227 ASSERT_TRUE(CheckManifestProducesPermissions( | 1091 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1228 "Read your browsing history on all your signed-in devices", | 1092 "Read your browsing history on all your signed-in devices", |
| 1229 "Capture content of your screen", "Read and change your bookmarks", | 1093 std::vector<std::string>(), |
| 1094 "Capture content of your screen", |
| 1095 std::vector<std::string>(), |
| 1096 "Read and change your bookmarks", |
| 1097 std::vector<std::string>(), |
| 1230 "Read and change your data on a number of websites", | 1098 "Read and change your data on a number of websites", |
| 1231 "Read and change your accessibility settings")); | 1099 submessages, |
| 1232 | 1100 "Read and change your accessibility settings", |
| 1233 ASSERT_TRUE(CheckManifestProducesHostPermissions( | 1101 std::vector<std::string>())); |
| 1234 "All go.com sites", "All google.com sites", "All news.com sites", | |
| 1235 "www.blogger.com", "www.foobar.com")); | |
| 1236 | 1102 |
| 1237 // Create an App instead, ensuring that the host permission messages are not | 1103 // Create an App instead, ensuring that the host permission messages are not |
| 1238 // added. | 1104 // added. |
| 1239 CreateAndInstall( | 1105 CreateAndInstall( |
| 1240 "{" | 1106 "{" |
| 1241 " 'app': {" | 1107 " 'app': {" |
| 1242 " 'background': {" | 1108 " 'background': {" |
| 1243 " 'scripts': ['background.js']" | 1109 " 'scripts': ['background.js']" |
| 1244 " }" | 1110 " }" |
| 1245 " }," | 1111 " }," |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1264 " 'http://*.news.com/'," | 1130 " 'http://*.news.com/'," |
| 1265 " 'http://www.foobar.com/'," | 1131 " 'http://www.foobar.com/'," |
| 1266 " 'http://*.go.com/'," | 1132 " 'http://*.go.com/'," |
| 1267 " ]" | 1133 " ]" |
| 1268 "}"); | 1134 "}"); |
| 1269 | 1135 |
| 1270 ASSERT_TRUE(CheckManifestProducesPermissions( | 1136 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1271 "Access your serial devices", "Store data in your Google Drive account", | 1137 "Access your serial devices", "Store data in your Google Drive account", |
| 1272 "Read and change your accessibility settings")); | 1138 "Read and change your accessibility settings")); |
| 1273 | 1139 |
| 1274 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1275 } | 1140 } |
| 1276 | 1141 |
| 1277 // Tests that the 'plugin' manifest key produces the correct permission. | 1142 // Tests that the 'plugin' manifest key produces the correct permission. |
| 1278 TEST_F(PermissionMessageCombinationsUnittest, PluginPermission) { | 1143 TEST_F(PermissionMessageCombinationsUnittest, PluginPermission) { |
| 1279 // Extensions can have plugins. | 1144 // Extensions can have plugins. |
| 1280 CreateAndInstall( | 1145 CreateAndInstall( |
| 1281 "{" | 1146 "{" |
| 1282 " 'plugins': [" | 1147 " 'plugins': [" |
| 1283 " { 'path': 'extension_plugin.dll' }" | 1148 " { 'path': 'extension_plugin.dll' }" |
| 1284 " ]" | 1149 " ]" |
| 1285 "}"); | 1150 "}"); |
| 1286 | 1151 |
| 1287 #ifdef OS_CHROMEOS | 1152 #ifdef OS_CHROMEOS |
| 1288 ASSERT_TRUE(CheckManifestProducesPermissions()); | 1153 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 1289 #else | 1154 #else |
| 1290 ASSERT_TRUE(CheckManifestProducesPermissions( | 1155 ASSERT_TRUE(CheckManifestProducesPermissions( |
| 1291 "Read and change all your data on your computer and the websites you " | 1156 "Read and change all your data on your computer and the websites you " |
| 1292 "visit")); | 1157 "visit")); |
| 1293 #endif | 1158 #endif |
| 1294 | 1159 |
| 1295 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1296 | |
| 1297 // Apps can't have plugins. | 1160 // Apps can't have plugins. |
| 1298 CreateAndInstall( | 1161 CreateAndInstall( |
| 1299 "{" | 1162 "{" |
| 1300 " 'app': {" | 1163 " 'app': {" |
| 1301 " 'background': {" | 1164 " 'background': {" |
| 1302 " 'scripts': ['background.js']" | 1165 " 'scripts': ['background.js']" |
| 1303 " }" | 1166 " }" |
| 1304 " }," | 1167 " }," |
| 1305 " 'plugins': [" | 1168 " 'plugins': [" |
| 1306 " { 'path': 'extension_plugin.dll' }" | 1169 " { 'path': 'extension_plugin.dll' }" |
| 1307 " ]" | 1170 " ]" |
| 1308 "}"); | 1171 "}"); |
| 1309 ASSERT_TRUE(CheckManifestProducesPermissions()); | 1172 ASSERT_TRUE(CheckManifestProducesPermissions()); |
| 1310 ASSERT_TRUE(CheckManifestProducesHostPermissions()); | |
| 1311 } | 1173 } |
| 1312 | 1174 |
| 1313 // TODO(sashab): Add a test that checks that messages are generated correctly | 1175 // TODO(sashab): Add a test that checks that messages are generated correctly |
| 1314 // for withheld permissions, when an app is granted the 'all sites' permission. | 1176 // for withheld permissions, when an app is granted the 'all sites' permission. |
| 1315 | 1177 |
| 1316 // TODO(sashab): Add a test that ensures that all permissions that can generate | 1178 // TODO(sashab): Add a test that ensures that all permissions that can generate |
| 1317 // a coalesced message can also generate a message on their own (i.e. ensure | 1179 // a coalesced message can also generate a message on their own (i.e. ensure |
| 1318 // that no permissions only modify other permissions). | 1180 // that no permissions only modify other permissions). |
| 1319 | 1181 |
| 1320 // TODO(sashab): Add a test for every permission message combination that can | 1182 // TODO(sashab): Add a test for every permission message combination that can |
| 1321 // generate a message. | 1183 // generate a message. |
| 1322 | 1184 |
| 1323 // TODO(aboxhall): Add tests for the automation API permission messages. | 1185 // TODO(aboxhall): Add tests for the automation API permission messages. |
| 1324 | 1186 |
| 1325 } // namespace extensions | 1187 } // namespace extensions |
| OLD | NEW |