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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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: console.log.bind(console), | 95 log: console.log.bind(console), |
96 error: console.error.bind(console) | 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.maybeExpectError = function(msg, test) | 422 exports.silenceAssertionOutput = function(test, msg) |
sergei
2017/11/24 10:15:28
What about calling it `silenceAssertionOutput`?
sergei
2017/11/24 13:49:13
JIC, I also thought that we could want to actually
hub
2017/11/24 15:48:59
Done.
hub
2017/11/24 15:48:59
I thought about expecting the output but then I'd
| |
423 { | 423 { |
424 let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`); | 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; | 425 let errorHandler = globals.console.error; |
sergei
2017/11/24 10:15:28
I think it's OK taking into account that `console`
hub
2017/11/24 15:48:59
I'm missing a patch here where we actualle make co
| |
426 globals.console.error = s => | 426 globals.console.error = s => |
427 { | 427 { |
428 if (!msgMatch.test(s) && typeof errorHandler === "function") | 428 if (!msgMatch.test(s)) |
sergei
2017/11/24 10:15:28
I think we should not test the type of errorHandle
hub
2017/11/24 15:48:59
Acknowledged.
| |
429 errorHandler(s); | 429 errorHandler(s); |
430 }; | 430 }; |
431 try | 431 try |
432 { | 432 { |
433 test(); | 433 return test(); |
sergei
2017/11/24 10:15:28
IMO we should return the result of `test()` for th
hub
2017/11/24 15:48:59
Acknowledged.
| |
434 } | 434 } |
435 finally | 435 finally |
436 { | 436 { |
437 globals.console.error = errorHandler; | 437 globals.console.error = errorHandler; |
438 } | 438 } |
439 }; | 439 }; |
440 | 440 |
441 exports.setupRandomResult = function() | 441 exports.setupRandomResult = function() |
442 { | 442 { |
443 let randomResult = 0.5; | 443 let randomResult = 0.5; |
444 Object.defineProperty(this, "randomResult", { | 444 Object.defineProperty(this, "randomResult", { |
445 get: () => randomResult, | 445 get: () => randomResult, |
446 set: value => randomResult = value | 446 set: value => randomResult = value |
447 }); | 447 }); |
448 | 448 |
449 return { | 449 return { |
450 Math: Object.create(Math, { | 450 Math: Object.create(Math, { |
451 random: { | 451 random: { |
452 value: () => randomResult | 452 value: () => randomResult |
453 } | 453 } |
454 }) | 454 }) |
455 }; | 455 }; |
456 }; | 456 }; |
457 | 457 |
458 exports.unexpectedError = function(error) | 458 exports.unexpectedError = function(error) |
459 { | 459 { |
460 console.error(error); | 460 console.error(error); |
461 this.ok(false, "Unexpected error: " + error); | 461 this.ok(false, "Unexpected error: " + error); |
462 }; | 462 }; |
LEFT | RIGHT |