2013-12-06 14:23:02 +00:00
|
|
|
assert = require 'assert'
|
|
|
|
path = require 'path'
|
|
|
|
http = require 'http'
|
2014-04-24 07:42:37 +00:00
|
|
|
url = require 'url'
|
2015-11-10 08:21:08 +00:00
|
|
|
multiparty = require 'multiparty'
|
2013-11-14 16:10:43 +00:00
|
|
|
|
2015-11-12 10:28:04 +00:00
|
|
|
{remote} = require 'electron'
|
|
|
|
{app, crashReporter, BrowserWindow} = remote.require 'electron'
|
2013-11-14 16:10:43 +00:00
|
|
|
|
|
|
|
describe 'crash-reporter module', ->
|
2013-12-06 14:23:02 +00:00
|
|
|
fixtures = path.resolve __dirname, 'fixtures'
|
|
|
|
|
2014-04-24 08:08:59 +00:00
|
|
|
w = null
|
|
|
|
beforeEach -> w = new BrowserWindow(show: false)
|
|
|
|
afterEach -> w.destroy()
|
|
|
|
|
2015-09-28 07:08:27 +00:00
|
|
|
# It is not working for mas build.
|
|
|
|
return if process.mas
|
|
|
|
|
2015-09-15 06:43:11 +00:00
|
|
|
# The crash-reporter test is not reliable on CI machine.
|
|
|
|
isCI = remote.process.argv[2] == '--ci'
|
|
|
|
return if isCI
|
|
|
|
|
2013-11-14 16:10:43 +00:00
|
|
|
it 'should send minidump when renderer crashes', (done) ->
|
2015-09-15 05:18:01 +00:00
|
|
|
@timeout 120000
|
2015-11-11 02:37:01 +00:00
|
|
|
called = false
|
2013-11-14 16:10:43 +00:00
|
|
|
server = http.createServer (req, res) ->
|
2015-09-15 05:18:01 +00:00
|
|
|
server.close()
|
2015-11-10 08:21:08 +00:00
|
|
|
form = new multiparty.Form()
|
2013-11-15 02:37:22 +00:00
|
|
|
form.parse req, (error, fields, files) ->
|
2015-11-11 02:37:01 +00:00
|
|
|
# This callback can be called for twice sometimes.
|
|
|
|
return if called
|
|
|
|
called = true
|
|
|
|
|
2015-04-14 07:59:45 +00:00
|
|
|
assert.equal fields['prod'], 'Electron'
|
|
|
|
assert.equal fields['ver'], process.versions['electron']
|
2013-11-15 02:37:22 +00:00
|
|
|
assert.equal fields['process_type'], 'renderer'
|
2013-11-18 10:37:32 +00:00
|
|
|
assert.equal fields['platform'], process.platform
|
|
|
|
assert.equal fields['extra1'], 'extra1'
|
|
|
|
assert.equal fields['extra2'], 'extra2'
|
2013-11-26 02:19:50 +00:00
|
|
|
assert.equal fields['_productName'], 'Zombies'
|
|
|
|
assert.equal fields['_companyName'], 'Umbrella Corporation'
|
2015-11-12 10:28:04 +00:00
|
|
|
assert.equal fields['_version'], app.getVersion()
|
2013-11-15 02:37:22 +00:00
|
|
|
|
2014-11-11 08:38:16 +00:00
|
|
|
res.end('abc-123-def')
|
2013-11-15 02:37:22 +00:00
|
|
|
done()
|
2015-06-05 11:48:58 +00:00
|
|
|
# Server port is generated randomly for the first run, it will be reused
|
|
|
|
# when page is refreshed.
|
|
|
|
port = remote.process.port
|
|
|
|
server.listen port, '127.0.0.1', ->
|
2014-05-05 21:06:47 +00:00
|
|
|
{port} = server.address()
|
2015-06-05 11:48:58 +00:00
|
|
|
remote.process.port = port
|
2014-04-24 07:42:37 +00:00
|
|
|
url = url.format
|
|
|
|
protocol: 'file'
|
|
|
|
pathname: path.join fixtures, 'api', 'crash.html'
|
|
|
|
search: "?port=#{port}"
|
2015-11-06 13:00:38 +00:00
|
|
|
if process.platform is 'darwin'
|
|
|
|
crashReporter.start {'submitUrl': 'http://127.0.0.1:' + port}
|
2014-04-24 07:42:37 +00:00
|
|
|
w.loadUrl url
|