forked from badeball/karma-jsdom-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·55 lines (44 loc) · 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var jsdom = require("jsdom");
function assign (destination, source) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
destination[key] = source[key];
}
}
return destination;
}
var jsdomBrowser = function (baseBrowserDecorator, config) {
baseBrowserDecorator(this);
this.name = "jsdom";
this._start = function (url) {
if (jsdom.JSDOM) { // Indicate jsdom >= 10.0.0 and a new API
var jsdomOptions = {
resources: "usable",
runScripts: "dangerously"
};
if (config && config.jsdom) {
jsdomOptions = assign(jsdomOptions, config.jsdom);
}
jsdom.JSDOM.fromURL(url, jsdomOptions);
} else {
var jsdomOptions = {
url: url,
features : {
FetchExternalResources: ["script", "iframe"],
ProcessExternalResources: ["script"]
},
created: function (error, window) {
// Do nothing.
}
}
if (config && config.jsdom) {
jsdomOptions = assign(jsdomOptions, config.jsdom);
}
jsdom.env(jsdomOptions);
}
};
};
jsdomBrowser.$inject = ["baseBrowserDecorator", "config.jsdomLauncher"];
module.exports = {
"launcher:jsdom": ["type", jsdomBrowser]
};