Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 13 matching lines...) Expand all Loading... | |
24 const Cr = exports.Cr = { | 24 const Cr = exports.Cr = { |
25 NS_OK: 0, | 25 NS_OK: 0, |
26 NS_BINDING_ABORTED: 0x804B0002, | 26 NS_BINDING_ABORTED: 0x804B0002, |
27 NS_ERROR_FAILURE: 0x80004005 | 27 NS_ERROR_FAILURE: 0x80004005 |
28 }; | 28 }; |
29 | 29 |
30 const MILLIS_IN_SECOND = exports.MILLIS_IN_SECOND = 1000; | 30 const MILLIS_IN_SECOND = exports.MILLIS_IN_SECOND = 1000; |
31 const MILLIS_IN_MINUTE = exports.MILLIS_IN_MINUTE = 60 * MILLIS_IN_SECOND; | 31 const MILLIS_IN_MINUTE = exports.MILLIS_IN_MINUTE = 60 * MILLIS_IN_SECOND; |
32 const MILLIS_IN_HOUR = exports.MILLIS_IN_HOUR = 60 * MILLIS_IN_MINUTE; | 32 const MILLIS_IN_HOUR = exports.MILLIS_IN_HOUR = 60 * MILLIS_IN_MINUTE; |
33 | 33 |
34 // URL is global in Node 10. In Node 7+ it must be imported. | |
kzar
2018/05/16 13:24:31
(Thanks for noting the versions involved here.)
| |
35 if (global.URL == undefined) | |
kzar
2018/05/16 13:24:31
I wonder why we put it in the global Object here,
hub
2018/05/16 18:33:23
The previous polyfill was to define `function URL(
kzar
2018/05/17 09:49:01
Well for some longer functions we declare them ear
hub
2018/05/17 12:50:46
I had no doubt this would be working.
Done.
| |
36 { | |
37 global.URL = require("url").URL; | |
38 } | |
39 | |
40 let Services = { | 34 let Services = { |
41 obs: { | 35 obs: { |
42 addObserver() {} | 36 addObserver() {} |
43 } | 37 } |
44 }; | 38 }; |
45 let XPCOMUtils = { | 39 let XPCOMUtils = { |
46 generateQI() {} | 40 generateQI() {} |
47 }; | 41 }; |
48 let FileUtils = {}; | 42 let FileUtils = {}; |
49 let resources = {Services, XPCOMUtils, FileUtils}; | 43 let resources = {Services, XPCOMUtils, FileUtils}; |
(...skipping 19 matching lines...) Expand all Loading... | |
69 }, | 63 }, |
70 console: { | 64 console: { |
71 log() {}, | 65 log() {}, |
72 error() {} | 66 error() {} |
73 }, | 67 }, |
74 navigator: { | 68 navigator: { |
75 }, | 69 }, |
76 onShutdown: { | 70 onShutdown: { |
77 add() {} | 71 add() {} |
78 }, | 72 }, |
79 URL | 73 // URL is global in Node 10. In Node 7+ it must be imported. |
74 URL: typeof URL == "undefined" ? require("url").URL : URL | |
80 }; | 75 }; |
81 | 76 |
82 let knownModules = new Map(); | 77 let knownModules = new Map(); |
83 for (let dir of [path.join(__dirname, "stub-modules"), | 78 for (let dir of [path.join(__dirname, "stub-modules"), |
84 path.join(__dirname, "..", "lib")]) | 79 path.join(__dirname, "..", "lib")]) |
85 { | 80 { |
86 for (let file of fs.readdirSync(path.resolve(dir))) | 81 for (let file of fs.readdirSync(path.resolve(dir))) |
87 { | 82 { |
88 if (path.extname(file) == ".js") | 83 if (path.extname(file) == ".js") |
89 knownModules[path.basename(file, ".js")] = path.resolve(dir, file); | 84 knownModules[path.basename(file, ".js")] = path.resolve(dir, file); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 } | 405 } |
411 }) | 406 }) |
412 }; | 407 }; |
413 }; | 408 }; |
414 | 409 |
415 exports.unexpectedError = function(error) | 410 exports.unexpectedError = function(error) |
416 { | 411 { |
417 console.error(error); | 412 console.error(error); |
418 this.ok(false, "Unexpected error: " + error); | 413 this.ok(false, "Unexpected error: " + error); |
419 }; | 414 }; |
LEFT | RIGHT |