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

Unified Diff: chrome/browser/extensions/extension_protocols_unittest.cc

Issue 55163006: Allow navigations performed by extensions to pass through AllowExtensionResourceLoad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix webview case. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_protocols.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_protocols_unittest.cc
diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc
index aff56cc5c551ef786381aaec2c23f2d1bdbb596c..6be3ea31aef4c72acd0bee4faf2bcb4e91aea2b1 100644
--- a/chrome/browser/extensions/extension_protocols_unittest.cc
+++ b/chrome/browser/extensions/extension_protocols_unittest.cc
@@ -32,10 +32,12 @@ scoped_refptr<Extension> CreateTestExtension(const std::string& name,
DictionaryValue manifest;
manifest.SetString("name", name);
manifest.SetString("version", "1");
+ manifest.SetInteger("manifest_version", 2);
manifest.SetString("incognito", incognito_split_mode ? "split" : "spanning");
base::FilePath path;
- EXPECT_TRUE(file_util::GetCurrentDirectory(&path));
+ EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
+ path = path.AppendASCII("extensions").AppendASCII("response_headers");
std::string error;
scoped_refptr<Extension> extension(
@@ -285,4 +287,42 @@ TEST_F(ExtensionProtocolTest, ResourceRequestResponseHeaders) {
}
}
+// Tests that a URL request for main frame or subframe from an extension
+// succeeds, but subresources fail. See http://crbug.com/312269.
+TEST_F(ExtensionProtocolTest, AllowFrameRequests) {
+ // Register a non-incognito extension protocol handler.
+ SetProtocolHandler(false);
+
+ scoped_refptr<Extension> extension = CreateTestExtension("foo", false);
+ extension_info_map_->AddExtension(extension.get(), base::Time::Now(), false);
+
+ // All MAIN_FRAME and SUB_FRAME requests should succeed.
+ {
+ net::URLRequest request(extension->GetResourceURL("test.dat"),
+ net::DEFAULT_PRIORITY,
+ &test_delegate_,
+ resource_context_.GetRequestContext());
+ StartRequest(&request, ResourceType::MAIN_FRAME);
+ EXPECT_EQ(net::URLRequestStatus::SUCCESS, request.status().status());
+ }
+ {
+ net::URLRequest request(extension->GetResourceURL("test.dat"),
+ net::DEFAULT_PRIORITY,
+ &test_delegate_,
+ resource_context_.GetRequestContext());
+ StartRequest(&request, ResourceType::SUB_FRAME);
+ EXPECT_EQ(net::URLRequestStatus::SUCCESS, request.status().status());
+ }
+
+ // And subresource types, such as media, should fail.
+ {
+ net::URLRequest request(extension->GetResourceURL("test.dat"),
+ net::DEFAULT_PRIORITY,
+ &test_delegate_,
+ resource_context_.GetRequestContext());
+ StartRequest(&request, ResourceType::MEDIA);
+ EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status());
+ }
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/extension_protocols.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698