Skip to content

Commit ad3acfc

Browse files
committed
Merge pull request nwjs#1336 from kingFighter/chromium-args-test
[test] update test-case for chromium-args because 'Intl' is not supporte...
2 parents 98a9b0a + ed66aa8 commit ad3acfc

File tree

5 files changed

+102
-7
lines changed

5 files changed

+102
-7
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>test case for chromium-args</title>
5+
</head>
6+
<body>
7+
<h1>Hello World!</h1>
8+
<script>
9+
var gui = require('nw.gui')
10+
var fs = require('fs');
11+
fs.openSync('./hi', 'w');
12+
var results = false;
13+
if (location.href == 'http://www.baidu.com/')
14+
results = true;
15+
16+
var client = require('../../nw_test_app').createClient({
17+
argv: gui.App.argv,
18+
data: results
19+
});
20+
21+
</script>
22+
</body>
23+
</html>
Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,64 @@
11
var assert = require('assert');
2+
var cp = require('child_process');
3+
var fs = require('fs');
4+
var fs_extra = require('fs-extra');
5+
var exec_path = process.execPath;
6+
var app_path = path.join(global.tests_dir, 'chromium-args');
7+
var app_test = require('./nw_test_app');
28

39
describe('chromium-args', function() {
4-
it("window.Intl should be undefined beacuse disabled in package.json",
5-
function() {
6-
assert.equal(window.Intl, undefined);
7-
}
8-
)
9-
})
10+
describe('--disable-javascript', function() {
11+
before(function(done) {
12+
this.timeout(0);
13+
fs_extra.copy(path.join(app_path, 'package1.json'), path.join(app_path, 'package.json'), function (err) {
14+
if (err) {
15+
throw err;
16+
}
17+
cp.exec(exec_path + " " + app_path, function(err, stdout, stderr) {
18+
})
19+
});
20+
setTimeout(done, 2500);
21+
});
22+
23+
it('javascript should not be executed', function() {
24+
var result = fs.existsSync(path.join(app_path, 'hi'));
25+
assert.equal(result, false);
26+
});
27+
28+
after(function() {
29+
fs.unlink(path.join(app_path, 'hi'), function(err) {if(err && err.code !== 'ENOENT') throw err});
30+
fs.unlink(path.join(app_path, 'package.json'), function(err) {if(err && err.code !== 'ENOENT') throw err});
31+
});
32+
});
33+
34+
describe('--app=url', function() {
35+
var result2 = false;
36+
before(function(done) {
37+
this.timeout(0);
38+
fs_extra.copy(path.join(app_path, 'package2.json'), path.join(app_path, 'package.json'), function (err) {
39+
if (err) {
40+
throw err;
41+
}
42+
var child = app_test.createChildProcess({
43+
execPath: exec_path,
44+
appPath: app_path,
45+
end: function(data, app) {
46+
result2 = data;
47+
app.kill();
48+
done()
49+
}
50+
});
51+
});
52+
});
53+
54+
it('website should be the url', function() {
55+
assert.equal(result2, true);
56+
});
57+
58+
after(function() {
59+
fs.unlink(path.join(app_path, 'package.json'), function(err) {if(err && err.code !== 'ENOENT') throw err});
60+
fs.unlink(path.join(app_path, 'hi'), function(err) {if(err && err.code !== 'ENOENT') throw err});
61+
});
62+
});
63+
64+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "nw-chromium-args",
3+
"main": "index.html",
4+
"window": {
5+
"show": false
6+
},
7+
"chromium-args": "--disable-javascript"
8+
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "nw-chromium-args",
3+
"main": "index.html",
4+
"window": {
5+
"show": false
6+
},
7+
"chromium-args": "--app=http://www.baidu.com"
8+
9+
}

tests/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"bignum": "git+https://github.com/owenc4a4/bignum.git",
2323
"fs-extra": "*"
2424
},
25-
"chromium-args": "--disable-javascript-i18n-api",
2625
"user-agent": "%name/%nwver/%ver/%webkit_ver/%osinfo",
2726
"scripts": {
2827
"install": "python ../tools/build_native_modules.py"

0 commit comments

Comments
 (0)