Send coverage from chrome extension iframe
This commit is contained in:
Родитель
9aec425ea8
Коммит
60e60d86d1
|
@ -117,6 +117,10 @@ const saveCoverageOnBeforeUnload = () => {
|
|||
saveCoverageData(event.sender, coverage, pid)
|
||||
})
|
||||
|
||||
ipcMain.on('report-coverage', function (event, message) {
|
||||
saveCoverageData(event.sender, message.coverage, `${message.pid}-extension`)
|
||||
})
|
||||
|
||||
app.on('web-contents-created', function (event, webContents) {
|
||||
webContents.executeJavaScript(`
|
||||
window.addEventListener('beforeunload', function () {
|
||||
|
|
|
@ -16,6 +16,15 @@
|
|||
})
|
||||
}
|
||||
|
||||
function reportCoverage () {
|
||||
var message = JSON.stringify({
|
||||
pid: chrome.runtime.id,
|
||||
coverage: window.__coverage__
|
||||
})
|
||||
var coverageMessage = `require('electron').ipcRenderer.send('report-coverage', ${message})`
|
||||
window.chrome.devtools.inspectedWindow.eval(coverageMessage, function () {})
|
||||
}
|
||||
|
||||
testStorage(function (syncItems, localItems) {
|
||||
var message = JSON.stringify({
|
||||
runtimeId: chrome.runtime.id,
|
||||
|
@ -26,6 +35,8 @@
|
|||
sync: syncItems
|
||||
}
|
||||
})
|
||||
|
||||
reportCoverage()
|
||||
var sendMessage = `require('electron').ipcRenderer.send('answer', ${message})`
|
||||
window.chrome.devtools.inspectedWindow.eval(sendMessage, function () {})
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче