Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/polyfills/fetch.js

Issue 29345235: Issue 4085 - Fallback to XMLHttpRequest if Fetch API is not supported in Edge (Closed)
Patch Set: Created May 29, 2016, 2:33 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // While the Fetch API is natively supported since Chrome 42, before 59 // While the Fetch API is natively supported since Chrome 42, before
60 // Chrome 47 it failed to fetch files from within the extension bundle. 60 // Chrome 47 it failed to fetch files from within the extension bundle.
61 // https://code.google.com/p/chromium/issues/detail?id=466876 61 // https://code.google.com/p/chromium/issues/detail?id=466876
62 var builtinFetch = global.fetch; 62 var builtinFetch = global.fetch;
63 if (builtinFetch) 63 if (builtinFetch)
64 global.fetch = function(url, init) 64 global.fetch = function(url, init)
65 { 65 {
66 return builtinFetch(url, init).catch(function(reason) 66 return builtinFetch(url, init).catch(function(reason)
67 { 67 {
68 if (new URL(url, document.URL).protocol == "chrome-extension:") 68 var protocol = new URL(url, document.URL).protocol;
69 if ((protocol == "chrome-extension:") || (protocol == "ms-browser-extens ion:"))
kzar 2016/08/22 15:47:20 Nit: Mind wrapping this at the || to avoid the lin
kzar 2016/08/22 15:47:20 Not sure what Sebastian thinks but maybe we should
69 return fetch(url); 70 return fetch(url);
70 throw reason; 71 throw reason;
71 }); 72 });
72 }; 73 };
73 else 74 else
74 global.fetch = fetch; 75 global.fetch = fetch;
75 })(this); 76 })(this);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld