MarshallOfSound

#53656: fix: report the requesting frame for hid and usb permission checks

Merged
Created: Sep 7, 2026, 2:22:12 AM
Merged: Sep 7, 2026, 10:45:52 AM
6 comments
Target: main

Description of Change

Supersedes #53629 (split: this is the narrow fix; the wider per-frame device permission work is in the follow-up PR stacked on this branch).

  • ElectronHidDelegate / ElectronUsbDelegate ran the hid / usb permission check with a null frame and the origin content handed them, so session.setPermissionCheckHandler saw the top-level document's origin, no requestingUrl, isMainFrame: false and a null webContents for a check made from a subframe — while the chooser controllers already store the grant under the requesting frame's origin. Serial and media were fixed for the same thing in #50679.
  • Carries https://crrev.com/c/8364427 so CanRequestDevicePermission() receives the frame, keys HidService / WebUsbServiceImpl on the requesting frame's origin so grant, check and forget() agree, and passes the frame into CheckPermissionWithDetails.
  • Specs: hid / usb check from a cross-origin iframe reports the iframe's origin, URL, isMainFrame: false and the owning webContents.

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • relevant documentation is changed or added

Release Notes

Notes: Fixed session.setPermissionCheckHandler receiving the top-level origin and a null webContents for hid and usb checks made from a subframe.

Backports

43-x-y
Merged
PR Number
#53689
Merged At
Sep 7, 2026, 1:25:18 PM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#53680
Merged At
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#53679
Merged At
Sep 7, 2026, 12:47:05 PM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron