Left: | ||
Right: |
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-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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 if (resourceName && resources.hasOwnProperty(resourceName)) | 85 if (resourceName && resources.hasOwnProperty(resourceName)) |
86 return {[resourceName]: resources[resourceName]}; | 86 return {[resourceName]: resources[resourceName]}; |
87 | 87 |
88 throw new Error( | 88 throw new Error( |
89 "Attempt to import unknown JavaScript module " + resource | 89 "Attempt to import unknown JavaScript module " + resource |
90 ); | 90 ); |
91 }, | 91 }, |
92 reportError(e) {} | 92 reportError(e) {} |
93 }, | 93 }, |
94 console: { | 94 console: { |
95 log() {}, | 95 log: console.log.bind(console), |
96 error() {} | 96 error: console.error.bind(console) |
97 }, | 97 }, |
Wladimir Palant
2017/11/28 12:59:39
Just remove console here, not overriding this glob
hub
2017/11/28 15:29:33
Done in follow up patch
| |
98 navigator: { | 98 navigator: { |
99 }, | 99 }, |
100 onShutdown: { | 100 onShutdown: { |
101 add() {} | 101 add() {} |
102 }, | 102 }, |
103 URL | 103 URL |
104 }; | 104 }; |
105 | 105 |
106 let knownModules = new Map(); | 106 let knownModules = new Map(); |
107 for (let dir of [path.join(__dirname, "stub-modules"), | 107 for (let dir of [path.join(__dirname, "stub-modules"), |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 Cr, | 412 Cr, |
413 XMLHttpRequest, | 413 XMLHttpRequest, |
414 Date: { | 414 Date: { |
415 now: () => currentTime | 415 now: () => currentTime |
416 } | 416 } |
417 }; | 417 }; |
418 }; | 418 }; |
419 | 419 |
420 console.warn = console.log; | 420 console.warn = console.log; |
421 | 421 |
422 exports.silenceAssertionOutput = function(test, msg) | |
423 { | |
424 let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`); | |
Wladimir Palant
2017/11/28 12:59:40
1) Inserting unescaped strings into a regular expr
hub
2017/11/28 15:29:33
Done in followup patch.
| |
425 let errorHandler = globals.console.error; | |
426 globals.console.error = s => | |
427 { | |
428 if (!msgMatch.test(s)) | |
429 errorHandler(s); | |
430 }; | |
431 try | |
432 { | |
433 return test(); | |
434 } | |
435 finally | |
436 { | |
437 globals.console.error = errorHandler; | |
438 } | |
439 }; | |
440 | |
422 exports.setupRandomResult = function() | 441 exports.setupRandomResult = function() |
423 { | 442 { |
424 let randomResult = 0.5; | 443 let randomResult = 0.5; |
425 Object.defineProperty(this, "randomResult", { | 444 Object.defineProperty(this, "randomResult", { |
426 get: () => randomResult, | 445 get: () => randomResult, |
427 set: value => randomResult = value | 446 set: value => randomResult = value |
428 }); | 447 }); |
429 | 448 |
430 return { | 449 return { |
431 Math: Object.create(Math, { | 450 Math: Object.create(Math, { |
432 random: { | 451 random: { |
433 value: () => randomResult | 452 value: () => randomResult |
434 } | 453 } |
435 }) | 454 }) |
436 }; | 455 }; |
437 }; | 456 }; |
438 | 457 |
439 exports.unexpectedError = function(error) | 458 exports.unexpectedError = function(error) |
440 { | 459 { |
441 console.error(error); | 460 console.error(error); |
442 this.ok(false, "Unexpected error: " + error); | 461 this.ok(false, "Unexpected error: " + error); |
443 }; | 462 }; |
OLD | NEW |