Repository navigation
Inherit webPreferences in windows opened via sandbox or nativeWindowOpen - #9972
Conversation
| auto pending_process = (*new_instance)->GetProcess(); | ||
| pending_processes_[pending_process->GetID()] = current_process->GetID(); | ||
| pending_processes_[pending_process->GetID()] = | ||
| content::WebContents::FromRenderFrameHost(render_frame_host);; |
There was a problem hiding this comment.
@zcbenz I'm a little nervous about this change, I'm not sure if there are times when we would have a pending render process host but not a render frame host. Through my testing, it seemed like the render frame host for the proper web contents was passed in each time so it seemed okay to track the pending process to the originating contents.
Do you remember why initially this mapped process host to process host instead of using the frame host to track the web contents doing the navigation?
There was a problem hiding this comment.
I don't remember the details, Chromium frequently changes how renderer process restarts, so some assumptions were no longer valid. If this change passes the tests, I think we can confidently do it.
|
@tarruda Wanted to get your feedback on this since this does change the Seemed nice to have that flexibility given the number of |
| } | ||
| if (!options.webPreferences.sandbox) { | ||
| // These events should only be handled when the guest window is opened by a | ||
| // non-sandboxed renderer for two reasons: |
There was a problem hiding this comment.
@tarruda I removed this because I was seeing a spec failure once options.webPreferences.sandbox was inherited by default from the parent window (line 16).
It looks like it was going down this path previously when a sandboxed window was opening a new window so I wasn't sure if this code was still needed.
Is this check only needed for opening sandboxed windows opened from non-sandbox windows?
On master, if you open a sandbox window then do window.open() the listeners did appear to be registered since the options have no web preferences by default so options.webPreferences.sandbox is false.
There was a problem hiding this comment.
Is this check only needed for opening sandboxed windows opened from non-sandbox windows?
I think it was related to opening sandboxed windows, regardless of the parent. Could also apply to nativeWindowOpen.
On master, if you open a sandbox window then do window.open() the listeners did appear to be registered since the options have no web preferences by default so options.webPreferences.sandbox is false.
Since this code was first added, there were some changes to allow sandbox reuse code from non-sandbox, so it is possible that this is obsolete.
If I remember correctly, you could reproduce the crash by closing a window created by window.open and waiting a bit for the garbage collector. If you can't reproduce this now, I guess it should be fine to remove it.
| } | ||
| if (!options.webPreferences.sandbox) { | ||
| // These events should only be handled when the guest window is opened by a | ||
| // non-sandboxed renderer for two reasons: |
There was a problem hiding this comment.
Is this check only needed for opening sandboxed windows opened from non-sandbox windows?
I think it was related to opening sandboxed windows, regardless of the parent. Could also apply to nativeWindowOpen.
On master, if you open a sandbox window then do window.open() the listeners did appear to be registered since the options have no web preferences by default so options.webPreferences.sandbox is false.
Since this code was first added, there were some changes to allow sandbox reuse code from non-sandbox, so it is possible that this is obsolete.
If I remember correctly, you could reproduce the crash by closing a window created by window.open and waiting a bit for the garbage collector. If you can't reproduce this now, I guess it should be fine to remove it.
Agreed, this is a nice improvement 👍 |
238bec1 to
a7c5de1
Compare
a7c5de1 to
fc53ac3
Compare
Previously both
nativeWindowOpenandsandboxoptions did not support overridingwebPreferencesvianew-windowevents. The preferences from the opener window were used instead when launching render processes for the new windows.This pull request changes this behavior to set configured
webPreferenceswhen creating new windows with an existingwebContents. These preferences are then used when the render process is launched for thewebContents(if applicable).webContentsweb preferences with the configured options when creating a new window with an existing contents.RenderFrameHostinstead ofRenderProcessHostso that lookup viaWebContentscan be done later on.sandboxas an inherited option inguest-window-manager.jsso windows opened from sandboxed windows have it enabled by default.nativeWindowOpenas an inherited option inguest-window-manager.jsso windows opened from native window open windows have it enabled by default.new-windowoption overriding forsandbox/nativeWindowOpenwindows.Refs #9961
Closes #9928