Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some ipc messages are not sent when contextIsolation and sandbox are set to true #11922

Closed
pcad opened this issue Feb 14, 2018 · 7 comments · Fixed by #16352
Closed

Some ipc messages are not sent when contextIsolation and sandbox are set to true #11922

pcad opened this issue Feb 14, 2018 · 7 comments · Fixed by #16352

Comments

@pcad
Copy link

pcad commented Feb 14, 2018

  • Electron version: 1.8.2
  • Operating system: MacOS, Windows10

Expected behavior

ipc messages from the main process should be sent to the renderer process when both sandbox and contextIsolation are set.

Actual behavior

ipc messages sent in listeners to webview events are not visible in the renderer process.

How to reproduce

$ git clone https://gist.github.com/4f6c4450cff194838e746ce23e60116d.git
$ cd 4f6c4450cff194838e746ce23e60116d/
$ electron main.js 

The devtools will open and the console will log one message. But the second message on the ipc ping channel is not observed.

Toggling either sandbox or contextIsolation to false allows the ping to travel to the renderer process. In the 1.7.X branch setting both values to true still allows the message to pass through successfully.

@welcome
Copy link

welcome bot commented Feb 14, 2018

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@pcad
Copy link
Author

pcad commented Feb 23, 2018

Updated issue to reflect this presents on Windows 10 as well.

@ckerr
Copy link
Member

ckerr commented Feb 24, 2018

Reproducible in 2.0.x on Ubuntu, as well

@mattbroussard
Copy link

I think this might be a dupe of #10868?

@pcad
Copy link
Author

pcad commented May 29, 2018

It looks like the same issue, but when I try to run this code on 1.7.x line, everything performs as expected. It's only when you move to 1.8 that things stop being sent.

I created a repo that has similar code to the gist above: https://github.com/pcad/electron-ipc-test

Commit 98be5386 uses electron 1.7.15
Commit 70af35f83 uses electron 1.8.2

In 1.7 the message is passed through correctly.
In 1.8 the message is not passed through.

While the commits reference 1.7.15, I also tried 1.7.3 directly to see if something may have happened in some commits in the 1.7.x line.

@SamuelRobotiq
Copy link

+1

desktopCapturer.getSources is also not working in preload.js when contextIsolation and sandbox are enabled.

@aegarbutt
Copy link
Contributor

Thanks to @pcad for providing the context around the last version where it worked and first version where it didn't work.

trop-bot pushed a commit to trop-bot/electron that referenced this issue Jan 10, 2019
IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes electron#11922
alexeykuzmin pushed a commit that referenced this issue Jan 12, 2019
…ed (#16352)

* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes #11922
trop-bot pushed a commit to trop-bot/electron that referenced this issue Jan 12, 2019
IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes electron#11922
alexeykuzmin pushed a commit that referenced this issue Jan 12, 2019
…ed (backport: 4-0-x) (#16376)

* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes #11922
@sofianguy sofianguy moved this from Confirmed Issues to PR in Flight in 3.0.x / 3.1.x Jan 15, 2019
akisctx pushed a commit to akisctx/electron that referenced this issue Jan 22, 2019
…ed (electron#16352)

* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes electron#11922
miniak pushed a commit that referenced this issue Jun 6, 2019
…ed (#16352)

* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes #11922
miniak pushed a commit that referenced this issue Jun 6, 2019
…ed (#16352)

* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes #11922
ckerr pushed a commit that referenced this issue Jun 6, 2019
…ed (#16352) (#18668)

* fix: emit IPC event in correct context if isolation and sandbox enabled

IPC events were not being delivered to renderer processes when both
`contextIsolation` and `sandbox` were enabled. This is because the
`AtomSandboxedRenderFrameObserver` class was incorrectly using the
`MainWorldScriptContext`, rather than conditionally selecting the
context based on if isolation was enabled.

Fixes #11922
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants