isolated-preload.js 664 B

1234567891011121314151617181920
  1. const { ipcRenderer, webFrame } = require('electron')
  2. window.foo = 3
  3. webFrame.executeJavaScript('window.preloadExecuteJavaScriptProperty = 1234;')
  4. window.addEventListener('message', (event) => {
  5. ipcRenderer.send('isolated-world', {
  6. preloadContext: {
  7. preloadProperty: typeof window.foo,
  8. pageProperty: typeof window.hello,
  9. typeofRequire: typeof require,
  10. typeofProcess: typeof process,
  11. typeofArrayPush: typeof Array.prototype.push,
  12. typeofFunctionApply: typeof Function.prototype.apply,
  13. typeofPreloadExecuteJavaScriptProperty: typeof window.preloadExecuteJavaScriptProperty
  14. },
  15. pageContext: event.data
  16. })
  17. })