Skip to content

Commit fdcc9ed

Browse files
committed
Merge pull request nwjs#1244 from kingFighter/tests
[test] test case for issue nwjs#1236--App Crashes when you try to open a win...
2 parents 259b081 + 8c828d8 commit fdcc9ed

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
</head>
4+
<body>
5+
hi
6+
<script>
7+
var gui=require('nw.gui');
8+
//The test case require crash dump api
9+
gui.App.setCrashDumpDir('./automatic_tests/after_close_previous_window_then_open_new/tmp');
10+
var win = gui.Window.get(window.open('http://www.google.com'))
11+
win.close(true);
12+
setTimeout(function() {
13+
gui.Window.open('http://www.google.com')
14+
}, 1000);
15+
setTimeout(gui.App.quit, 1500);
16+
</script>
17+
</body>
18+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var path = require('path');
2+
var app_test = require('./nw_test_app');
3+
var assert =require('assert');
4+
var fs = require('fs');
5+
var fs_extra = require('fs-extra');
6+
var spawn = require('child_process').spawn;
7+
var result;
8+
9+
describe('afterpp close previous window then open new', function() {
10+
after(function () {
11+
fs_extra.remove('./automatic_tests/after_close_previous_window_then_open_new/tmp', function (er) {
12+
if (er) throw er;
13+
});
14+
});
15+
16+
before(function(done) {
17+
this.timeout(0);
18+
fs.mkdirSync('./automatic_tests/after_close_previous_window_then_open_new/tmp');
19+
20+
var appPath = path.join(global.tests_dir, 'after_close_previous_window_then_open_new');
21+
22+
var exec_argv = [appPath];
23+
app = spawn(process.execPath, exec_argv);
24+
setTimeout(function() {
25+
done();
26+
}, 2000);
27+
});
28+
29+
it('should not crash', function() {
30+
result = fs.readdirSync('./automatic_tests/after_close_previous_window_then_open_new/tmp');
31+
assert.equal(result.length, 0);
32+
});
33+
34+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "nw-#1236",
3+
"main": "index.html"
4+
}

0 commit comments

Comments
 (0)