|
@@ -11,85 +11,96 @@ const {remote} = require('electron')
|
|
|
const {app, BrowserWindow, crashReporter} = remote.require('electron')
|
|
|
|
|
|
describe('crashReporter module', function () {
|
|
|
- var fixtures = path.resolve(__dirname, 'fixtures')
|
|
|
- var w = null
|
|
|
- var originalTempDirectory = null
|
|
|
- var tempDirectory = null
|
|
|
-
|
|
|
- beforeEach(function () {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false
|
|
|
- })
|
|
|
- tempDirectory = temp.mkdirSync('electronCrashReporterSpec-')
|
|
|
- originalTempDirectory = app.getPath('temp')
|
|
|
- app.setPath('temp', tempDirectory)
|
|
|
- })
|
|
|
-
|
|
|
- afterEach(function () {
|
|
|
- app.setPath('temp', originalTempDirectory)
|
|
|
- return closeWindow(w).then(function () { w = null })
|
|
|
- })
|
|
|
-
|
|
|
if (process.mas) {
|
|
|
return
|
|
|
}
|
|
|
+ var fixtures = path.resolve(__dirname, 'fixtures')
|
|
|
+ const generateSpecs = (description, browserWindowOpts) => {
|
|
|
+ describe(description, function () {
|
|
|
+ var w = null
|
|
|
+ var originalTempDirectory = null
|
|
|
+ var tempDirectory = null
|
|
|
+
|
|
|
+ beforeEach(function () {
|
|
|
+ w = new BrowserWindow(Object.assign({
|
|
|
+ show: false
|
|
|
+ }, browserWindowOpts))
|
|
|
+ tempDirectory = temp.mkdirSync('electronCrashReporterSpec-')
|
|
|
+ originalTempDirectory = app.getPath('temp')
|
|
|
+ app.setPath('temp', tempDirectory)
|
|
|
+ })
|
|
|
|
|
|
- it('should send minidump when renderer crashes', function (done) {
|
|
|
- if (process.env.APPVEYOR === 'True') return done()
|
|
|
- if (process.env.TRAVIS === 'true') return done()
|
|
|
-
|
|
|
- this.timeout(120000)
|
|
|
+ afterEach(function () {
|
|
|
+ app.setPath('temp', originalTempDirectory)
|
|
|
+ return closeWindow(w).then(function () { w = null })
|
|
|
+ })
|
|
|
|
|
|
- startServer({
|
|
|
- callback (port) {
|
|
|
- const crashUrl = url.format({
|
|
|
- protocol: 'file',
|
|
|
- pathname: path.join(fixtures, 'api', 'crash.html'),
|
|
|
- search: '?port=' + port
|
|
|
+ it('should send minidump when renderer crashes', function (done) {
|
|
|
+ if (process.env.APPVEYOR === 'True') return done()
|
|
|
+ if (process.env.TRAVIS === 'true') return done()
|
|
|
+
|
|
|
+ this.timeout(120000)
|
|
|
+
|
|
|
+ startServer({
|
|
|
+ callback (port) {
|
|
|
+ const crashUrl = url.format({
|
|
|
+ protocol: 'file',
|
|
|
+ pathname: path.join(fixtures, 'api', 'crash.html'),
|
|
|
+ search: '?port=' + port
|
|
|
+ })
|
|
|
+ w.loadURL(crashUrl)
|
|
|
+ },
|
|
|
+ processType: 'renderer',
|
|
|
+ done: done
|
|
|
})
|
|
|
- w.loadURL(crashUrl)
|
|
|
- },
|
|
|
- processType: 'renderer',
|
|
|
- done: done
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- it('should send minidump when node processes crash', function (done) {
|
|
|
- if (process.env.APPVEYOR === 'True') return done()
|
|
|
- if (process.env.TRAVIS === 'true') return done()
|
|
|
-
|
|
|
- this.timeout(120000)
|
|
|
-
|
|
|
- startServer({
|
|
|
- callback (port) {
|
|
|
- const crashesDir = path.join(app.getPath('temp'), `${app.getName()} Crashes`)
|
|
|
- const version = app.getVersion()
|
|
|
- const crashPath = path.join(fixtures, 'module', 'crash.js')
|
|
|
- childProcess.fork(crashPath, [port, version, crashesDir], {silent: true})
|
|
|
- },
|
|
|
- processType: 'browser',
|
|
|
- done: done
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- it('should send minidump with updated extra parameters', function (done) {
|
|
|
- if (process.env.APPVEYOR === 'True') return done()
|
|
|
- if (process.env.TRAVIS === 'true') return done()
|
|
|
+ })
|
|
|
|
|
|
- this.timeout(10000)
|
|
|
+ it('should send minidump when node processes crash', function (done) {
|
|
|
+ if (process.env.APPVEYOR === 'True') return done()
|
|
|
+ if (process.env.TRAVIS === 'true') return done()
|
|
|
+
|
|
|
+ this.timeout(120000)
|
|
|
+
|
|
|
+ startServer({
|
|
|
+ callback (port) {
|
|
|
+ const crashesDir = path.join(app.getPath('temp'), `${app.getName()} Crashes`)
|
|
|
+ const version = app.getVersion()
|
|
|
+ const crashPath = path.join(fixtures, 'module', 'crash.js')
|
|
|
+ childProcess.fork(crashPath, [port, version, crashesDir], {silent: true})
|
|
|
+ },
|
|
|
+ processType: 'browser',
|
|
|
+ done: done
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
- startServer({
|
|
|
- callback (port) {
|
|
|
- const crashUrl = url.format({
|
|
|
- protocol: 'file',
|
|
|
- pathname: path.join(fixtures, 'api', 'crash-restart.html'),
|
|
|
- search: '?port=' + port
|
|
|
+ it('should send minidump with updated extra parameters', function (done) {
|
|
|
+ if (process.env.APPVEYOR === 'True') return done()
|
|
|
+ if (process.env.TRAVIS === 'true') return done()
|
|
|
+
|
|
|
+ this.timeout(10000)
|
|
|
+
|
|
|
+ startServer({
|
|
|
+ callback (port) {
|
|
|
+ const crashUrl = url.format({
|
|
|
+ protocol: 'file',
|
|
|
+ pathname: path.join(fixtures, 'api', 'crash-restart.html'),
|
|
|
+ search: '?port=' + port
|
|
|
+ })
|
|
|
+ w.loadURL(crashUrl)
|
|
|
+ },
|
|
|
+ processType: 'renderer',
|
|
|
+ done: done
|
|
|
})
|
|
|
- w.loadURL(crashUrl)
|
|
|
- },
|
|
|
- processType: 'renderer',
|
|
|
- done: done
|
|
|
+ })
|
|
|
})
|
|
|
+ }
|
|
|
+
|
|
|
+ generateSpecs('without sandbox', {})
|
|
|
+ generateSpecs('with sandbox ', {
|
|
|
+ webPreferences: {
|
|
|
+ sandbox: true,
|
|
|
+ preload: path.join(fixtures, 'module', 'preload-sandbox.js')
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
describe('.start(options)', function () {
|