| Index: test/_common.js |
| =================================================================== |
| --- a/test/_common.js |
| +++ b/test/_common.js |
| @@ -86,20 +86,16 @@ |
| return {[resourceName]: resources[resourceName]}; |
| throw new Error( |
| "Attempt to import unknown JavaScript module " + resource |
| ); |
| }, |
| reportError(e) {} |
| }, |
| - console: { |
| - log: console.log.bind(console), |
| - error: console.error.bind(console) |
| - }, |
| navigator: { |
| }, |
| onShutdown: { |
| add() {} |
| }, |
| URL |
| }; |
| @@ -416,48 +412,52 @@ |
| } |
| }; |
| }; |
| console.warn = console.log; |
| exports.silenceWarnOutput = function(test, msg) |
| { |
| - let warnHandler = globals.console.warn; |
| - globals.console.warn = s => |
| + let warnHandler = console.warn; |
| + console.warn = (...args) => |
| { |
| + let s = (args[0] instanceof Error ? args[0].message : args[0]); |
| + |
| if (s != msg) |
| - warnHandler(s); |
| + warnHandler(...args); |
| }; |
| try |
| { |
| return test(); |
| } |
| finally |
| { |
| - globals.console.warn = warnHandler; |
| + console.warn = warnHandler; |
| } |
| }; |
| exports.silenceAssertionOutput = function(test, msg) |
| { |
| - let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`); |
| - let errorHandler = globals.console.error; |
| - globals.console.error = s => |
| + let msgMatch = new RegExp("^Error: (.*)[\r\n]"); |
| + let errorHandler = console.error; |
| + console.error = (...args) => |
| { |
| - if (!msgMatch.test(s)) |
| - errorHandler(s); |
| + let s = (args[0] instanceof Error ? args[0].message : args[0]); |
| + let match = s && s.match(msgMatch); |
| + if (!match || match[1] != msg) |
| + errorHandler(...args); |
| }; |
| try |
| { |
| return test(); |
| } |
| finally |
| { |
| - globals.console.error = errorHandler; |
| + console.error = errorHandler; |
| } |
| }; |
| exports.setupRandomResult = function() |
| { |
| let randomResult = 0.5; |
| Object.defineProperty(this, "randomResult", { |
| get: () => randomResult, |