Browse Source

add webFrame to sandboxed renderer

sungpark 7 years ago
parent
commit
eca7ff986c

+ 1 - 1
docs/api/sandbox-option.md

@@ -166,7 +166,7 @@ Currently the `require` function provided in the preload scope exposes the
 following modules:
 
 - `child_process`
-- `electron` (crashReporter, remote and ipcRenderer)
+- `electron` (crashReporter, remote, ipcRenderer, and webFrame)
 - `fs`
 - `os`
 - `timers`

+ 6 - 0
lib/sandboxed_renderer/api/exports/electron.js

@@ -11,6 +11,12 @@ Object.defineProperties(exports, {
       return require('../../../renderer/api/remote')
     }
   },
+  webFrame: {
+    enumerable: true,
+    get: function () {
+      return require('../../../renderer/api/web-frame')
+    }
+  },
   crashReporter: {
     enumerable: true,
     get: function () {

+ 2 - 0
spec/fixtures/api/isolated-preload.js

@@ -6,6 +6,8 @@ const {ipcRenderer, webFrame} = require('electron')
 
 window.foo = 3
 
+webFrame.executeJavaScript('window.preloadExecuteJavaScriptProperty = 1234;')
+
 window.addEventListener('message', (event) => {
   ipcRenderer.send('isolated-world', {
     preloadContext: {

+ 0 - 1
spec/fixtures/api/isolated.html

@@ -7,7 +7,6 @@
       window.hello = 'world'
       Array.prototype.push = 3
       Function.prototype.apply = true
-      window.preloadExecuteJavaScriptProperty = 1234;
 
       const opened = window.open()
       opened.close()