Skip to content

fix: only relax the drag target check across WebContents - #53669

Merged
codebytere merged 3 commits into
mainfrom
fix/narrow-webview-cross-drag
Sep 8, 2026
Merged

codebytere merged 3 commits into
mainfrom
fix/narrow-webview-cross-drag

Conversation

@codebytere

@codebytere codebytere commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Description of Change

webview_cross_drag.patch (libchromiumcontent#267, 2017) lets drags cross <webview> boundaries by making WebContentsViewDragSecurityInfo::IsValidDragTarget return true unconditionally. That function is the browser-side half of crbug.com/59081: when a drag was started by the same top-level WebContentsView, it refuses drop targets whose SiteInstanceGroup differs from the source, so a page cannot use a drag to move data into or out of a cross-site iframe without the renderer-side DragController check being the only line of defense. The patch switched that off for every Electron app, not just for guests.

Guests hit the check because inner WebContents drag through their outermost view (WebContentsViewChildFrame::StartDragging forwards to the embedder's view), so did_initiate_ is set even though source and target are different WebContents. The patch now records the source widget in OnDragInitiated, resolves both widgets to their WebContentsImpl, and allows the drop only when they belong to different WebContents and at least one of them IsGuest() (guest to guest, guest to embedder, embedder to guest); everything else falls through to the upstream SiteInstanceGroup comparison. If the source widget has gone away mid-drag the weak pointer is null and the upstream check applies.

Verified on Linux that it builds and spec/webview-spec.ts is unchanged, and on macOS 26.5 (arm64, in a VM, real pointer drags driven over VNC) against a build of this branch with current main as the control, each drag from a link in the source onto a drop target that logs dataTransfer:

Drag main this PR
<webview> to a second <webview> in the same window drop lands drop lands
page to a cross-site <iframe> in the same page (localhost page, 127.0.0.1 frame) drop lands refused: the frame never sees dragenter, dragend reports none
page to a same-site <iframe> drop lands drop lands

Windows has not been exercised by hand; the code path is shared with macOS (WebContentsViewDragSecurityInfo backs both web_contents_view_mac.mm and web_contents_view_aura.cc).

Checklist

Release Notes

Notes: Fixed an issue where the browser-side check that blocks drag and drop between cross-site frames of the same page was disabled.

webview_cross_drag.patch made WebContentsViewDragSecurityInfo::IsValidDragTarget
return true unconditionally so drags can cross <webview> boundaries, which
also removed the browser-side check that blocks drags between cross-site
frames of the same page (crbug.com/59081) for every Electron app. Keep the
source widget and allow the drop only when source and target belong to
different WebContents; same-WebContents drags go back to the upstream
SiteInstanceGroup comparison.
@codebytere
codebytere requested a review from a team as a code owner September 7, 2026 09:30
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Sep 7, 2026
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 7, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Sep 8, 2026
@codebytere
codebytere merged commit 41bb25d into main Sep 8, 2026
93 of 94 checks passed
@release-clerk

release-clerk Bot commented Sep 8, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where the browser-side check that blocks drag and drop between cross-site frames of the same page was disabled.

@trop

trop Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #53748

@trop trop Bot added the in-flight/45-x-y label Sep 8, 2026
@trop

trop Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #53749

@trop trop Bot removed the target/45-x-y PR should also be added to the "45-x-y" branch. label Sep 8, 2026
@trop

trop Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #53750

@trop trop Bot added in-flight/44-x-y in-flight/43-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. in-flight/43-x-y labels Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants