| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 /* | 
|  | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
|  | 3  * Copyright (C) 2006-2015 Eyeo GmbH | 
|  | 4  * | 
|  | 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 | 
|  | 7  * published by the Free Software Foundation. | 
|  | 8  * | 
|  | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
|  | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12  * GNU General Public License for more details. | 
|  | 13  * | 
|  | 14  * You should have received a copy of the GNU General Public License | 
|  | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
|  | 16  */ | 
|  | 17 | 
|  | 18 (function(global) | 
|  | 19 { | 
|  | 20   if ("fetch" in global) | 
|  | 21     return; | 
|  | 22 | 
|  | 23   function Response(xhr) | 
|  | 24   { | 
|  | 25     this._xhr = xhr; | 
|  | 26   } | 
|  | 27   Response.prototype = { | 
|  | 28     get ok() | 
|  | 29     { | 
|  | 30       return this._xhr.status >= 200 && this._xhr.status <= 299; | 
|  | 31     }, | 
|  | 32     text: function() | 
|  | 33     { | 
|  | 34       return Promise.resolve(this._xhr.responseText); | 
|  | 35     } | 
|  | 36   }; | 
|  | 37 | 
|  | 38   global.fetch = function(url) | 
|  | 39   { | 
|  | 40     return new Promise(function(resolve, reject) | 
|  | 41     { | 
|  | 42       var xhr = new XMLHttpRequest(); | 
|  | 43 | 
|  | 44       xhr.onload = function() | 
|  | 45       { | 
|  | 46         resolve(new Response(xhr)); | 
|  | 47       }; | 
|  | 48       xhr.onerror = function() | 
|  | 49       { | 
|  | 50         reject(new TypeError("Failed to fetch")); | 
|  | 51       }; | 
|  | 52 | 
|  | 53       xhr.open("GET", url); | 
|  | 54       xhr.send(); | 
|  | 55     }); | 
|  | 56   }; | 
|  | 57 })(this); | 
| OLD | NEW | 
|---|