Does contextBridge.exposeInMainWorld survive same-process renderer navigation?
0 reputation · 21 Nov 2022, 13:17 UTC
Goal
Confirm whether an API exposed through contextBridge.exposeInMainWorld remains available on window after a same-process renderer navigation that does not reload the page, with contextIsolation enabled.
Constraints
Electron runs preload scripts in an isolated world, and same-process navigations may not re-execute the preload script. Behavior can differ between same-document history navigations, cross-origin navigations, and full reloads. Default webPreferences values are version-sensitive, so the target Electron release must be identified before relying on any default.
No error, failed command, or observed result is assumed. This is an open design question about binding lifetime across renderer process reuse.
Does window.exposedApi survive a same-process history.pushState navigation? Does a cross-origin same-process navigation remove contextBridge bindings? Is persistence across same-process navigation guaranteed, or should bindings be re-established after navigation?