Commit 9eb4e195 authored by Stanley Shyiko's avatar Stanley Shyiko
Browse files

Fixed timeout that could occur if initial url gets loaded before 'devtools-opened' event

parent e070fd2d
...@@ -87,21 +87,21 @@ app.on('ready', function () { ...@@ -87,21 +87,21 @@ app.on('ready', function () {
}); });
} }
bw.webContents.on('devtools-opened', function () { function notifyDevToolsExtensionOfLoad(e) {
function notifyDevToolsExtensionOfLoad() { if (e.sender.getURL() != 'chrome://ensure-electron-resolution/') {
bw.webContents.executeJavaScript('new Image().src = "https://did-finish-load/"'); bw.webContents.executeJavaScript('new Image().src = "https://did-finish-load/"');
} }
}
// fired regardless of the outcome (success or not) // fired regardless of the outcome (success or not)
bw.webContents.on('did-finish-load', notifyDevToolsExtensionOfLoad); bw.webContents.on('did-finish-load', notifyDevToolsExtensionOfLoad);
bw.webContents.on('did-fail-load', function (e, errorCode, errorDescription, url) { bw.webContents.on('did-fail-load', function (e, errorCode, errorDescription, url) {
if (url !== 'chrome://ensure-electron-resolution/' && url !== 'https://did-finish-load/') { if (url !== 'chrome://ensure-electron-resolution/' && url !== 'https://did-finish-load/') {
bw.webContents.removeListener('did-finish-load', notifyDevToolsExtensionOfLoad); bw.webContents.removeListener('did-finish-load', notifyDevToolsExtensionOfLoad);
bw.webContents.executeJavaScript('require("electron").ipcRenderer.send("har-generation-failed", ' + bw.webContents.executeJavaScript('require("electron").ipcRenderer.send("har-generation-failed", ' +
JSON.stringify({errorCode: errorCode, errorDescription: errorDescription}) + ')'); JSON.stringify({errorCode: errorCode, errorDescription: errorDescription}) + ')');
} }
});
}); });
electron.ipcMain.on('devtools-loaded', function (event) { electron.ipcMain.on('devtools-loaded', function (event) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment