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

Unified Diff: test/_common.js

Issue 29355872: Issue 4223 - Adapt synchronizer tests to work in adblockpluscore repository (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created Oct. 5, 2016, 8:05 a.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/filterListener.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
@@ -22,19 +22,22 @@ let path = require("path");
let SandboxedModule = require("sandboxed-module");
let globals = {
atob: data => new Buffer(data, "base64").toString("binary"),
btoa: data => new Buffer(data, "binary").toString("base64"),
Ci: {
},
Cu: {
- import: () =>
- {
- }
+ import: () => {},
+ reportError: e => undefined
+ },
+ console: {
+ log: () => undefined,
kzar 2016/10/05 11:36:51 I think suppressing logging for all tests might be
Wladimir Palant 2016/10/05 12:12:51 Not really. An exception in a test should still be
kzar 2016/10/05 12:18:16 Yea, a switch to enable logging would be pretty us
+ error: () => undefined,
},
navigator: {
},
onShutdown: {
add: () =>
{
}
},
@@ -82,23 +85,26 @@ function rewriteRequires(source)
return source.replace(/(\brequire\(["'])([^"']+)/g, (match, prefix, request) =>
{
if (request in knownModules)
return prefix + escapeString(knownModules[request]);
return match;
});
}
-exports.createSandbox = function(extraExports)
+exports.createSandbox = function(options)
{
+ if (!options)
+ options = {};
+
let sourceTransformers = [rewriteRequires];
- if (extraExports)
- sourceTransformers.push(addExports(extraExports));
+ if (options.extraExports)
+ sourceTransformers.push(addExports(options.extraExports));
// This module loads itself into a sandbox, keeping track of the require
// function which can be used to load further modules into the sandbox.
return SandboxedModule.require("./_common", {
- globals: globals,
+ globals: Object.assign({}, globals, options.globals),
kzar 2016/10/05 11:36:51 (Cool, never heard of Object.assign() before.)
sourceTransformers: sourceTransformers
}).require;
};
exports.require = require;
« no previous file with comments | « no previous file | test/filterListener.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld