forked from kangax/html-minifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
51 lines (47 loc) · 1011 Bytes
/
test.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
/* eslint-env phantomjs, qunit */
'use strict';
function load(path) {
var obj = require(path);
for (var key in obj) {
global[key] = obj[key];
}
return obj;
}
var alert = console.log;
var QUnit = load('qunit');
function hook() {
var failures = [];
QUnit.log(function(details) {
if (!details.result) {
failures.push(details);
}
});
QUnit.done(function(details) {
details.failures = failures;
alert(JSON.stringify(details));
});
QUnit.start();
}
if (typeof phantom === 'undefined') {
load('./src/htmlminifier');
require(process.argv[2]);
hook();
}
else {
var system = require('system');
setTimeout(function() {
system.stderr.write('timed out');
phantom.exit(1);
}, 15000);
var page = require('webpage').create();
page.onAlert = function(details) {
console.log(details);
phantom.exit();
};
page.open(system.args[1], function(status) {
if (status !== 'success') {
phantom.exit(1);
}
page.evaluate(hook);
});
}