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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 now: () => currentTime | 411 now: () => currentTime |
412 } | 412 } |
413 }; | 413 }; |
414 }; | 414 }; |
415 | 415 |
416 console.warn = console.log; | 416 console.warn = console.log; |
417 | 417 |
418 exports.silenceWarnOutput = function(test, msg) | 418 exports.silenceWarnOutput = function(test, msg) |
419 { | 419 { |
420 let warnHandler = console.warn; | 420 let warnHandler = console.warn; |
421 console.warn = s => | 421 console.warn = (...args) => |
422 { | 422 { |
423 let s = (args[0] instanceof Error ? args[0].message : args[0]); | |
424 | |
423 if (s != msg) | 425 if (s != msg) |
424 warnHandler(s); | 426 warnHandler(...args); |
425 }; | 427 }; |
426 try | 428 try |
427 { | 429 { |
428 return test(); | 430 return test(); |
429 } | 431 } |
430 finally | 432 finally |
431 { | 433 { |
432 console.warn = warnHandler; | 434 console.warn = warnHandler; |
433 } | 435 } |
434 }; | 436 }; |
435 | 437 |
436 exports.silenceAssertionOutput = function(test, msg) | 438 exports.silenceAssertionOutput = function(test, msg) |
437 { | 439 { |
438 let msgMatch = new RegExp("^Error: (.*)[\r\n]"); | 440 let msgMatch = new RegExp("^Error: (.*)[\r\n]"); |
439 let errorHandler = console.error; | 441 let errorHandler = console.error; |
440 console.error = s => | 442 console.error = (...args) => |
sergei
2017/11/28 15:46:22
should not we wrap even a single argument of the l
hub
2017/11/28 15:54:20
This follow our code style.
| |
441 { | 443 { |
442 let match = msgMatch.match(s); | 444 let s = (args[0] instanceof Error ? args[0].message : args[0]); |
sergei
2017/11/28 15:46:22
AFAIR regexp does not have method `match`, it shou
hub
2017/11/28 15:54:20
Already fixed in the patch update. I have no idea
| |
445 let match = s && s.match(msgMatch); | |
443 if (!match || match[1] != msg) | 446 if (!match || match[1] != msg) |
444 errorHandler(s); | 447 errorHandler(...args); |
445 }; | 448 }; |
446 try | 449 try |
447 { | 450 { |
448 return test(); | 451 return test(); |
449 } | 452 } |
450 finally | 453 finally |
451 { | 454 { |
452 console.error = errorHandler; | 455 console.error = errorHandler; |
453 } | 456 } |
454 }; | 457 }; |
(...skipping 13 matching lines...) Expand all Loading... | |
468 } | 471 } |
469 }) | 472 }) |
470 }; | 473 }; |
471 }; | 474 }; |
472 | 475 |
473 exports.unexpectedError = function(error) | 476 exports.unexpectedError = function(error) |
474 { | 477 { |
475 console.error(error); | 478 console.error(error); |
476 this.ok(false, "Unexpected error: " + error); | 479 this.ok(false, "Unexpected error: " + error); |
477 }; | 480 }; |
LEFT | RIGHT |