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: Converted former loops into separate tests Created Oct. 5, 2016, 9:24 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') | test/synchronizer.js » ('J')
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,
+ 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),
sourceTransformers: sourceTransformers
}).require;
};
exports.require = require;
« no previous file with comments | « no previous file | test/filterListener.js » ('j') | test/synchronizer.js » ('J')

Powered by Google App Engine
This is Rietveld