fix: crash when setWindowOpenHandler
callback throws (#34523)
* fix: crash when setWindowOpenHandler throws * refactor: throw as process uncaughtException event
This commit is contained in:
parent
8de5cdb426
commit
bed38e0985
2 changed files with 77 additions and 8 deletions
|
@ -482,6 +482,7 @@ WebContents.prototype._callWindowOpenHandler = function (event: Electron.Event,
|
|||
if (!this._windowOpenHandler) {
|
||||
return defaultResponse;
|
||||
}
|
||||
|
||||
const response = this._windowOpenHandler(details);
|
||||
|
||||
if (typeof response !== 'object') {
|
||||
|
@ -644,7 +645,15 @@ WebContents.prototype._init = function () {
|
|||
postBody,
|
||||
disposition
|
||||
};
|
||||
const result = this._callWindowOpenHandler(event, details);
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = this._callWindowOpenHandler(event, details);
|
||||
} catch (err) {
|
||||
event.preventDefault();
|
||||
throw err;
|
||||
}
|
||||
|
||||
const options = result.browserWindowConstructorOptions;
|
||||
if (!event.defaultPrevented) {
|
||||
openGuestWindow({
|
||||
|
@ -675,7 +684,15 @@ WebContents.prototype._init = function () {
|
|||
referrer,
|
||||
postBody
|
||||
};
|
||||
const result = this._callWindowOpenHandler(event, details);
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = this._callWindowOpenHandler(event, details);
|
||||
} catch (err) {
|
||||
event.preventDefault();
|
||||
throw err;
|
||||
}
|
||||
|
||||
windowOpenOutlivesOpenerOption = result.outlivesOpener;
|
||||
windowOpenOverriddenOptions = result.browserWindowConstructorOptions;
|
||||
if (!event.defaultPrevented) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue