From 88dc28124267cf01b4a18bef3eb854232ad6555f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 2 Aug 2016 16:23:12 -0700 Subject: [PATCH] Use web contents id when pid is unavailable --- spec/coverage/reporter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/coverage/reporter.js b/spec/coverage/reporter.js index e813eed52d12..4487c3cdf56e 100644 --- a/spec/coverage/reporter.js +++ b/spec/coverage/reporter.js @@ -73,9 +73,9 @@ const saveCoverageData = (coverage, pid) => { } const getCoverageFromWebContents = (webContents, callback) => { - webContents.executeJavaScript('[global.__coverage__, global.process && global.process.pid]', (results) => { + webContents.executeJavaScript('[window.__coverage__, window.process && window.process.pid]', (results) => { const coverage = results[0] - const pid = results[1] + const pid = results[1] || webContents.getId() callback(coverage, pid) }) } @@ -102,13 +102,13 @@ const saveCoverageOnBeforeUnload = () => { const {app, ipcMain} = require('electron') ipcMain.on('save-coverage', function (event, coverage, pid) { - saveCoverageData(coverage, pid) + saveCoverageData(coverage, pid || event.sender.getId()) }) app.on('web-contents-created', function (event, webContents) { webContents.executeJavaScript(` window.addEventListener('beforeunload', function () { - require('electron').ipcRenderer.send('save-coverage', global.__coverage__, process && process.pid) + require('electron').ipcRenderer.send('save-coverage', window.__coverage__, window.process && window.process.pid) }) `) })