[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 5 | #include <stddef.h> |
| 6 | |
dcheng | c963c714 | 2016-04-08 03:55:22 | [diff] [blame] | 7 | #include <memory> |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 8 | #include <string> |
vabr | 9984ea6 | 2017-04-10 11:33:49 | [diff] [blame] | 9 | #include <utility> |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 10 | |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 11 | #include "base/command_line.h" |
thestig | c9e38a2 | 2014-09-13 01:02:11 | [diff] [blame] | 12 | #include "base/files/file_util.h" |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 13 | #include "base/path_service.h" |
fdoray | cb32419d | 2016-06-23 15:52:55 | [diff] [blame] | 14 | #include "base/run_loop.h" |
Avi Drissman | 5f0fb8c | 2018-12-25 23:20:49 | [diff] [blame] | 15 | #include "base/stl_util.h" |
[email protected] | 774cebd | 2013-09-26 04:55:01 | [diff] [blame] | 16 | #include "base/strings/string_number_conversions.h" |
[email protected] | 00e7bef | 2013-06-10 20:35:17 | [diff] [blame] | 17 | #include "base/strings/string_util.h" |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 18 | #include "base/test/power_monitor_test_base.h" |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 19 | #include "base/test/test_file_util.h" |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 20 | #include "base/test/values_test_util.h" |
[email protected] | 06492ed | 2013-03-24 22:13:14 | [diff] [blame] | 21 | #include "base/values.h" |
Kevin Marshall | 4cab5af | 2019-01-14 20:27:14 | [diff] [blame] | 22 | #include "build/build_config.h" |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 23 | #include "chrome/browser/extensions/chrome_content_verifier_delegate.h" |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 24 | #include "chrome/common/chrome_paths.h" |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 25 | #include "chrome/common/chrome_switches.h" |
| 26 | #include "chrome/test/base/testing_profile.h" |
| 27 | #include "components/crx_file/id_util.h" |
Matt Falkenhagen | ae65b29 | 2018-04-25 16:03:27 | [diff] [blame] | 28 | #include "content/public/browser/render_process_host.h" |
megjablon | caf312f | 2017-01-12 18:47:49 | [diff] [blame] | 29 | #include "content/public/common/previews_state.h" |
Gabriel Charette | c710874 | 2019-08-23 03:31:40 | [diff] [blame] | 30 | #include "content/public/test/browser_task_environment.h" |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 31 | #include "content/public/test/test_renderer_host.h" |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 32 | #include "content/public/test/test_utils.h" |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 33 | #include "content/public/test/web_contents_tester.h" |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 34 | #include "extensions/browser/content_verifier.h" |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 35 | #include "extensions/browser/content_verifier/test_utils.h" |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 36 | #include "extensions/browser/extension_prefs.h" |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 37 | #include "extensions/browser/extension_protocols.h" |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 38 | #include "extensions/browser/extension_registry.h" |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 39 | #include "extensions/browser/extension_system.h" |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 40 | #include "extensions/browser/info_map.h" |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 41 | #include "extensions/common/constants.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 42 | #include "extensions/common/extension.h" |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 43 | #include "extensions/common/extension_builder.h" |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 44 | #include "extensions/common/extension_paths.h" |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 45 | #include "extensions/common/file_util.h" |
Devlin Cronin | 1fa235b6 | 2018-04-12 14:04:07 | [diff] [blame] | 46 | #include "extensions/common/value_builder.h" |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 47 | #include "extensions/test/test_extension_dir.h" |
Julie Jeongeun Kim | 917c19790 | 2019-11-26 03:36:14 | [diff] [blame^] | 48 | #include "mojo/public/cpp/bindings/pending_remote.h" |
rhalavati | 04b9338 | 2017-04-07 19:00:54 | [diff] [blame] | 49 | #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 50 | #include "services/network/test/test_url_loader_client.h" |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 51 | #include "testing/gtest/include/gtest/gtest.h" |
| 52 | |
[email protected] | 7491ad0 | 2014-07-05 19:10:07 | [diff] [blame] | 53 | using content::ResourceType; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 54 | using extensions::ExtensionRegistry; |
| 55 | using network::mojom::URLLoader; |
[email protected] | 7491ad0 | 2014-07-05 19:10:07 | [diff] [blame] | 56 | |
[email protected] | 702d8b4 | 2013-02-27 20:55:50 | [diff] [blame] | 57 | namespace extensions { |
jamescook | 8816ae5 | 2014-09-05 17:02:37 | [diff] [blame] | 58 | namespace { |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 59 | |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 60 | base::FilePath GetTestPath(const std::string& name) { |
| 61 | base::FilePath path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 62 | EXPECT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &path)); |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 63 | return path.AppendASCII("extensions").AppendASCII(name); |
| 64 | } |
| 65 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 66 | base::FilePath GetContentVerifierTestPath() { |
| 67 | base::FilePath path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 68 | EXPECT_TRUE(base::PathService::Get(extensions::DIR_TEST_DATA, &path)); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 69 | return path.AppendASCII("content_hash_fetcher") |
| 70 | .AppendASCII("different_sized_files"); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 71 | } |
| 72 | |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 73 | scoped_refptr<Extension> CreateTestExtension(const std::string& name, |
| 74 | bool incognito_split_mode) { |
[email protected] | 023b3d1 | 2013-12-23 18:46:49 | [diff] [blame] | 75 | base::DictionaryValue manifest; |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 76 | manifest.SetString("name", name); |
| 77 | manifest.SetString("version", "1"); |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 78 | manifest.SetInteger("manifest_version", 2); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 79 | manifest.SetString("incognito", incognito_split_mode ? "split" : "spanning"); |
| 80 | |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 81 | base::FilePath path = GetTestPath("response_headers"); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 82 | |
| 83 | std::string error; |
| 84 | scoped_refptr<Extension> extension( |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 85 | Extension::Create(path, Manifest::INTERNAL, manifest, |
[email protected] | ed3b9b1 | 2012-05-31 18:37:51 | [diff] [blame] | 86 | Extension::NO_FLAGS, &error)); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 87 | EXPECT_TRUE(extension.get()) << error; |
| 88 | return extension; |
| 89 | } |
| 90 | |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 91 | scoped_refptr<Extension> CreateWebStoreExtension() { |
Devlin Cronin | f43c331 | 2018-03-27 19:54:17 | [diff] [blame] | 92 | std::unique_ptr<base::DictionaryValue> manifest = |
| 93 | DictionaryBuilder() |
| 94 | .Set("name", "WebStore") |
| 95 | .Set("version", "1") |
| 96 | .Set("manifest_version", 2) |
| 97 | .Set("icons", |
| 98 | DictionaryBuilder().Set("16", "webstore_icon_16.png").Build()) |
| 99 | .Set("web_accessible_resources", |
| 100 | ListBuilder().Append("webstore_icon_16.png").Build()) |
| 101 | .Build(); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 102 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 103 | base::FilePath path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 104 | EXPECT_TRUE(base::PathService::Get(chrome::DIR_RESOURCES, &path)); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 105 | path = path.AppendASCII("web_store"); |
| 106 | |
| 107 | std::string error; |
Devlin Cronin | f43c331 | 2018-03-27 19:54:17 | [diff] [blame] | 108 | scoped_refptr<Extension> extension(Extension::Create( |
| 109 | path, Manifest::COMPONENT, *manifest, Extension::NO_FLAGS, &error)); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 110 | EXPECT_TRUE(extension.get()) << error; |
| 111 | return extension; |
| 112 | } |
| 113 | |
Devlin Cronin | 8e5892f | 2018-10-04 00:13:43 | [diff] [blame] | 114 | scoped_refptr<const Extension> CreateTestResponseHeaderExtension() { |
Devlin Cronin | 1fa235b6 | 2018-04-12 14:04:07 | [diff] [blame] | 115 | return ExtensionBuilder("An extension with web-accessible resources") |
Devlin Cronin | 98cd658 | 2018-05-08 19:18:12 | [diff] [blame] | 116 | .SetManifestKey("web_accessible_resources", |
| 117 | ListBuilder().Append("test.dat").Build()) |
Devlin Cronin | 1fa235b6 | 2018-04-12 14:04:07 | [diff] [blame] | 118 | .SetPath(GetTestPath("response_headers")) |
| 119 | .Build(); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 120 | } |
| 121 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 122 | // Helper function to create a |ResourceRequest| for testing purposes. |
| 123 | network::ResourceRequest CreateResourceRequest(const std::string& method, |
| 124 | ResourceType resource_type, |
| 125 | const GURL& url) { |
| 126 | network::ResourceRequest request; |
| 127 | request.method = method; |
| 128 | request.url = url; |
| 129 | request.site_for_cookies = url; // bypass third-party cookie blocking. |
| 130 | request.request_initiator = |
| 131 | url::Origin::Create(url); // ensure initiator set. |
| 132 | request.referrer_policy = content::Referrer::GetDefaultReferrerPolicy(); |
Daniel Cheng | 57541be | 2019-05-07 07:51:07 | [diff] [blame] | 133 | request.resource_type = static_cast<int>(resource_type); |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 134 | request.is_main_frame = resource_type == content::ResourceType::kMainFrame; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 135 | return request; |
| 136 | } |
| 137 | |
| 138 | // The result of either a URLRequest of a URLLoader response (but not both) |
| 139 | // depending on the on test type. |
| 140 | class GetResult { |
| 141 | public: |
Lucas Furukawa Gadani | 0690260 | 2019-09-27 20:44:27 | [diff] [blame] | 142 | GetResult(network::mojom::URLResponseHeadPtr response, int result) |
| 143 | : response_(std::move(response)), result_(result) {} |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 144 | GetResult(GetResult&& other) : result_(other.result_) {} |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 145 | ~GetResult() = default; |
| 146 | |
| 147 | std::string GetResponseHeaderByName(const std::string& name) const { |
| 148 | std::string value; |
Lucas Furukawa Gadani | 0690260 | 2019-09-27 20:44:27 | [diff] [blame] | 149 | if (response_ && response_->headers) |
| 150 | response_->headers->GetNormalizedHeader(name, &value); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 151 | return value; |
| 152 | } |
| 153 | |
| 154 | int result() const { return result_; } |
| 155 | |
| 156 | private: |
Lucas Furukawa Gadani | 0690260 | 2019-09-27 20:44:27 | [diff] [blame] | 157 | network::mojom::URLResponseHeadPtr response_; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 158 | int result_; |
| 159 | |
| 160 | DISALLOW_COPY_AND_ASSIGN(GetResult); |
| 161 | }; |
| 162 | |
jamescook | 8816ae5 | 2014-09-05 17:02:37 | [diff] [blame] | 163 | } // namespace |
| 164 | |
| 165 | // This test lives in src/chrome instead of src/extensions because it tests |
| 166 | // functionality delegated back to Chrome via ChromeExtensionsBrowserClient. |
lfg | 048201a | 2014-09-16 19:09:36 | [diff] [blame] | 167 | // See chrome/browser/extensions/chrome_url_request_util.cc. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 168 | class ExtensionProtocolsTestBase : public testing::Test { |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 169 | public: |
Alexey Baskakov | f0f9d8f | 2019-01-19 02:31:54 | [diff] [blame] | 170 | explicit ExtensionProtocolsTestBase(bool force_incognito) |
Gabriel Charette | 798fde7 | 2019-08-20 22:24:04 | [diff] [blame] | 171 | : task_environment_(content::BrowserTaskEnvironment::IO_MAINLOOP), |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 172 | rvh_test_enabler_(new content::RenderViewHostTestEnabler()), |
Alexey Baskakov | f0f9d8f | 2019-01-19 02:31:54 | [diff] [blame] | 173 | force_incognito_(force_incognito) {} |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 174 | |
dcheng | 7219181 | 2014-10-28 20:49:56 | [diff] [blame] | 175 | void SetUp() override { |
[email protected] | 06492ed | 2013-03-24 22:13:14 | [diff] [blame] | 176 | testing::Test::SetUp(); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 177 | testing_profile_ = TestingProfile::Builder().Build(); |
Erik Chen | 5bab499 | 2018-05-05 15:19:53 | [diff] [blame] | 178 | contents_ = CreateTestWebContents(); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 179 | |
| 180 | // Set up content verification. |
| 181 | base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 182 | command_line->AppendSwitchASCII( |
| 183 | switches::kExtensionContentVerification, |
| 184 | switches::kExtensionContentVerificationEnforce); |
| 185 | content_verifier_ = new ContentVerifier( |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 186 | browser_context(), |
| 187 | std::make_unique<ChromeContentVerifierDelegate>(browser_context())); |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 188 | info_map()->SetContentVerifier(content_verifier_.get()); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 189 | } |
| 190 | |
dcheng | 7219181 | 2014-10-28 20:49:56 | [diff] [blame] | 191 | void TearDown() override { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 192 | loader_factory_.reset(); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 193 | content_verifier_->Shutdown(); |
Matt Menke | db9fc40b | 2019-06-19 17:57:35 | [diff] [blame] | 194 | // Shut down the PowerMonitor if initialized. |
| 195 | base::PowerMonitor::ShutdownForTesting(); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 196 | } |
| 197 | |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 198 | void SetProtocolHandler(bool is_incognito) { |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 199 | loader_factory_ = extensions::CreateExtensionNavigationURLLoaderFactory( |
| 200 | browser_context(), false); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 201 | } |
| 202 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 203 | GetResult RequestOrLoad(const GURL& url, ResourceType resource_type) { |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 204 | return LoadURL(url, resource_type); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | void AddExtension(const scoped_refptr<const Extension>& extension, |
| 208 | bool incognito_enabled, |
| 209 | bool notifications_disabled) { |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 210 | info_map()->AddExtension(extension.get(), base::Time::Now(), |
| 211 | incognito_enabled, notifications_disabled); |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 212 | EXPECT_TRUE(extension_registry()->AddEnabled(extension)); |
| 213 | ExtensionPrefs::Get(browser_context()) |
| 214 | ->SetIsIncognitoEnabled(extension->id(), incognito_enabled); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | void RemoveExtension(const scoped_refptr<const Extension>& extension, |
| 218 | const UnloadedExtensionReason reason) { |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 219 | info_map()->RemoveExtension(extension->id(), reason); |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 220 | EXPECT_TRUE(extension_registry()->RemoveEnabled(extension->id())); |
| 221 | if (reason == UnloadedExtensionReason::DISABLE) |
| 222 | EXPECT_TRUE(extension_registry()->AddDisabled(extension)); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | // Helper method to create a URL request/loader, call RequestOrLoad on it, and |
| 226 | // return the result. If |extension| hasn't already been added to |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 227 | // info_map(), this will add it. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 228 | GetResult DoRequestOrLoad(const scoped_refptr<Extension> extension, |
| 229 | const std::string& relative_path) { |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 230 | if (!info_map()->extensions().Contains(extension->id())) { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 231 | AddExtension(extension.get(), |
| 232 | /*incognito_enabled=*/false, |
| 233 | /*notifications_disabled=*/false); |
| 234 | } |
| 235 | return RequestOrLoad(extension->GetResourceURL(relative_path), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 236 | content::ResourceType::kMainFrame); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | ExtensionRegistry* extension_registry() { |
| 240 | return ExtensionRegistry::Get(browser_context()); |
| 241 | } |
| 242 | |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 243 | InfoMap* info_map() { |
| 244 | return ExtensionSystem::Get(browser_context())->info_map(); |
| 245 | } |
| 246 | |
Alexey Baskakov | f0f9d8f | 2019-01-19 02:31:54 | [diff] [blame] | 247 | content::BrowserContext* browser_context() { |
| 248 | return force_incognito_ ? testing_profile_->GetOffTheRecordProfile() |
| 249 | : testing_profile_.get(); |
| 250 | } |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 251 | |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 252 | void SimulateSystemSuspendForRequests() { |
| 253 | power_monitor_source_ = new base::PowerMonitorTestSource(); |
Matt Menke | db9fc40b | 2019-06-19 17:57:35 | [diff] [blame] | 254 | base::PowerMonitor::Initialize( |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 255 | std::unique_ptr<base::PowerMonitorSource>(power_monitor_source_)); |
| 256 | } |
| 257 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 258 | protected: |
| 259 | scoped_refptr<ContentVerifier> content_verifier_; |
| 260 | |
| 261 | private: |
| 262 | GetResult LoadURL(const GURL& url, ResourceType resource_type) { |
| 263 | constexpr int32_t kRoutingId = 81; |
| 264 | constexpr int32_t kRequestId = 28; |
| 265 | |
Julie Jeongeun Kim | 917c19790 | 2019-11-26 03:36:14 | [diff] [blame^] | 266 | mojo::PendingRemote<network::mojom::URLLoader> loader; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 267 | network::TestURLLoaderClient client; |
| 268 | loader_factory_->CreateLoaderAndStart( |
Julie Jeongeun Kim | 917c19790 | 2019-11-26 03:36:14 | [diff] [blame^] | 269 | loader.InitWithNewPipeAndPassReceiver(), kRoutingId, kRequestId, |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 270 | network::mojom::kURLLoadOptionNone, |
Julie Jeongeun Kim | 6dd4c7b | 2019-11-18 05:56:30 | [diff] [blame] | 271 | CreateResourceRequest("GET", resource_type, url), client.CreateRemote(), |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 272 | net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS)); |
| 273 | |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 274 | if (power_monitor_source_) { |
| 275 | power_monitor_source_->GenerateSuspendEvent(); |
| 276 | power_monitor_source_->GenerateResumeEvent(); |
| 277 | } |
| 278 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 279 | client.RunUntilComplete(); |
Lucas Furukawa Gadani | 0690260 | 2019-09-27 20:44:27 | [diff] [blame] | 280 | return GetResult(client.response_head().Clone(), |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 281 | client.completion_status().error_code); |
| 282 | } |
| 283 | |
Erik Chen | 5bab499 | 2018-05-05 15:19:53 | [diff] [blame] | 284 | std::unique_ptr<content::WebContents> CreateTestWebContents() { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 285 | auto site_instance = content::SiteInstance::Create(browser_context()); |
| 286 | return content::WebContentsTester::CreateTestWebContents( |
| 287 | browser_context(), std::move(site_instance)); |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 288 | } |
| 289 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 290 | content::WebContents* web_contents() { return contents_.get(); } |
| 291 | |
| 292 | content::RenderFrameHost* main_rfh() { |
| 293 | return web_contents()->GetMainFrame(); |
| 294 | } |
| 295 | |
Gabriel Charette | 798fde7 | 2019-08-20 22:24:04 | [diff] [blame] | 296 | content::BrowserTaskEnvironment task_environment_; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 297 | std::unique_ptr<content::RenderViewHostTestEnabler> rvh_test_enabler_; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 298 | std::unique_ptr<network::mojom::URLLoaderFactory> loader_factory_; |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 299 | std::unique_ptr<TestingProfile> testing_profile_; |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 300 | std::unique_ptr<content::WebContents> contents_; |
Alexey Baskakov | f0f9d8f | 2019-01-19 02:31:54 | [diff] [blame] | 301 | const bool force_incognito_; |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 302 | |
Matt Menke | db9fc40b | 2019-06-19 17:57:35 | [diff] [blame] | 303 | // |power_monitor_source_| is owned by the global PowerMonitor. |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 304 | base::PowerMonitorTestSource* power_monitor_source_ = nullptr; |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 305 | }; |
| 306 | |
Alexey Baskakov | f0f9d8f | 2019-01-19 02:31:54 | [diff] [blame] | 307 | class ExtensionProtocolsTest : public ExtensionProtocolsTestBase { |
| 308 | public: |
| 309 | ExtensionProtocolsTest() |
| 310 | : ExtensionProtocolsTestBase(false /*force_incognito*/) {} |
| 311 | }; |
| 312 | |
| 313 | class ExtensionProtocolsIncognitoTest : public ExtensionProtocolsTestBase { |
| 314 | public: |
| 315 | ExtensionProtocolsIncognitoTest() |
| 316 | : ExtensionProtocolsTestBase(true /*force_incognito*/) {} |
| 317 | }; |
| 318 | |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 319 | // Tests that making a chrome-extension request in an incognito context is |
| 320 | // only allowed under the right circumstances (if the extension is allowed |
| 321 | // in incognito, and it's either a non-main-frame request or a split-mode |
| 322 | // extension). |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 323 | TEST_F(ExtensionProtocolsIncognitoTest, IncognitoRequest) { |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 324 | // Register an incognito extension protocol handler. |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 325 | SetProtocolHandler(true); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 326 | |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 327 | struct TestCase { |
| 328 | // Inputs. |
| 329 | std::string name; |
| 330 | bool incognito_split_mode; |
| 331 | bool incognito_enabled; |
| 332 | |
| 333 | // Expected results. |
| 334 | bool should_allow_main_frame_load; |
| 335 | bool should_allow_sub_frame_load; |
| 336 | } cases[] = { |
| 337 | {"spanning disabled", false, false, false, false}, |
| 338 | {"split disabled", true, false, false, false}, |
nasko | 5cf9d45 | 2016-06-01 05:34:56 | [diff] [blame] | 339 | {"spanning enabled", false, true, false, false}, |
| 340 | {"split enabled", true, true, true, false}, |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 341 | }; |
| 342 | |
Avi Drissman | 5f0fb8c | 2018-12-25 23:20:49 | [diff] [blame] | 343 | for (size_t i = 0; i < base::size(cases); ++i) { |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 344 | scoped_refptr<Extension> extension = |
| 345 | CreateTestExtension(cases[i].name, cases[i].incognito_split_mode); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 346 | AddExtension(extension, cases[i].incognito_enabled, false); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 347 | |
| 348 | // First test a main frame request. |
| 349 | { |
| 350 | // It doesn't matter that the resource doesn't exist. If the resource |
nasko | b9164c4 | 2016-06-07 01:21:35 | [diff] [blame] | 351 | // is blocked, we should see BLOCKED_BY_CLIENT. Otherwise, the request |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 352 | // should just fail because the file doesn't exist. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 353 | auto get_result = RequestOrLoad(extension->GetResourceURL("404.html"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 354 | content::ResourceType::kMainFrame); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 355 | |
| 356 | if (cases[i].should_allow_main_frame_load) { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 357 | EXPECT_EQ(net::ERR_FILE_NOT_FOUND, get_result.result()) |
maksim.sisov | 1b83bb7 | 2016-10-07 06:07:23 | [diff] [blame] | 358 | << cases[i].name; |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 359 | } else { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 360 | EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, get_result.result()) |
nasko | b9164c4 | 2016-06-07 01:21:35 | [diff] [blame] | 361 | << cases[i].name; |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
John Abd-El-Malek | 2305cdc | 2018-02-14 20:26:28 | [diff] [blame] | 365 | // Subframe navigation requests are blocked in ExtensionNavigationThrottle |
| 366 | // which isn't added in this unit test. This is tested in an integration |
| 367 | // test in ExtensionResourceRequestPolicyTest.IframeNavigateToInaccessible. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 368 | RemoveExtension(extension, UnloadedExtensionReason::UNINSTALL); |
[email protected] | 5e212ed | 2012-03-21 23:29:15 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 372 | void CheckForContentLengthHeader(const GetResult& get_result) { |
| 373 | std::string content_length = get_result.GetResponseHeaderByName( |
| 374 | net::HttpRequestHeaders::kContentLength); |
| 375 | |
[email protected] | 774cebd | 2013-09-26 04:55:01 | [diff] [blame] | 376 | EXPECT_FALSE(content_length.empty()); |
| 377 | int length_value = 0; |
| 378 | EXPECT_TRUE(base::StringToInt(content_length, &length_value)); |
| 379 | EXPECT_GT(length_value, 0); |
| 380 | } |
| 381 | |
dstockwell | 944d1888 | 2019-04-09 04:25:58 | [diff] [blame] | 382 | #if defined(OS_CHROMEOS) |
| 383 | // Tests getting a resource for a component extension works correctly where |
| 384 | // there is no mime type. Such a resource currently only exists for Chrome OS |
| 385 | // build. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 386 | TEST_F(ExtensionProtocolsTest, ComponentResourceRequestNoMimeType) { |
dstockwell | 944d1888 | 2019-04-09 04:25:58 | [diff] [blame] | 387 | SetProtocolHandler(false); |
| 388 | std::unique_ptr<base::DictionaryValue> manifest = |
| 389 | DictionaryBuilder() |
| 390 | .Set("name", "pdf") |
| 391 | .Set("version", "1") |
| 392 | .Set("manifest_version", 2) |
| 393 | .Set("web_accessible_resources", |
| 394 | // Registered by chrome_component_extension_resource_manager.cc |
| 395 | ListBuilder().Append("ink/glcore_base.js.mem").Build()) |
| 396 | .Build(); |
| 397 | |
| 398 | base::FilePath path; |
| 399 | EXPECT_TRUE(base::PathService::Get(chrome::DIR_RESOURCES, &path)); |
| 400 | path = path.AppendASCII("pdf"); |
| 401 | |
| 402 | std::string error; |
| 403 | scoped_refptr<Extension> extension(Extension::Create( |
| 404 | path, Manifest::COMPONENT, *manifest, Extension::NO_FLAGS, &error)); |
| 405 | EXPECT_TRUE(extension.get()) << error; |
| 406 | AddExtension(extension, false, false); |
| 407 | |
| 408 | auto get_result = |
| 409 | RequestOrLoad(extension->GetResourceURL("ink/glcore_base.js.mem"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 410 | content::ResourceType::kXhr); |
dstockwell | 944d1888 | 2019-04-09 04:25:58 | [diff] [blame] | 411 | EXPECT_EQ(net::OK, get_result.result()); |
| 412 | CheckForContentLengthHeader(get_result); |
| 413 | EXPECT_EQ("", get_result.GetResponseHeaderByName( |
| 414 | net::HttpRequestHeaders::kContentType)); |
| 415 | } |
| 416 | #endif |
| 417 | |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 418 | // Tests getting a resource for a component extension works correctly, both when |
| 419 | // the extension is enabled and when it is disabled. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 420 | TEST_F(ExtensionProtocolsTest, ComponentResourceRequest) { |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 421 | // Register a non-incognito extension protocol handler. |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 422 | SetProtocolHandler(false); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 423 | |
| 424 | scoped_refptr<Extension> extension = CreateWebStoreExtension(); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 425 | AddExtension(extension, false, false); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 426 | |
| 427 | // First test it with the extension enabled. |
| 428 | { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 429 | auto get_result = |
| 430 | RequestOrLoad(extension->GetResourceURL("webstore_icon_16.png"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 431 | content::ResourceType::kMedia); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 432 | EXPECT_EQ(net::OK, get_result.result()); |
| 433 | CheckForContentLengthHeader(get_result); |
| 434 | EXPECT_EQ("image/png", get_result.GetResponseHeaderByName( |
| 435 | net::HttpRequestHeaders::kContentType)); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | // And then test it with the extension disabled. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 439 | RemoveExtension(extension, UnloadedExtensionReason::DISABLE); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 440 | { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 441 | auto get_result = |
| 442 | RequestOrLoad(extension->GetResourceURL("webstore_icon_16.png"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 443 | content::ResourceType::kMedia); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 444 | EXPECT_EQ(net::OK, get_result.result()); |
| 445 | CheckForContentLengthHeader(get_result); |
| 446 | EXPECT_EQ("image/png", get_result.GetResponseHeaderByName( |
| 447 | net::HttpRequestHeaders::kContentType)); |
[email protected] | 93ac047a | 2012-12-13 02:53:49 | [diff] [blame] | 448 | } |
| 449 | } |
| 450 | |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 451 | // Tests that a URL request for resource from an extension returns a few |
| 452 | // expected response headers. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 453 | TEST_F(ExtensionProtocolsTest, ResourceRequestResponseHeaders) { |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 454 | // Register a non-incognito extension protocol handler. |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 455 | SetProtocolHandler(false); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 456 | |
Devlin Cronin | 8e5892f | 2018-10-04 00:13:43 | [diff] [blame] | 457 | scoped_refptr<const Extension> extension = |
| 458 | CreateTestResponseHeaderExtension(); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 459 | AddExtension(extension, false, false); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 460 | |
| 461 | { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 462 | auto get_result = RequestOrLoad(extension->GetResourceURL("test.dat"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 463 | content::ResourceType::kMedia); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 464 | EXPECT_EQ(net::OK, get_result.result()); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 465 | |
| 466 | // Check that cache-related headers are set. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 467 | std::string etag = get_result.GetResponseHeaderByName("ETag"); |
brettw | 66d1b81b | 2015-07-06 19:29:40 | [diff] [blame] | 468 | EXPECT_TRUE(base::StartsWith(etag, "\"", base::CompareCase::SENSITIVE)); |
| 469 | EXPECT_TRUE(base::EndsWith(etag, "\"", base::CompareCase::SENSITIVE)); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 470 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 471 | std::string revalidation_header = |
| 472 | get_result.GetResponseHeaderByName("cache-control"); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 473 | EXPECT_EQ("no-cache", revalidation_header); |
| 474 | |
| 475 | // We set test.dat as web-accessible, so it should have a CORS header. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 476 | std::string access_control = |
| 477 | get_result.GetResponseHeaderByName("Access-Control-Allow-Origin"); |
[email protected] | 6f7d706 | 2013-06-04 03:49:33 | [diff] [blame] | 478 | EXPECT_EQ("*", access_control); |
| 479 | } |
| 480 | } |
| 481 | |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 482 | // Tests that a URL request for main frame or subframe from an extension |
| 483 | // succeeds, but subresources fail. See http://crbug.com/312269. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 484 | TEST_F(ExtensionProtocolsTest, AllowFrameRequests) { |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 485 | // Register a non-incognito extension protocol handler. |
[email protected] | 1791e6c9 | 2014-04-11 08:29:01 | [diff] [blame] | 486 | SetProtocolHandler(false); |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 487 | |
| 488 | scoped_refptr<Extension> extension = CreateTestExtension("foo", false); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 489 | AddExtension(extension, false, false); |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 490 | |
nasko | 5cf9d45 | 2016-06-01 05:34:56 | [diff] [blame] | 491 | // All MAIN_FRAME requests should succeed. SUB_FRAME requests that are not |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 492 | // explicitly listed in web_accessible_resources or same-origin to the parent |
nasko | 5cf9d45 | 2016-06-01 05:34:56 | [diff] [blame] | 493 | // should not succeed. |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 494 | { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 495 | auto get_result = RequestOrLoad(extension->GetResourceURL("test.dat"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 496 | content::ResourceType::kMainFrame); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 497 | EXPECT_EQ(net::OK, get_result.result()); |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 498 | } |
John Abd-El-Malek | 2305cdc | 2018-02-14 20:26:28 | [diff] [blame] | 499 | |
| 500 | // Subframe navigation requests are blocked in ExtensionNavigationThrottle |
| 501 | // which isn't added in this unit test. This is tested in an integration test |
| 502 | // in ExtensionResourceRequestPolicyTest.IframeNavigateToInaccessible. |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 503 | |
| 504 | // And subresource types, such as media, should fail. |
| 505 | { |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 506 | auto get_result = RequestOrLoad(extension->GetResourceURL("test.dat"), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 507 | content::ResourceType::kMedia); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 508 | EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, get_result.result()); |
[email protected] | b109bdd | 2013-11-04 18:08:43 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 512 | TEST_F(ExtensionProtocolsTest, MetadataFolder) { |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 513 | SetProtocolHandler(false); |
| 514 | |
| 515 | base::FilePath extension_dir = GetTestPath("metadata_folder"); |
| 516 | std::string error; |
| 517 | scoped_refptr<Extension> extension = |
| 518 | file_util::LoadExtension(extension_dir, Manifest::INTERNAL, |
| 519 | Extension::NO_FLAGS, &error); |
| 520 | ASSERT_NE(extension.get(), nullptr) << "error: " << error; |
| 521 | |
| 522 | // Loading "/test.html" should succeed. |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 523 | EXPECT_EQ(net::OK, DoRequestOrLoad(extension, "test.html").result()); |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 524 | |
| 525 | // Loading "/_metadata/verified_contents.json" should fail. |
| 526 | base::FilePath relative_path = |
| 527 | base::FilePath(kMetadataFolder).Append(kVerifiedContentsFilename); |
| 528 | EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path))); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 529 | EXPECT_NE(net::OK, |
| 530 | DoRequestOrLoad(extension, relative_path.AsUTF8Unsafe()).result()); |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 531 | |
| 532 | // Loading "/_metadata/a.txt" should also fail. |
| 533 | relative_path = base::FilePath(kMetadataFolder).AppendASCII("a.txt"); |
| 534 | EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path))); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 535 | EXPECT_NE(net::OK, |
| 536 | DoRequestOrLoad(extension, relative_path.AsUTF8Unsafe()).result()); |
asargent | a093ec3 | 2016-02-13 01:36:43 | [diff] [blame] | 537 | } |
| 538 | |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 539 | // Tests that unreadable files and deleted files correctly go through |
| 540 | // ContentVerifyJob. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 541 | TEST_F(ExtensionProtocolsTest, VerificationSeenForFileAccessErrors) { |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 542 | SetProtocolHandler(false); |
| 543 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 544 | // Unzip extension containing verification hashes to a temporary directory. |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 545 | base::ScopedTempDir temp_dir; |
| 546 | ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 547 | base::FilePath unzipped_path = temp_dir.GetPath(); |
| 548 | scoped_refptr<Extension> extension = |
| 549 | content_verifier_test_utils::UnzipToDirAndLoadExtension( |
| 550 | GetContentVerifierTestPath().AppendASCII("source.zip"), |
| 551 | unzipped_path); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 552 | ASSERT_TRUE(extension.get()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 553 | ExtensionId extension_id = extension->id(); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 554 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 555 | const std::string kJs("1024.js"); |
| 556 | base::FilePath kRelativePath(FILE_PATH_LITERAL("1024.js")); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 557 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 558 | // Valid and readable 1024.js. |
| 559 | { |
Istiaque Ahmed | 584fe14 | 2018-03-13 09:19:04 | [diff] [blame] | 560 | TestContentVerifySingleJobObserver observer(extension_id, kRelativePath); |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 561 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 562 | content_verifier_->OnExtensionLoaded(browser_context(), extension.get()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 563 | // Wait for PostTask to ContentVerifierIOData::AddData() to finish. |
| 564 | content::RunAllPendingInMessageLoop(); |
| 565 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 566 | EXPECT_EQ(net::OK, DoRequestOrLoad(extension, kJs).result()); |
Istiaque Ahmed | 1dec1d4 | 2018-02-02 00:01:36 | [diff] [blame] | 567 | EXPECT_EQ(ContentVerifyJob::NONE, observer.WaitForJobFinished()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | // chmod -r 1024.js. |
| 571 | { |
Istiaque Ahmed | 584fe14 | 2018-03-13 09:19:04 | [diff] [blame] | 572 | TestContentVerifySingleJobObserver observer(extension->id(), kRelativePath); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 573 | base::FilePath file_path = unzipped_path.AppendASCII(kJs); |
| 574 | ASSERT_TRUE(base::MakeFileUnreadable(file_path)); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 575 | EXPECT_EQ(net::ERR_ACCESS_DENIED, DoRequestOrLoad(extension, kJs).result()); |
Istiaque Ahmed | 1dec1d4 | 2018-02-02 00:01:36 | [diff] [blame] | 576 | EXPECT_EQ(ContentVerifyJob::HASH_MISMATCH, observer.WaitForJobFinished()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 577 | // NOTE: In production, hash mismatch would have disabled |extension|, but |
| 578 | // since UnzipToDirAndLoadExtension() doesn't add the extension to |
| 579 | // ExtensionRegistry, ChromeContentVerifierDelegate won't disable it. |
| 580 | // TODO(lazyboy): We may want to update this to more closely reflect the |
| 581 | // real flow. |
| 582 | } |
| 583 | |
| 584 | // Delete 1024.js. |
| 585 | { |
Istiaque Ahmed | 584fe14 | 2018-03-13 09:19:04 | [diff] [blame] | 586 | TestContentVerifySingleJobObserver observer(extension_id, kRelativePath); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 587 | base::FilePath file_path = unzipped_path.AppendASCII(kJs); |
| 588 | ASSERT_TRUE(base::DieFileDie(file_path, false)); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 589 | EXPECT_EQ(net::ERR_FILE_NOT_FOUND, |
| 590 | DoRequestOrLoad(extension, kJs).result()); |
Istiaque Ahmed | 1dec1d4 | 2018-02-02 00:01:36 | [diff] [blame] | 591 | EXPECT_EQ(ContentVerifyJob::HASH_MISMATCH, observer.WaitForJobFinished()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 592 | } |
lazyboy | d6dbb26 | 2017-03-30 00:57:30 | [diff] [blame] | 593 | } |
| 594 | |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 595 | // Tests that zero byte files correctly go through ContentVerifyJob. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 596 | TEST_F(ExtensionProtocolsTest, VerificationSeenForZeroByteFile) { |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 597 | SetProtocolHandler(false); |
| 598 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 599 | const std::string kEmptyJs("empty.js"); |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 600 | base::ScopedTempDir temp_dir; |
| 601 | ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 602 | base::FilePath unzipped_path = temp_dir.GetPath(); |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 603 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 604 | scoped_refptr<Extension> extension = |
| 605 | content_verifier_test_utils::UnzipToDirAndLoadExtension( |
| 606 | GetContentVerifierTestPath().AppendASCII("source.zip"), |
| 607 | unzipped_path); |
| 608 | ASSERT_TRUE(extension.get()); |
| 609 | |
| 610 | base::FilePath kRelativePath(FILE_PATH_LITERAL("empty.js")); |
| 611 | ExtensionId extension_id = extension->id(); |
| 612 | |
| 613 | // Sanity check empty.js. |
| 614 | base::FilePath file_path = unzipped_path.AppendASCII(kEmptyJs); |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 615 | int64_t foo_file_size = -1; |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 616 | ASSERT_TRUE(base::GetFileSize(file_path, &foo_file_size)); |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 617 | ASSERT_EQ(0, foo_file_size); |
| 618 | |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 619 | // Request empty.js. |
| 620 | { |
Istiaque Ahmed | 584fe14 | 2018-03-13 09:19:04 | [diff] [blame] | 621 | TestContentVerifySingleJobObserver observer(extension_id, kRelativePath); |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 622 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 623 | content_verifier_->OnExtensionLoaded(browser_context(), extension.get()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 624 | // Wait for PostTask to ContentVerifierIOData::AddData() to finish. |
| 625 | content::RunAllPendingInMessageLoop(); |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 626 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 627 | EXPECT_EQ(net::OK, DoRequestOrLoad(extension, kEmptyJs).result()); |
Istiaque Ahmed | 1dec1d4 | 2018-02-02 00:01:36 | [diff] [blame] | 628 | EXPECT_EQ(ContentVerifyJob::NONE, observer.WaitForJobFinished()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | // chmod -r empty.js. |
| 632 | // Unreadable empty file doesn't generate hash mismatch. Note that this is the |
| 633 | // current behavior of ContentVerifyJob. |
| 634 | // TODO(lazyboy): The behavior is probably incorrect. |
| 635 | { |
Istiaque Ahmed | 584fe14 | 2018-03-13 09:19:04 | [diff] [blame] | 636 | TestContentVerifySingleJobObserver observer(extension->id(), kRelativePath); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 637 | base::FilePath file_path = unzipped_path.AppendASCII(kEmptyJs); |
| 638 | ASSERT_TRUE(base::MakeFileUnreadable(file_path)); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 639 | EXPECT_EQ(net::ERR_ACCESS_DENIED, |
| 640 | DoRequestOrLoad(extension, kEmptyJs).result()); |
Istiaque Ahmed | 1dec1d4 | 2018-02-02 00:01:36 | [diff] [blame] | 641 | EXPECT_EQ(ContentVerifyJob::NONE, observer.WaitForJobFinished()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | // rm empty.js. |
| 645 | // Deleted empty file doesn't generate hash mismatch. Note that this is the |
| 646 | // current behavior of ContentVerifyJob. |
| 647 | // TODO(lazyboy): The behavior is probably incorrect. |
| 648 | { |
Istiaque Ahmed | 584fe14 | 2018-03-13 09:19:04 | [diff] [blame] | 649 | TestContentVerifySingleJobObserver observer(extension_id, kRelativePath); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 650 | base::FilePath file_path = unzipped_path.AppendASCII(kEmptyJs); |
| 651 | ASSERT_TRUE(base::DieFileDie(file_path, false)); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 652 | EXPECT_EQ(net::ERR_FILE_NOT_FOUND, |
| 653 | DoRequestOrLoad(extension, kEmptyJs).result()); |
Istiaque Ahmed | 1dec1d4 | 2018-02-02 00:01:36 | [diff] [blame] | 654 | EXPECT_EQ(ContentVerifyJob::NONE, observer.WaitForJobFinished()); |
Istiaque Ahmed | 72816eaa | 2018-01-30 22:37:06 | [diff] [blame] | 655 | } |
lazyboy | e83ab9c6 | 2017-03-30 03:18:26 | [diff] [blame] | 656 | } |
| 657 | |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 658 | TEST_F(ExtensionProtocolsTest, VerifyScriptListedAsIcon) { |
proberge | 4f9644c | 2018-03-27 23:01:54 | [diff] [blame] | 659 | SetProtocolHandler(false); |
| 660 | |
| 661 | const std::string kBackgroundJs("background.js"); |
| 662 | base::ScopedTempDir temp_dir; |
| 663 | ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 664 | base::FilePath unzipped_path = temp_dir.GetPath(); |
| 665 | |
| 666 | base::FilePath path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 667 | EXPECT_TRUE(base::PathService::Get(extensions::DIR_TEST_DATA, &path)); |
proberge | 4f9644c | 2018-03-27 23:01:54 | [diff] [blame] | 668 | |
| 669 | scoped_refptr<Extension> extension = |
| 670 | content_verifier_test_utils::UnzipToDirAndLoadExtension( |
| 671 | path.AppendASCII("content_hash_fetcher") |
| 672 | .AppendASCII("manifest_mislabeled_script") |
| 673 | .AppendASCII("source.zip"), |
| 674 | unzipped_path); |
| 675 | ASSERT_TRUE(extension.get()); |
| 676 | |
| 677 | base::FilePath kRelativePath(FILE_PATH_LITERAL("background.js")); |
| 678 | ExtensionId extension_id = extension->id(); |
| 679 | |
| 680 | // Request background.js. |
| 681 | { |
| 682 | TestContentVerifySingleJobObserver observer(extension_id, kRelativePath); |
| 683 | |
| 684 | content_verifier_->OnExtensionLoaded(browser_context(), extension.get()); |
| 685 | // Wait for PostTask to ContentVerifierIOData::AddData() to finish. |
| 686 | base::RunLoop().RunUntilIdle(); |
| 687 | |
| 688 | EXPECT_EQ(net::OK, DoRequestOrLoad(extension, kBackgroundJs).result()); |
| 689 | EXPECT_EQ(ContentVerifyJob::NONE, observer.WaitForJobFinished()); |
| 690 | } |
| 691 | |
| 692 | // Modify background.js and request it. |
| 693 | { |
| 694 | base::FilePath file_path = unzipped_path.AppendASCII("background.js"); |
| 695 | const std::string content = "new content"; |
| 696 | EXPECT_NE(base::WriteFile(file_path, content.c_str(), content.size()), -1); |
| 697 | TestContentVerifySingleJobObserver observer(extension_id, kRelativePath); |
| 698 | |
| 699 | content_verifier_->OnExtensionLoaded(browser_context(), extension.get()); |
| 700 | // Wait for PostTask to ContentVerifierIOData::AddData() to finish. |
| 701 | base::RunLoop().RunUntilIdle(); |
| 702 | |
| 703 | EXPECT_EQ(net::OK, DoRequestOrLoad(extension, kBackgroundJs).result()); |
| 704 | EXPECT_EQ(ContentVerifyJob::HASH_MISMATCH, observer.WaitForJobFinished()); |
| 705 | } |
| 706 | } |
| 707 | |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 708 | // Tests that mime types are properly set for returned extension resources. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 709 | TEST_F(ExtensionProtocolsTest, MimeTypesForKnownFiles) { |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 710 | // Register a non-incognito extension protocol handler. |
| 711 | SetProtocolHandler(false); |
| 712 | |
| 713 | TestExtensionDir test_dir; |
| 714 | constexpr char kManifest[] = R"( |
| 715 | { |
| 716 | "name": "Test Ext", |
| 717 | "description": "A test extension", |
| 718 | "manifest_version": 2, |
| 719 | "version": "0.1", |
| 720 | "web_accessible_resources": ["*"] |
| 721 | })"; |
| 722 | test_dir.WriteManifest(kManifest); |
| 723 | std::unique_ptr<base::DictionaryValue> manifest = |
Lei Zhang | 9b9d579 | 2019-02-20 07:24:42 | [diff] [blame] | 724 | base::DictionaryValue::From(base::test::ParseJsonDeprecated(kManifest)); |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 725 | ASSERT_TRUE(manifest); |
| 726 | |
| 727 | test_dir.WriteFile(FILE_PATH_LITERAL("json_file.json"), "{}"); |
| 728 | test_dir.WriteFile(FILE_PATH_LITERAL("js_file.js"), "function() {}"); |
| 729 | |
| 730 | base::FilePath unpacked_path = test_dir.UnpackedPath(); |
| 731 | ASSERT_TRUE(base::PathExists(unpacked_path.AppendASCII("json_file.json"))); |
| 732 | std::string error; |
| 733 | scoped_refptr<const Extension> extension = |
| 734 | ExtensionBuilder() |
| 735 | .SetManifest(std::move(manifest)) |
| 736 | .SetPath(unpacked_path) |
| 737 | .SetLocation(Manifest::INTERNAL) |
| 738 | .Build(); |
| 739 | ASSERT_TRUE(extension); |
| 740 | |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 741 | AddExtension(extension.get(), false, false); |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 742 | |
| 743 | struct { |
| 744 | const char* file_name; |
| 745 | const char* expected_mime_type; |
| 746 | } test_cases[] = { |
dstockwell | 0067793 | 2019-04-09 02:12:08 | [diff] [blame] | 747 | {"json_file.json", "application/json"}, |
| 748 | {"js_file.js", "text/javascript"}, |
| 749 | {"mem_file.mem", ""}, |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 750 | }; |
| 751 | |
| 752 | for (const auto& test_case : test_cases) { |
| 753 | SCOPED_TRACE(test_case.file_name); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 754 | auto result = RequestOrLoad(extension->GetResourceURL(test_case.file_name), |
Daniel Cheng | aee5c031 | 2019-04-18 23:49:05 | [diff] [blame] | 755 | content::ResourceType::kSubResource); |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 756 | EXPECT_EQ( |
| 757 | test_case.expected_mime_type, |
| 758 | result.GetResponseHeaderByName(net::HttpRequestHeaders::kContentType)); |
Devlin Cronin | c3f8807 | 2018-01-30 02:10:11 | [diff] [blame] | 759 | } |
| 760 | } |
| 761 | |
Kevin Marshall | 4cab5af | 2019-01-14 20:27:14 | [diff] [blame] | 762 | #if defined(OS_WIN) |
| 763 | #define MAYBE_ExtensionRequestsNotAborted DISABLED_ExtensionRequestsNotAborted |
| 764 | #else |
| 765 | #define MAYBE_ExtensionRequestsNotAborted ExtensionRequestsNotAborted |
| 766 | #endif |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 767 | // Tests that requests for extension resources (including the generated |
| 768 | // background page) are not aborted on system suspend. |
Kevin Marshall | 4cab5af | 2019-01-14 20:27:14 | [diff] [blame] | 769 | // |
| 770 | // Flaky on Windows. |
| 771 | // TODO(https://crbug.com/921687): Investigate and fix. |
Clark DuVall | c7e3b469 | 2019-06-13 22:07:11 | [diff] [blame] | 772 | TEST_F(ExtensionProtocolsTest, MAYBE_ExtensionRequestsNotAborted) { |
Karandeep Bhatia | ab489a4d | 2018-11-28 21:56:06 | [diff] [blame] | 773 | // Register a non-incognito extension protocol handler. |
| 774 | SetProtocolHandler(false); |
| 775 | |
| 776 | base::FilePath extension_dir = |
| 777 | GetTestPath("common").AppendASCII("background_script"); |
| 778 | std::string error; |
| 779 | scoped_refptr<Extension> extension = file_util::LoadExtension( |
| 780 | extension_dir, Manifest::INTERNAL, Extension::NO_FLAGS, &error); |
| 781 | ASSERT_TRUE(extension.get()) << error; |
| 782 | |
| 783 | SimulateSystemSuspendForRequests(); |
| 784 | |
| 785 | // Request the generated background page. Ensure the request completes |
| 786 | // successfully. |
| 787 | EXPECT_EQ(net::OK, |
| 788 | DoRequestOrLoad(extension.get(), kGeneratedBackgroundPageFilename) |
| 789 | .result()); |
| 790 | |
| 791 | // Request the background.js file. Ensure the request completes successfully. |
| 792 | EXPECT_EQ(net::OK, DoRequestOrLoad(extension.get(), "background.js").result()); |
| 793 | } |
| 794 | |
[email protected] | 702d8b4 | 2013-02-27 20:55:50 | [diff] [blame] | 795 | } // namespace extensions |