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

Unified Diff: test/_common.js

Issue 29616611: Issue 6090 - Allow use of console to be seen during tests (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: review feedback Created Nov. 24, 2017, 6:16 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/filterStorage.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/_common.js
===================================================================
--- a/test/_common.js
+++ b/test/_common.js
@@ -87,18 +87,18 @@
throw new Error(
"Attempt to import unknown JavaScript module " + resource
);
},
reportError(e) {}
},
console: {
- log() {},
- error() {}
+ log: console.log.bind(console),
+ error: console.error.bind(console)
},
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
navigator: {
},
onShutdown: {
add() {}
},
URL
};
@@ -414,16 +414,35 @@
Date: {
now: () => currentTime
}
};
};
console.warn = console.log;
+exports.silenceAssertionOutput = function(test, msg)
+{
+ 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.
+ let errorHandler = globals.console.error;
+ globals.console.error = s =>
+ {
+ if (!msgMatch.test(s))
+ errorHandler(s);
+ };
+ try
+ {
+ return test();
+ }
+ finally
+ {
+ globals.console.error = errorHandler;
+ }
+};
+
exports.setupRandomResult = function()
{
let randomResult = 0.5;
Object.defineProperty(this, "randomResult", {
get: () => randomResult,
set: value => randomResult = value
});
« no previous file with comments | « no previous file | test/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld