|
|
@ -64,17 +64,30 @@ WebBrowser.prototype = { |
|
|
|
startProcess: function (url) { |
|
|
|
startProcess: function (url) { |
|
|
|
var args = this.buildArguments(url); |
|
|
|
var args = this.buildArguments(url); |
|
|
|
var proc = spawn(this.path, args); |
|
|
|
var proc = spawn(this.path, args); |
|
|
|
proc.on('close', function (code) { |
|
|
|
proc.on('exit', function (code) { |
|
|
|
this.finished = true; |
|
|
|
this.finished = true; |
|
|
|
|
|
|
|
// trying to wait for process to shutdown (for Windows sake)
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
this.cleanup(); |
|
|
|
if (this.callback) { |
|
|
|
if (this.callback) { |
|
|
|
this.callback.call(null, code); |
|
|
|
this.callback.call(null, code); |
|
|
|
} |
|
|
|
} |
|
|
|
this.cleanup(); |
|
|
|
}.bind(this), 500); |
|
|
|
}.bind(this)); |
|
|
|
}.bind(this)); |
|
|
|
return proc; |
|
|
|
return proc; |
|
|
|
}, |
|
|
|
}, |
|
|
|
cleanup: function () { |
|
|
|
cleanup: function () { |
|
|
|
|
|
|
|
try { |
|
|
|
testUtils.removeDirSync(this.tmpDir); |
|
|
|
testUtils.removeDirSync(this.tmpDir); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error('Unable to cleanup after the process: ' + e); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (this.process) { |
|
|
|
|
|
|
|
this.process.kill('SIGKILL'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.process = null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
stop: function (callback) { |
|
|
|
stop: function (callback) { |
|
|
|
if (this.finished) { |
|
|
|
if (this.finished) { |
|
|
@ -85,8 +98,7 @@ WebBrowser.prototype = { |
|
|
|
this.callback = callback; |
|
|
|
this.callback = callback; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.process.kill(); |
|
|
|
this.process.kill('SIGTERM'); |
|
|
|
this.process = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|