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

Delta Between Two Patch Sets: test/_common.js

Issue 29616611: Issue 6090 - Allow use of console to be seen during tests (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Added missing patch. Review feedback Created Nov. 24, 2017, 3:48 p.m.
Right Patch Set: review feedback Created Nov. 24, 2017, 6:16 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | test/filterStorage.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) 422 exports.silenceAssertionOutput = function(test, msg)
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;
426 globals.console.error = s => 426 globals.console.error = s =>
427 { 427 {
428 if (!msgMatch.test(s)) 428 if (!msgMatch.test(s))
429 errorHandler(s); 429 errorHandler(s);
430 }; 430 };
431 let result;
432 try 431 try
433 { 432 {
434 result = test(); 433 return test();
sergei 2017/11/24 16:46:27 There is no necessity in an additional variable, c
hub 2017/11/24 18:17:56 For some reason I believed that return would by-pa
435 } 434 }
436 finally 435 finally
437 { 436 {
438 globals.console.error = errorHandler; 437 globals.console.error = errorHandler;
439 } 438 }
440 return result;
441 }; 439 };
442 440
443 exports.setupRandomResult = function() 441 exports.setupRandomResult = function()
444 { 442 {
445 let randomResult = 0.5; 443 let randomResult = 0.5;
446 Object.defineProperty(this, "randomResult", { 444 Object.defineProperty(this, "randomResult", {
447 get: () => randomResult, 445 get: () => randomResult,
448 set: value => randomResult = value 446 set: value => randomResult = value
449 }); 447 });
450 448
451 return { 449 return {
452 Math: Object.create(Math, { 450 Math: Object.create(Math, {
453 random: { 451 random: {
454 value: () => randomResult 452 value: () => randomResult
455 } 453 }
456 }) 454 })
457 }; 455 };
458 }; 456 };
459 457
460 exports.unexpectedError = function(error) 458 exports.unexpectedError = function(error)
461 { 459 {
462 console.error(error); 460 console.error(error);
463 this.ok(false, "Unexpected error: " + error); 461 this.ok(false, "Unexpected error: " + error);
464 }; 462 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld