Browse Source

fix: warning when worldSafeExecuteJavaScript is disabled (#27928)

Milan Burda 4 years ago
parent
commit
bf7e445883
1 changed files with 4 additions and 2 deletions
  1. 4 2
      lib/renderer/api/web-frame.ts

+ 4 - 2
lib/renderer/api/web-frame.ts

@@ -48,8 +48,10 @@ class WebFrame extends EventEmitter {
   }
 }
 
-const { hasSwitch } = process._linkedBinding('electron_common_command_line');
-const worldSafeJS = hasSwitch('world-safe-execute-javascript') && hasSwitch('context-isolation');
+const contextIsolation = binding.getWebPreference(window, 'contextIsolation');
+const worldSafeExecuteJavaScript = binding.getWebPreference(window, 'worldSafeExecuteJavaScript');
+
+const worldSafeJS = worldSafeExecuteJavaScript || !contextIsolation;
 
 // Populate the methods.
 for (const name in binding) {