| OLD | NEW |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 let onShutdown = { | 43 let onShutdown = { |
| 44 done: false, | 44 done: false, |
| 45 add() {}, | 45 add() {}, |
| 46 remove() {} | 46 remove() {} |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // | 49 // |
| 50 // XPCOM emulation | 50 // XPCOM emulation |
| 51 // | 51 // |
| 52 | 52 |
| 53 let Components = | 53 let Components = { |
| 54 { | |
| 55 interfaces: | 54 interfaces: |
| 56 { | 55 { |
| 57 nsIFile: {DIRECTORY_TYPE: 0}, | 56 nsIFile: {DIRECTORY_TYPE: 0}, |
| 58 nsIFileURL() {}, | 57 nsIFileURL() {}, |
| 59 nsIHttpChannel() {}, | 58 nsIHttpChannel() {}, |
| 60 nsITimer: {TYPE_REPEATING_SLACK: 0}, | 59 nsITimer: {TYPE_REPEATING_SLACK: 0}, |
| 61 nsIInterfaceRequestor: null, | 60 nsIInterfaceRequestor: null, |
| 62 nsIChannelEventSink: null | 61 nsIChannelEventSink: null |
| 63 }, | 62 }, |
| 64 classes: | 63 classes: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 } | 83 } |
| 85 }, | 84 }, |
| 86 manager: null, | 85 manager: null, |
| 87 ID() { return null; } | 86 ID() { return null; } |
| 88 }; | 87 }; |
| 89 const Cc = Components.classes; | 88 const Cc = Components.classes; |
| 90 const Ci = Components.interfaces; | 89 const Ci = Components.interfaces; |
| 91 const Cr = Components.results; | 90 const Cr = Components.results; |
| 92 const Cu = Components.utils; | 91 const Cu = Components.utils; |
| 93 | 92 |
| 94 let XPCOMUtils = | 93 let XPCOMUtils = { |
| 95 { | |
| 96 generateQI() {} | 94 generateQI() {} |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 // | 97 // |
| 100 // Fake nsIFile implementation for our I/O | 98 // Fake nsIFile implementation for our I/O |
| 101 // | 99 // |
| 102 | 100 |
| 103 function FakeFile(path) | 101 function FakeFile(path) |
| 104 { | 102 { |
| 105 this.path = path; | 103 this.path = path; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 126 { | 124 { |
| 127 return {create() {}}; | 125 return {create() {}}; |
| 128 }, | 126 }, |
| 129 normalize() {} | 127 normalize() {} |
| 130 }; | 128 }; |
| 131 | 129 |
| 132 // | 130 // |
| 133 // Services.jsm module emulation | 131 // Services.jsm module emulation |
| 134 // | 132 // |
| 135 | 133 |
| 136 let Services = | 134 let Services = { |
| 137 { | |
| 138 obs: { | 135 obs: { |
| 139 addObserver() {}, | 136 addObserver() {}, |
| 140 removeObserver() {} | 137 removeObserver() {} |
| 141 }, | 138 }, |
| 142 vc: { | 139 vc: { |
| 143 compare(v1, v2) | 140 compare(v1, v2) |
| 144 { | 141 { |
| 145 function parsePart(s) | 142 function parsePart(s) |
| 146 { | 143 { |
| 147 if (!s) | 144 if (!s) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 let parts2 = v2.split("."); | 197 let parts2 = v2.split("."); |
| 201 for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) | 198 for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) |
| 202 { | 199 { |
| 203 let result = compareParts(parsePart(parts1[i]), parsePart(parts2[i])); | 200 let result = compareParts(parsePart(parts1[i]), parsePart(parts2[i])); |
| 204 if (result) | 201 if (result) |
| 205 return result; | 202 return result; |
| 206 } | 203 } |
| 207 return 0; | 204 return 0; |
| 208 } | 205 } |
| 209 } | 206 } |
| 210 } | 207 }; |
| 211 | 208 |
| 212 // | 209 // |
| 213 // FileUtils.jsm module emulation | 210 // FileUtils.jsm module emulation |
| 214 // | 211 // |
| 215 | 212 |
| 216 let FileUtils = | 213 let FileUtils = { |
| 217 { | |
| 218 PERMS_DIRECTORY: 0 | 214 PERMS_DIRECTORY: 0 |
| 219 }; | 215 }; |
| 220 | 216 |
| 221 function FakeTimer() | 217 function FakeTimer() |
| 222 { | 218 { |
| 223 } | 219 } |
| 224 FakeTimer.prototype = | 220 FakeTimer.prototype = { |
| 225 { | |
| 226 delay: 0, | 221 delay: 0, |
| 227 callback: null, | 222 callback: null, |
| 228 initWithCallback(callback, delay) | 223 initWithCallback(callback, delay) |
| 229 { | 224 { |
| 230 this.callback = callback; | 225 this.callback = callback; |
| 231 this.delay = delay; | 226 this.delay = delay; |
| 232 this.scheduleTimeout(); | 227 this.scheduleTimeout(); |
| 233 }, | 228 }, |
| 234 scheduleTimeout() | 229 scheduleTimeout() |
| 235 { | 230 { |
| 236 window.setTimeout(() => | 231 window.setTimeout(() => |
| 237 { | 232 { |
| 238 try | 233 try |
| 239 { | 234 { |
| 240 this.callback(); | 235 this.callback(); |
| 241 } | 236 } |
| 242 catch(e) | 237 catch (e) |
| 243 { | 238 { |
| 244 Cu.reportError(e); | 239 Cu.reportError(e); |
| 245 } | 240 } |
| 246 this.scheduleTimeout(); | 241 this.scheduleTimeout(); |
| 247 }, this.delay); | 242 }, this.delay); |
| 248 } | 243 } |
| 249 }; | 244 }; |
| 250 | 245 |
| 251 // | 246 // |
| 252 // Add a channel property to XMLHttpRequest, Synchronizer needs it | 247 // Add a channel property to XMLHttpRequest, Synchronizer needs it |
| 253 // | 248 // |
| 254 | 249 |
| 255 XMLHttpRequest.prototype.channel = | 250 XMLHttpRequest.prototype.channel = { |
| 256 { | |
| 257 status: -1, | 251 status: -1, |
| 258 notificationCallbacks: {}, | 252 notificationCallbacks: {}, |
| 259 loadFlags: 0, | 253 loadFlags: 0, |
| 260 INHIBIT_CACHING: 0, | 254 INHIBIT_CACHING: 0, |
| 261 VALIDATE_ALWAYS: 0, | 255 VALIDATE_ALWAYS: 0, |
| 262 QueryInterface() | 256 QueryInterface() |
| 263 { | 257 { |
| 264 return this; | 258 return this; |
| 265 } | 259 } |
| 266 }; | 260 }; |
| OLD | NEW |