Run the crash reporter specs with sandbox option.

- Create a function that accepts BrowserWindow options and generates a suite
  that contains the renderer-specific tests.
- Run the function twice to execute the tests with and without sandbox option.
This commit is contained in:
Thiago de Arruda 2017-03-21 10:48:36 -03:00
parent 3a97cfc359
commit 5ee6205c0a
2 changed files with 19 additions and 6 deletions

View file

@ -11,15 +11,20 @@ const {remote} = require('electron')
const {app, BrowserWindow, crashReporter} = remote.require('electron')
describe('crashReporter module', function () {
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({
w = new BrowserWindow(Object.assign({
show: false
})
}, browserWindowOpts))
tempDirectory = temp.mkdirSync('electronCrashReporterSpec-')
originalTempDirectory = app.getPath('temp')
app.setPath('temp', tempDirectory)
@ -30,10 +35,6 @@ describe('crashReporter module', function () {
return closeWindow(w).then(function () { w = null })
})
if (process.mas) {
return
}
it('should send minidump when renderer crashes', function (done) {
if (process.env.APPVEYOR === 'True') return done()
if (process.env.TRAVIS === 'true') return done()
@ -91,6 +92,16 @@ describe('crashReporter module', function () {
done: done
})
})
})
}
generateSpecs('without sandbox', {})
generateSpecs('with sandbox ', {
webPreferences: {
sandbox: true,
preload: path.join(fixtures, 'module', 'preload-sandbox.js')
}
})
describe('.start(options)', function () {
it('requires that the companyName and submitURL options be specified', function () {

View file

@ -1,6 +1,8 @@
(function () {
const {setImmediate} = require('timers')
const {ipcRenderer} = require('electron')
window.ipcRenderer = ipcRenderer
window.setImmediate = setImmediate
if (location.protocol === 'file:') {
window.test = 'preload'
window.require = require