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

Delta Between Two Patch Sets: test_wrapper.js

Issue 29354864: Issue 4223 - Migrate some more of adblockplustests (Closed)
Left Patch Set: Created Sept. 25, 2016, 1:38 p.m.
Right Patch Set: Addressed final nit Created Oct. 4, 2016, 12: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 | « test_runner.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 "use strict";
2
3 let nodeBabel = require("node-babel");
4 let nodeunit = require("nodeunit");
5 let path = require("path");
6
7 // The Adblock Plus code assumes some things are present in the global scope.
8 // We need to stub them out here to get the tests running.
9 GLOBAL.atob = data => new Buffer(data, "base64").toString("binary");
10 GLOBAL.btoa = data => new Buffer(data, "binary").toString("base64");
11 GLOBAL.Ci = {};
12 GLOBAL.Cu = {
13 import: () => { }
14 };
15 GLOBAL.navigator = {};
16 GLOBAL.onShutdown = {
17 add: () => { }
18 };
19 GLOBAL.Services = {
20 obs: {
21 addObserver: () => { }
22 }
23 };
24 GLOBAL.XPCOMUtils = {
25 generateQI: () => { }
26 };
27
28 // Force the use of our modules over the Node.js builtin modules when the names
29 // clash by messing with the module cache. (It's important we load any Node.js
30 // modules beforehand, otherwise they will might break when given our modules!)
Wladimir Palant 2016/09/26 09:40:58 Messing with the global require function is a bad
kzar 2016/09/29 15:53:10 Done.
31 function forceModule(name, relativePath)
32 {
33 let filename = name + ".js";
34 let absolutePath = path.join(__dirname, relativePath, filename);
35 require(absolutePath);
36 require.cache[name] = require.cache[absolutePath];
37 }
38 forceModule("events", "lib");
39 forceModule("io", "test/stub-modules");
40
41 nodeBabel();
Wladimir Palant 2016/09/26 09:40:58 This should no longer be necessary if we require a
kzar 2016/09/29 15:53:10 Done.
42 nodeunit.reporters.default.run(["test"]);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld