diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 86ef660b6a4f..b0b8e9b763ed 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -4,7 +4,7 @@ const {EventEmitter} = require('events') const electron = require('electron') const path = require('path') const url = require('url') -const {app, ipcMain, session, NavigationController} = electron +const {app, ipcMain, session, NavigationController, deprecate} = electron // session is not used here, the purpose is to make sure session is initalized // before the webContents module. @@ -165,6 +165,14 @@ for (const method of webFrameMethodsWithResult) { } } +const nativeOpenDevTools = WebContents.prototype.openDevTools +WebContents.prototype.openDevTools = function (params) { + if (!process.noDeprecations && params && 'detach' in params) { + deprecate.warn('webContents.openDevTools({detach: true})', `webContents.openDevTools({mode: 'detach'})`) + } + return nativeOpenDevTools.call(this, params) +} + // Make sure WebContents::executeJavaScript would run the code only when the // WebContents has been loaded. WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {