return closeWindow(w).then(function () { w = null })
})
+ afterEach(function () {
+ stopCrashService()
+ })
+
afterEach(function (done) {
if (stopServer != null) {
stopServer(done)
stopServer = startServer({
callback (port) {
- const crashesDir = path.join(app.getPath('temp'), `${app.getName()} Crashes`)
+ const crashesDir = path.join(app.getPath('temp'), `Zombies Crashes`)
const version = app.getVersion()
const crashPath = path.join(fixtures, 'module', 'crash.js')
+
+ if (process.platform === 'win32') {
+ const crashServiceProcess = childProcess.spawn(process.execPath, [
+ `--reporter-url=http://127.0.0.1:${port}`,
+ '--application-name=Zombies',
+ `--crashes-directory=${crashesDir}`
+ ], {
+ env: {
+ ELECTRON_INTERNAL_CRASH_SERVICE: 1
+ },
+ detached: true
+ })
+ remote.process.crashServicePid = crashServiceProcess.pid
+ }
+
childProcess.fork(crashPath, [port, version, crashesDir], {silent: true})
},
processType: 'browser',
}
const testDone = (uploaded) => {
if (uploaded) {
- return done(new Error('fail'))
+ return done(new Error('Uploaded crash report'))
}
if (process.platform === 'darwin') {
crashReporter.setUploadToServer(true)
})
}
}
+
+const stopCrashService = () => {
+ const {crashServicePid} = remote.process
+ if (crashServicePid) {
+ remote.process.crashServicePid = 0
+ try {
+ process.kill(crashServicePid)
+ } catch (error) {
+ if (error.code !== 'ESRCH') {
+ throw error
+ }
+ }
+ }
+}
<script type="text/javascript" charset="utf-8">
const {port} = require('url').parse(window.location.href, true).query
-const {crashReporter} = require('electron')
+const {crashReporter, ipcRenderer} = require('electron')
crashReporter.start({
productName: 'Zombies',
}
})
+if (process.platform === 'win32') {
+ ipcRenderer.sendSync('crash-service-pid', crashReporter._crashServiceProcess.pid)
+}
+
setImmediate(() => {
if (process.platform === 'darwin') {
crashReporter.setExtraParameter('extra2', 'extra2')
.argv
var window = null
-process.port = 0 // will be used by crash-reporter spec.
+
+ // will be used by crash-reporter spec.
+process.port = 0
+process.crashServicePid = 0
v8.setFlagsFromString('--expose_gc')
app.commandLine.appendSwitch('js-flags', '--expose_gc')
})
})
+ipcMain.on('crash-service-pid', (event, pid) => {
+ process.crashServicePid = pid
+ event.returnValue = null
+})
+
// Suspend listeners until the next event and then restore them
const suspendListeners = (emitter, eventName, callback) => {
const listeners = emitter.listeners(eventName)