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

Side by Side Diff: lib/compat.js

Issue 29398651: Issue 5061 - Update adblockpluscore dependency to 3bdddf0e8343 (Closed)
Patch Set: Update dependency further Created March 30, 2017, 1:55 p.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 | « dependencies ('k') | 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 { 62 {
63 createInstance() { return new FakeTimer(); } 63 createInstance() { return new FakeTimer(); }
64 }, 64 },
65 "@mozilla.org/xmlextras/xmlhttprequest;1": 65 "@mozilla.org/xmlextras/xmlhttprequest;1":
66 { 66 {
67 createInstance() { return new XMLHttpRequest(); } 67 createInstance() { return new XMLHttpRequest(); }
68 } 68 }
69 }, 69 },
70 results: {}, 70 results: {},
71 utils: { 71 utils: {
72 import() 72 import(resource)
73 { 73 {
74 let match = /^resource:\/\/gre\/modules\/(.+)\.jsm$/.exec(resource);
75 let resourceName = match && match[1];
76 if (resourceName && Cu.import.resources.has(resourceName))
77 return {[resourceName]: Cu.import.resources.get(resourceName)};
78
79 throw new Error(
80 "Attempt to import unknown JavaScript module " + resource
81 );
74 }, 82 },
75 reportError(e) 83 reportError(e)
76 { 84 {
77 console.error(e); 85 console.error(e);
78 console.trace(); 86 console.trace();
79 } 87 }
80 }, 88 },
81 manager: null, 89 manager: null,
82 ID() { return null; } 90 ID() { return null; }
83 }; 91 };
84 const Cc = Components.classes; 92 const Cc = Components.classes;
85 const Ci = Components.interfaces; 93 const Ci = Components.interfaces;
86 const Cr = Components.results; 94 const Cr = Components.results;
87 const Cu = Components.utils; 95 const Cu = Components.utils;
88 96
89 let XPCOMUtils = { 97 Cu.import.resources = new Map();
98
99 Cu.import.resources.set("XPCOMUtils", {
90 generateQI() {} 100 generateQI() {}
91 }; 101 });
92 102
93 // 103 //
94 // Fake nsIFile implementation for our I/O 104 // Fake nsIFile implementation for our I/O
95 // 105 //
96 106
97 function FakeFile(path) 107 function FakeFile(path)
98 { 108 {
99 this.path = path; 109 this.path = path;
100 } 110 }
101 FakeFile.prototype = 111 FakeFile.prototype =
(...skipping 18 matching lines...) Expand all
120 { 130 {
121 return {create() {}}; 131 return {create() {}};
122 }, 132 },
123 normalize() {} 133 normalize() {}
124 }; 134 };
125 135
126 // 136 //
127 // Services.jsm module emulation 137 // Services.jsm module emulation
128 // 138 //
129 139
130 let Services = { 140 Cu.import.resources.set("Services", {
131 obs: { 141 obs: {
132 addObserver() {}, 142 addObserver() {},
133 removeObserver() {} 143 removeObserver() {}
134 }, 144 },
135 vc: { 145 vc: {
136 compare(v1, v2) 146 compare(v1, v2)
137 { 147 {
138 function parsePart(s) 148 function parsePart(s)
139 { 149 {
140 if (!s) 150 if (!s)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 let parts2 = v2.split("."); 203 let parts2 = v2.split(".");
194 for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) 204 for (let i = 0; i < Math.max(parts1.length, parts2.length); i++)
195 { 205 {
196 let result = compareParts(parsePart(parts1[i]), parsePart(parts2[i])); 206 let result = compareParts(parsePart(parts1[i]), parsePart(parts2[i]));
197 if (result) 207 if (result)
198 return result; 208 return result;
199 } 209 }
200 return 0; 210 return 0;
201 } 211 }
202 } 212 }
203 }; 213 });
204 214
205 // 215 //
206 // FileUtils.jsm module emulation 216 // FileUtils.jsm module emulation
207 // 217 //
208 218
209 let FileUtils = { 219 Cu.import.resources.set("FileUtils", {
210 PERMS_DIRECTORY: 0 220 PERMS_DIRECTORY: 0
211 }; 221 });
212 222
213 function FakeTimer() 223 function FakeTimer()
214 { 224 {
215 } 225 }
216 FakeTimer.prototype = 226 FakeTimer.prototype =
217 { 227 {
218 delay: 0, 228 delay: 0,
219 callback: null, 229 callback: null,
220 initWithCallback(callback, delay) 230 initWithCallback(callback, delay)
221 { 231 {
(...skipping 26 matching lines...) Expand all
248 status: -1, 258 status: -1,
249 notificationCallbacks: {}, 259 notificationCallbacks: {},
250 loadFlags: 0, 260 loadFlags: 0,
251 INHIBIT_CACHING: 0, 261 INHIBIT_CACHING: 0,
252 VALIDATE_ALWAYS: 0, 262 VALIDATE_ALWAYS: 0,
253 QueryInterface() 263 QueryInterface()
254 { 264 {
255 return this; 265 return this;
256 } 266 }
257 }; 267 };
OLDNEW
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld