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

Unified Diff: chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/content_script.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
Index: chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/content_script.js
diff --git a/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/content_script.js b/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/content_script.js
index c30c8dddf9ab45569b8f28afd44688350e07913a..c46805a2a4e2b5f2ce91539613a23de79aabe6cd 100644
--- a/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/content_script.js
+++ b/chrome/test/data/extensions/api_test/cross_origin_xhr/content_script/content_script.js
@@ -4,6 +4,7 @@
chrome.extension.onRequest.addListener(
function(url, sender, sendResponse) {
+ var isErrorTriggered = false;
var req = new XMLHttpRequest();
console.log('Requesting url: ' + url);
req.open('GET', url, true);
@@ -16,6 +17,7 @@ chrome.extension.onRequest.addListener(
});
};
req.onerror = function() {
+ isErrorTriggered = true;
sendResponse({
'event': 'error',
'status': req.status,
@@ -23,7 +25,22 @@ chrome.extension.onRequest.addListener(
});
};
- req.send(null);
+ try {
+ req.send(null);
+ } catch (e) {
+ if (/^https?:/i.test(url)) {
+ sendResponse({
+ 'thrownError': 'req.send() has thrown an error for ' + url + ': ' + e
+ });
+ } else if (!isErrorTriggered) {
+ // A NetworkError will synchronously be be thrown whenever a
+ // FTP request fails. This should be handled by req.onerror.
+ sendResponse({
+ 'thrownError': 'req.send() has thrown an error without dispatching ' +
+ 'the req.onerror event for ' + url + ': ' + e
+ });
+ }
+ }
});
chrome.extension.sendRequest('injected');

Powered by Google App Engine
This is Rietveld 408576698