Browse Source

fix: don't warn about enableRemoteModule when it's undefined (#29023)

* fix: don't warn about enableRemoteModule when it's undefined

* fix tests
Jeremy Rose 3 years ago
parent
commit
2ed8e63cfe
2 changed files with 3 additions and 3 deletions
  1. 1 1
      lib/renderer/security-warnings.ts
  2. 2 2
      spec-main/security-warnings-spec.ts

+ 1 - 1
lib/renderer/security-warnings.ts

@@ -270,7 +270,7 @@ const warnAboutAllowedPopups = function () {
 
 const warnAboutRemoteModuleWithRemoteContent = function (webPreferences?: Electron.WebPreferences) {
   if (!webPreferences || isLocalhost()) return;
-  const remoteModuleEnabled = webPreferences.enableRemoteModule != null ? !!webPreferences.enableRemoteModule : true;
+  const remoteModuleEnabled = webPreferences.enableRemoteModule != null ? !!webPreferences.enableRemoteModule : false;
   if (!remoteModuleEnabled) return;
 
   if (getIsRemoteProtocol()) {

+ 2 - 2
spec-main/security-warnings-spec.ts

@@ -228,7 +228,7 @@ describe('security warnings', () => {
       it('should warn about enabled remote module with remote content', async () => {
         w = new BrowserWindow({
           show: false,
-          webPreferences
+          webPreferences: { ...webPreferences, enableRemoteModule: true }
         });
 
         w.loadURL(`${serverUrl}/base-page-security.html`);
@@ -239,7 +239,7 @@ describe('security warnings', () => {
       it('should not warn about enabled remote module with remote content from localhost', async () => {
         w = new BrowserWindow({
           show: false,
-          webPreferences
+          webPreferences: { ...webPreferences, enableRemoteModule: true }
         });
         w.loadURL(`${serverUrl}/base-page-security-onload-message.html`);
         const [,, message] = await emittedUntil(w.webContents, 'console-message', isLoaded);