| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 extension = LoadManifest("socket_permissions", "empty.json"); | 125 extension = LoadManifest("socket_permissions", "empty.json"); |
| 126 EXPECT_FALSE(CheckSocketPermission(extension, | 126 EXPECT_FALSE(CheckSocketPermission(extension, |
| 127 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); | 127 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); |
| 128 | 128 |
| 129 extension = LoadManifestUnchecked("socket_permissions", | 129 extension = LoadManifestUnchecked("socket_permissions", |
| 130 "socket1.json", | 130 "socket1.json", |
| 131 Manifest::INTERNAL, Extension::NO_FLAGS, | 131 Manifest::INTERNAL, Extension::NO_FLAGS, |
| 132 &error); | 132 &error); |
| 133 EXPECT_TRUE(extension.get() == NULL); | 133 EXPECT_TRUE(extension.get() == NULL); |
| 134 ASSERT_EQ(ErrorUtils::FormatErrorMessage( | 134 std::string expected_error_msg_header = ErrorUtils::FormatErrorMessage( |
| 135 manifest_errors::kInvalidPermission, "socket"), | 135 manifest_errors::kInvalidPermissionWithDetail, |
| 136 error); | 136 "socket", |
| 137 "NULL or empty permission list"); |
| 138 EXPECT_EQ(expected_error_msg_header, error); |
| 137 | 139 |
| 138 extension = LoadManifest("socket_permissions", "socket2.json"); | 140 extension = LoadManifest("socket_permissions", "socket2.json"); |
| 139 EXPECT_TRUE(CheckSocketPermission(extension, | 141 EXPECT_TRUE(CheckSocketPermission(extension, |
| 140 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); | 142 SocketPermissionRequest::TCP_CONNECT, "www.example.com", 80)); |
| 141 EXPECT_FALSE(CheckSocketPermission( | 143 EXPECT_FALSE(CheckSocketPermission( |
| 142 extension, SocketPermissionRequest::UDP_BIND, "", 80)); | 144 extension, SocketPermissionRequest::UDP_BIND, "", 80)); |
| 143 EXPECT_TRUE(CheckSocketPermission( | 145 EXPECT_TRUE(CheckSocketPermission( |
| 144 extension, SocketPermissionRequest::UDP_BIND, "", 8888)); | 146 extension, SocketPermissionRequest::UDP_BIND, "", 8888)); |
| 145 | 147 |
| 146 EXPECT_FALSE(CheckSocketPermission( | 148 EXPECT_FALSE(CheckSocketPermission( |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 PermissionsData::ClearTabSpecificPermissions(extension.get(), 1); | 632 PermissionsData::ClearTabSpecificPermissions(extension.get(), 1); |
| 631 EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 1) | 633 EXPECT_FALSE(PermissionsData::GetTabSpecificPermissions(extension.get(), 1) |
| 632 .get()); | 634 .get()); |
| 633 | 635 |
| 634 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); | 636 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); |
| 635 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); | 637 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); |
| 636 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); | 638 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); |
| 637 } | 639 } |
| 638 | 640 |
| 639 } // namespace extensions | 641 } // namespace extensions |
| OLD | NEW |