isolated-preload.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Ensure fetch works from isolated world origin
  2. fetch('http://localhost:1234')
  3. fetch('https://localhost:1234')
  4. const {ipcRenderer, webFrame} = require('electron')
  5. window.foo = 3
  6. webFrame.executeJavaScript('window.preloadExecuteJavaScriptProperty = 1234;')
  7. window.addEventListener('message', (event) => {
  8. ipcRenderer.send('isolated-world', {
  9. preloadContext: {
  10. preloadProperty: typeof window.foo,
  11. pageProperty: typeof window.hello,
  12. typeofRequire: typeof require,
  13. typeofProcess: typeof process,
  14. typeofArrayPush: typeof Array.prototype.push,
  15. typeofFunctionApply: typeof Function.prototype.apply
  16. },
  17. pageContext: event.data
  18. })
  19. ipcRenderer.send('isolated-sandbox-world', {
  20. preloadContext: {
  21. preloadProperty: typeof window.foo,
  22. pageProperty: typeof window.hello,
  23. typeofRequire: typeof require,
  24. typeofProcess: typeof process,
  25. typeofArrayPush: typeof Array.prototype.push,
  26. typeofFunctionApply: typeof Function.prototype.apply
  27. },
  28. pageContext: event.data
  29. })
  30. })