File tree 3 files changed +42
-0
lines changed 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,25 @@ Returns:
368
368
369
369
Emitted when the renderer process of ` webContents ` crashes or is killed.
370
370
371
+ #### Event: 'render-process-gone'
372
+
373
+ Returns:
374
+
375
+ * ` event ` Event
376
+ * ` webContents ` [ WebContents] ( web-contents.md )
377
+ * ` details ` Object
378
+ * ` reason ` String - The reason the render process is gone. Possible values:
379
+ * ` clean-exit ` - Process exited with an exit code of zero
380
+ * ` abnormal-exit ` - Process exited with a non-zero exit code
381
+ * ` killed ` - Process was sent a SIGTERM or otherwise killed externally
382
+ * ` crashed ` - Process crashed
383
+ * ` oom ` - Process ran out of memory
384
+ * ` launch-failure ` - Process never successfully launched
385
+ * ` integrity-failure ` - Windows code integrity checks failed
386
+
387
+ Emitted when the renderer process unexpectedly dissapears. This is normally
388
+ because it was crashed or killed.
389
+
371
390
### Event: 'accessibility-support-changed' _ macOS_ _ Windows_
372
391
373
392
Returns:
Original file line number Diff line number Diff line change @@ -389,6 +389,10 @@ WebContents.prototype._init = function () {
389
389
app . emit ( 'renderer-process-crashed' , event , this , ...args ) ;
390
390
} ) ;
391
391
392
+ this . on ( 'render-process-gone' , ( event , ...args ) => {
393
+ app . emit ( 'render-process-gone' , event , this , ...args ) ;
394
+ } ) ;
395
+
392
396
// The devtools requests the webContents to reload.
393
397
this . on ( 'devtools-reload-page' , function ( ) {
394
398
this . reload ( ) ;
Original file line number Diff line number Diff line change @@ -427,6 +427,25 @@ describe('app module', () => {
427
427
expect ( webContents ) . to . equal ( w . webContents )
428
428
} )
429
429
430
+ it ( 'should emit render-process-gone event when renderer crashes' , async function ( ) {
431
+ // FIXME: re-enable this test on win32.
432
+ if ( process . platform === 'win32' ) { return this . skip ( ) ; }
433
+ w = new BrowserWindow ( {
434
+ show : false ,
435
+ webPreferences : {
436
+ nodeIntegration : true
437
+ }
438
+ } ) ;
439
+ await w . loadURL ( 'about:blank' ) ;
440
+
441
+ const promise = emittedOnce ( app , 'render-process-gone' ) ;
442
+ w . webContents . executeJavaScript ( 'process.crash()' ) ;
443
+
444
+ const [ , webContents , details ] = await promise ;
445
+ expect ( webContents ) . to . equal ( w . webContents ) ;
446
+ expect ( details . reason ) . to . be . oneOf ( [ 'crashed' , 'abnormal-exit' ] ) ;
447
+ } ) ;
448
+
430
449
ifdescribe ( features . isDesktopCapturerEnabled ( ) ) ( 'desktopCapturer module filtering' , ( ) => {
431
450
it ( 'should emit desktop-capturer-get-sources event when desktopCapturer.getSources() is invoked' , async ( ) => {
432
451
w = new BrowserWindow ( {
You can’t perform that action at this time.
0 commit comments