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

Unified Diff: chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/test.js

Issue 166793003: Allow FTP requests by Chromium extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/manifest.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/test.js
diff --git a/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/test.js b/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/test.js
index fa5893600e88c4e790267fa8bdaf845f228d30ca..9689a5a99a8486e755a433d8065254addc4fda11 100644
--- a/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/test.js
+++ b/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/test.js
@@ -8,18 +8,26 @@ var testTabId;
chrome.test.getConfig(function(config) {
function rewriteURL(url) {
- return url.replace(/PORT/, config.testServer.port);
+ var isFtp = /^ftp:/i.test(url);
+ var port = isFtp ? config.ftpServer.port : config.testServer.port;
+ return url.replace(/PORT/, port);
}
function doReq(domain, expectSuccess) {
var url = rewriteURL(domain + ':PORT/extensions/test_file.txt');
chrome.tabs.sendRequest(testTabId, url, function(response) {
+ if (response.thrownError) {
+ chrome.test.fail(response.thrownError);
+ return;
+ }
if (expectSuccess) {
chrome.test.assertEq('load', response.event);
- chrome.test.assertEq(200, response.status);
+ if (/^https?:/i.test(url))
+ chrome.test.assertEq(200, response.status);
chrome.test.assertEq('Hello!', response.text);
} else {
+ chrome.test.assertEq('error', response.event);
chrome.test.assertEq(0, response.status);
}
@@ -61,6 +69,15 @@ chrome.test.getConfig(function(config) {
// can still make requests to it since it's the page that the content
// script is injected into.
doReq('http://localhost', true);
+ },
+ function allowedFtpHostAllowed() {
+ doReq('ftp://127.0.0.1', true);
+ },
+ function disallowedFtpHostDisallowed() {
+ // The host is the same as the current page, but the scheme differs.
+ // The origin is not whitelisted, so the same origin policy must kick in
+ // and block the request.
+ doReq('ftp://localhost', false);
}
]);
});
« no previous file with comments | « chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698