Browse Source

docs: deprecation warning for using nativeWindowOpen with nodeIntegration

Cheng Zhao 6 years ago
parent
commit
df70487f80
2 changed files with 14 additions and 0 deletions
  1. 3 0
      docs/api/breaking-changes.md
  2. 11 0
      lib/browser/api/browser-window.js

+ 3 - 0
docs/api/breaking-changes.md

@@ -18,6 +18,9 @@ The following `webPreferences` option default values are deprecated in favor of
 | `nodeIntegration` | `true` | `false` |
 | `webviewTag` | `nodeIntegration` if set else `true` | `false` |
 
+## `nativeWindowOpen`
+
+Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled.
 
 # Planned Breaking API Changes (4.0)
 

+ 11 - 0
lib/browser/api/browser-window.js

@@ -49,6 +49,17 @@ BrowserWindow.prototype._init = function () {
       return
     }
 
+    if (webContents.getLastWebPreferences().nodeIntegration === true) {
+      const message =
+        'Enabling Node.js integration in child windows opened with the ' +
+        '"nativeWindowOpen" option will cause memory leaks, please turn off ' +
+        'the "nodeIntegration" option.\\n' +
+        'From 5.x child windows opened with the "nativeWindowOpen" option ' +
+        'will always have Node.js integration disabled.\\n' +
+        'See https://github.com/electron/electron/pull/15076 for more.'
+      this.webContents.executeJavaScript(`console.warn('${message}')`)
+    }
+
     const { url, frameName } = urlFrameName
     v8Util.deleteHiddenValue(webContents, 'url-framename')
     const options = {