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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc

Issue 1047943002: Cache --whitelisted-extension-id in SimpleFeature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests that fail on memory bots. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/json/json_file_value_serializer.h" 6 #include "base/json/json_file_value_serializer.h"
7 #include "base/memory/linked_ptr.h" 7 #include "base/memory/linked_ptr.h"
8 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" 8 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
9 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" 9 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
10 #include "extensions/common/error_utils.h" 10 #include "extensions/common/error_utils.h"
11 #include "extensions/common/features/simple_feature.h"
11 #include "extensions/common/manifest_constants.h" 12 #include "extensions/common/manifest_constants.h"
12 #include "extensions/common/manifest_handlers/csp_info.h" 13 #include "extensions/common/manifest_handlers/csp_info.h"
13 #include "extensions/common/manifest_handlers/incognito_info.h" 14 #include "extensions/common/manifest_handlers/incognito_info.h"
14 #include "extensions/common/switches.h" 15 #include "extensions/common/switches.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace extensions { 18 namespace extensions {
18 19
19 namespace errors = manifest_errors; 20 namespace errors = manifest_errors;
20 21
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 Testcase( 75 Testcase(
75 "init_platform_app_csp_warning_2.json", 76 "init_platform_app_csp_warning_2.json",
76 "'app.content_security_policy' is not allowed for specified extension " 77 "'app.content_security_policy' is not allowed for specified extension "
77 "ID.") 78 "ID.")
78 }; 79 };
79 RunTestcases( 80 RunTestcases(
80 warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING); 81 warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING);
81 82
82 // Whitelisted ones can (this is the ID corresponding to the base 64 encoded 83 // Whitelisted ones can (this is the ID corresponding to the base 64 encoded
83 // key in the init_platform_app_csp.json manifest.) 84 // key in the init_platform_app_csp.json manifest.)
84 std::string test_id = "ahplfneplbnjcflhdgkkjeiglkkfeelb"; 85 extensions::SimpleFeature::ScopedWhitelistForTest whitelist(
85 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 86 "ahplfneplbnjcflhdgkkjeiglkkfeelb");
86 switches::kWhitelistedExtensionID, test_id);
87 scoped_refptr<Extension> extension = 87 scoped_refptr<Extension> extension =
88 LoadAndExpectSuccess("init_platform_app_csp.json"); 88 LoadAndExpectSuccess("init_platform_app_csp.json");
89 EXPECT_EQ(0U, extension->install_warnings().size()) 89 EXPECT_EQ(0U, extension->install_warnings().size())
90 << "Unexpected warning " << extension->install_warnings()[0].message; 90 << "Unexpected warning " << extension->install_warnings()[0].message;
91 EXPECT_TRUE(extension->is_platform_app()); 91 EXPECT_TRUE(extension->is_platform_app());
92 EXPECT_EQ("default-src 'self' https://www.google.com;", 92 EXPECT_EQ("default-src 'self' https://www.google.com;",
93 CSPInfo::GetResourceContentSecurityPolicy(extension.get(), 93 CSPInfo::GetResourceContentSecurityPolicy(extension.get(),
94 std::string())); 94 std::string()));
95 95
96 // But even whitelisted ones must specify a secure policy. 96 // But even whitelisted ones must specify a secure policy.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 // Now try again with the experimental flag set. 141 // Now try again with the experimental flag set.
142 base::CommandLine::ForCurrentProcess()->AppendSwitch( 142 base::CommandLine::ForCurrentProcess()->AppendSwitch(
143 switches::kEnableExperimentalExtensionApis); 143 switches::kEnableExperimentalExtensionApis);
144 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { 144 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) {
145 LoadAndExpectSuccess(ManifestData(manifests[i].get(), "")); 145 LoadAndExpectSuccess(ManifestData(manifests[i].get(), ""));
146 } 146 }
147 } 147 }
148 148
149 } // namespace extensions 149 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698