deprecation for webContents.openDevTools (#11986)
* deprecate old openDevTools param * add deprecation check and existence check * fix method issues
This commit is contained in:
parent
c2575c4944
commit
719e5a93b4
1 changed files with 9 additions and 1 deletions
|
@ -4,7 +4,7 @@ const {EventEmitter} = require('events')
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const url = require('url')
|
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
|
// session is not used here, the purpose is to make sure session is initalized
|
||||||
// before the webContents module.
|
// 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
|
// Make sure WebContents::executeJavaScript would run the code only when the
|
||||||
// WebContents has been loaded.
|
// WebContents has been loaded.
|
||||||
WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {
|
WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {
|
||||||
|
|
Loading…
Reference in a new issue