Skip to content

Commit 6537fce

Browse files
committed
fix bug of crash on reload
1 parent 24b82dc commit 6537fce

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

tests/automatic_tests/crashonreload/index.html

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010
var gui = require('nw.gui');
1111
var win = gui.Window.get();
1212
win.showDevTools('devtools');
13-
setTimeout(function() {
14-
location.reload();
15-
}, 2000);
16-
setTimeout(function() {
17-
var client = require('../../nw_test_app').createClient({
18-
argv: gui.App.argv,
19-
data: 'ok'
20-
});
21-
}, 3000);
13+
14+
win.on('loaded',function(){
15+
setTimeout(function() {
16+
location.reload();
17+
}, 1000);
18+
})
2219
</script>
2320
</body>
2421
</html>
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1+
var spawn = require('child_process').spawn;
2+
var path = require('path');
13
var app_test = require('./nw_test_app');
24
describe('crash on reload',function(){
35
it('nw should not crash when reloading with devtool opened',function(done){
46
this.timeout(0);
57
var result = false;
6-
var child = app_test.createChildProcess({
7-
execPath: process.execPath,
8-
appPath: path.join(global.tests_dir, 'crashonreload'),
9-
end: function(data, app) {
8+
var exec_argv = [path.join(global.tests_dir, 'crashonreload')];
9+
10+
var app = spawn(process.execPath, exec_argv);
11+
app.on('exit', function (code){
12+
if (code != 0) return done('nw crashes');
13+
result = true;
14+
done();
15+
});
16+
setTimeout(function(){
17+
if (!result) {
1018
app.kill();
11-
result = true;
12-
if (data == 'ok') {
13-
done();
14-
}
15-
else
16-
done('the nw crashes');
19+
done();
1720
}
18-
});
19-
setTimeout(function() {
20-
if (!result) {
21-
child.close();
22-
done('nw crashes when reloading with devtool opened');
23-
}
24-
}, 4000);
21+
}, 7500);
2522
})
2623
})

0 commit comments

Comments
 (0)