electron/spec/api-crash-reporter-spec.coffee

50 lines
1.8 KiB
CoffeeScript
Raw Normal View History

assert = require 'assert'
path = require 'path'
http = require 'http'
url = require 'url'
remote = require 'remote'
formidable = require 'formidable'
2013-11-14 16:10:43 +00:00
2015-05-29 23:34:56 +00:00
crashReporter = remote.require 'crash-reporter'
BrowserWindow = remote.require 'browser-window'
2013-11-14 16:10:43 +00:00
describe 'crash-reporter module', ->
fixtures = path.resolve __dirname, 'fixtures'
w = null
beforeEach -> w = new BrowserWindow(show: false)
afterEach -> w.destroy()
# It is not working on 64bit Windows.
2015-04-11 15:03:54 +00:00
return if process.platform is 'win32' and process.arch is 'x64'
2013-11-14 16:10:43 +00:00
it 'should send minidump when renderer crashes', (done) ->
2014-06-23 15:01:50 +00:00
@timeout 60000
2013-11-14 16:10:43 +00:00
server = http.createServer (req, res) ->
form = new formidable.IncomingForm()
process.throwDeprecation = false
form.parse req, (error, fields, files) ->
process.throwDeprecation = true
2015-04-14 07:59:45 +00:00
assert.equal fields['prod'], 'Electron'
assert.equal fields['ver'], process.versions['electron']
assert.equal fields['process_type'], 'renderer'
assert.equal fields['platform'], process.platform
assert.equal fields['extra1'], 'extra1'
assert.equal fields['extra2'], 'extra2'
assert.equal fields['_productName'], 'Zombies'
assert.equal fields['_companyName'], 'Umbrella Corporation'
assert.equal fields['_version'], require('remote').require('app').getVersion()
assert files['upload_file_minidump']['name']?
2014-11-11 08:38:16 +00:00
res.end('abc-123-def')
server.close()
done()
2014-05-05 21:06:47 +00:00
server.listen 0, '127.0.0.1', ->
{port} = server.address()
url = url.format
protocol: 'file'
pathname: path.join fixtures, 'api', 'crash.html'
search: "?port=#{port}"
2015-06-04 07:52:16 +00:00
crashReporter.start {'submitUrl': 'http://127.0.0.1:' + port}
w.loadUrl url