Repository navigation
fix(browser): name the requesting frame and the permission in denial notices - #15542
Conversation
…notices Two defects in the same notice, both found by the review of #15481 and left out of it deliberately. The notice named the wrong site. setPermissionRequestHandler passed webContents.getURL(), which is the top-level document, so a permission request from a cross-origin sub-frame was attributed to the embedder. Every PermissionRequest variant carries requestingUrl, so all three call sites now use it and fall back to the top-level document only when it is absent. The notice also showed raw Chromium permission names. humanizePermission mapped two permissions and returned the raw token for the rest. That now matters more: #15481 granted ordinary storage-access and left top-level-storage-access denied, making it the storage denial a user can still hit - rendered as its raw token. The default still returns the raw token. Inventing prose for a permission nobody has seen is worse than showing its real name. Does not change any permission verdict, and does not fix Google sign-in (#15221).
📝 WalkthroughWalkthroughPermission-denial notifications now resolve the requesting URL, fall back to the top-level WebContents URL when needed, and report an empty URL for opaque or invalid URLs. Media flows capture this URL before asynchronous processing. Browser notices now provide descriptions for additional Chromium permissions and retain raw names for unmapped permissions. Tests cover URL fallback, opaque origins, navigation timing, queued denials, and permission text. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/browser/browser-session-partition-policies.ts (1)
44-65: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCapture the fallback URL before the asynchronous media request.
Because
requestSystemMediaAccess()resolves asynchronously,webContents.getURL()runs after the permission flow completes. If the page navigates during that interval, the notice uses the new URL instead of the URL that made the request. CapturerequestingUrl || webContents.getURL()before starting the request and reuse that value in all denial paths.Proposed fix
- const requestingUrl = (details as Electron.PermissionRequest | undefined)?.requestingUrl + const rawUrl = + (details as Electron.PermissionRequest | undefined)?.requestingUrl || webContents.getURL() ... - rawUrl: requestingUrl || webContents.getURL() + rawUrl ... - rawUrl: requestingUrl || webContents.getURL() + rawUrl ... - rawUrl: requestingUrl || webContents.getURL() + rawUrlAlso applies to: 77-77
🧹 Nitpick comments (2)
src/renderer/src/components/browser-pane/navigate/browser-notices.ts (1)
18-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep changed comments concise.
src/renderer/src/components/browser-pane/navigate/browser-notices.ts#L18-L21: replace the four-line explanation with one concise note about raw-token fallback.src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts#L24-L25: shorten or remove the storage-permission rationale.src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts#L38-L39: shorten or remove the unknown-permission rationale.As per coding guidelines, comments must be concise, non-obvious, and brief; prefer one line.
Source: Coding guidelines
src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts (1)
26-48: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd coverage for the new permission mappings.
These tests cover
top-level-storage-accessand the raw-token fallback. They do not cover the new media, idle-detection, display-capture, window-management, keyboardLock, openExternal, fileSystem, HID, USB, serial, MIDI, or speaker-selection labels.Add a table-driven test for the new mappings. This will catch malformed
asked for to ...output and future label regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f91613de-b291-4081-afd9-a5b9b0c4ad78
📒 Files selected for processing (4)
src/main/browser/browser-session-partition-policies.tssrc/main/browser/browser-session-registry.persistence.test.tssrc/renderer/src/components/browser-pane/navigate/browser-notices.test.tssrc/renderer/src/components/browser-pane/navigate/browser-notices.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6578386e-2a95-43fb-b444-f2e5c6df5e11
📒 Files selected for processing (5)
src/main/browser/browser-manager-downloads.test.tssrc/main/browser/browser-session-partition-policies.tssrc/main/browser/browser-session-registry.persistence.test.tssrc/renderer/src/components/browser-pane/navigate/browser-notices.test.tssrc/renderer/src/components/browser-pane/navigate/browser-notices.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| const requestingUrl = details?.requestingUrl | ||
| if (!requestingUrl) { | ||
| return webContents.getURL() | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
file="src/main/browser/browser-session-partition-policies.ts"
printf '%s\n' '--- candidate implementation ---'
cat -n "$file" | sed -n '1,120p'
printf '%s\n' '--- references and tests ---'
rg -n --glob '*.{ts,tsx,js,jsx}' \
'browser-session-partition-policies|requestingUrl|resolve.*Url|getURL\(\)' \
src test tests 2>/dev/null | head -300 || trueRepository: stablyai/orca
Length of output: 50371
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- focused references ---'
rg -n -C 4 \
'resolvePermissionNoticeUrl|notifyPermissionDenied|setPermissionRequestHandler|requestingUrl' \
src/main tests --glob '*.{ts,tsx,js,jsx}' \
| head -250
printf '%s\n' '--- relevant test files ---'
git ls-files | rg 'browser-session-partition-policies(\.|/)|browser-session.*partition.*test|permission.*test' \
| head -100
printf '%s\n' '--- URL behavior probe ---'
node - <<'JS'
for (const value of ['about:blank', 'data:text/html,hello', 'javascript:alert(1)', 'file:///tmp/a', 'https://example.test/a', '']) {
try {
const parsed = new URL(value)
console.log(JSON.stringify({ value, origin: parsed.origin }))
} catch (error) {
console.log(JSON.stringify({ value, error: String(error) }))
}
}
JSRepository: stablyai/orca
Length of output: 23630
🏁 Script executed:
#!/bin/bash
set -eu
test_file="src/main/browser/browser-session-registry.persistence.test.ts"
printf '%s\n' '--- permission URL tests ---'
cat -n "$test_file" | sed -n '500,610p'
printf '%s\n' '--- policy implementation history/context ---'
git diff --stat
git status --short
rg -n -C 3 \
'Opaque frame URLs|requestingUrl: .about:blank|requestingUrl: .data:|getURL:.*about:blank|rawUrl: .about:blank' \
src/main --glob '*.{ts,tsx}' || true
printf '%s\n' '--- exact fallback semantics probe ---'
node - <<'JS'
function current(getURL, requestingUrl) {
if (!requestingUrl) return getURL
try { return new URL(requestingUrl).origin === 'null' ? '' : requestingUrl }
catch { return '' }
}
function proposed(getURL, requestingUrl) {
const candidateUrl = requestingUrl || getURL
if (!candidateUrl) return ''
try { return new URL(candidateUrl).origin === 'null' ? '' : candidateUrl }
catch { return '' }
}
for (const [page, request] of [
['about:blank', undefined],
['data:text/html,hello', undefined],
['file:///tmp/a', undefined],
['', undefined],
['https://top.example/', undefined],
['https://top.example/', 'about:blank'],
['https://top.example/', 'not a URL']
]) {
console.log(JSON.stringify({ page, request, current: current(page, request), proposed: proposed(page, request) }))
}
JSRepository: stablyai/orca
Length of output: 7249
Validate the fallback URL.
When requestingUrl is empty, webContents.getURL() bypasses origin validation. An origin-null top-level URL such as about:blank is then reported as raw text instead of ''. Use one candidate for both paths and add a test for this case.
Source: MCP tools
|
Review complete — ready for Brennan's merge decision. I did not merge. I pushed
Validation is clean: the same-model/high-effort second review returned CLEAN after its first opaque-origin finding was fixed; 81 focused tests passed locally, node/web typechecks passed, native and type-aware lint passed, max-lines and localization guards passed, and all required CI checks passed (E2E correctly skipped because no affected spec was detected). No manual Electron QA was run because this is deterministic attribution/string formatting with direct unit coverage. |
Electron QA — permission denial noticesSHA tested: Verified1. Permission named in English, not a Chromium token A top-level page at
Not 2. Notice names the requesting frame, not the embedding page Parent
Not the parent origin, and not the raw Could not verify in the rendered UI
Did not merge. Did not change source. |
…notices (stablyai#15542) * fix(browser): name the requesting frame and the permission in denial notices Two defects in the same notice, both found by the review of stablyai#15481 and left out of it deliberately. The notice named the wrong site. setPermissionRequestHandler passed webContents.getURL(), which is the top-level document, so a permission request from a cross-origin sub-frame was attributed to the embedder. Every PermissionRequest variant carries requestingUrl, so all three call sites now use it and fall back to the top-level document only when it is absent. The notice also showed raw Chromium permission names. humanizePermission mapped two permissions and returned the raw token for the rest. That now matters more: stablyai#15481 granted ordinary storage-access and left top-level-storage-access denied, making it the storage denial a user can still hit - rendered as its raw token. The default still returns the raw token. Inventing prose for a permission nobody has seen is worse than showing its real name. Does not change any permission verdict, and does not fix Google sign-in (stablyai#15221). * fix(browser): keep permission denial attribution accurate Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
…notices (stablyai#15542) * fix(browser): name the requesting frame and the permission in denial notices Two defects in the same notice, both found by the review of stablyai#15481 and left out of it deliberately. The notice named the wrong site. setPermissionRequestHandler passed webContents.getURL(), which is the top-level document, so a permission request from a cross-origin sub-frame was attributed to the embedder. Every PermissionRequest variant carries requestingUrl, so all three call sites now use it and fall back to the top-level document only when it is absent. The notice also showed raw Chromium permission names. humanizePermission mapped two permissions and returned the raw token for the rest. That now matters more: stablyai#15481 granted ordinary storage-access and left top-level-storage-access denied, making it the storage denial a user can still hit - rendered as its raw token. The default still returns the raw token. Inventing prose for a permission nobody has seen is worse than showing its real name. Does not change any permission verdict, and does not fix Google sign-in (stablyai#15221). * fix(browser): keep permission denial attribution accurate Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.
…notices (stablyai#15542) * fix(browser): name the requesting frame and the permission in denial notices Two defects in the same notice, both found by the review of stablyai#15481 and left out of it deliberately. The notice named the wrong site. setPermissionRequestHandler passed webContents.getURL(), which is the top-level document, so a permission request from a cross-origin sub-frame was attributed to the embedder. Every PermissionRequest variant carries requestingUrl, so all three call sites now use it and fall back to the top-level document only when it is absent. The notice also showed raw Chromium permission names. humanizePermission mapped two permissions and returned the raw token for the rest. That now matters more: stablyai#15481 granted ordinary storage-access and left top-level-storage-access denied, making it the storage denial a user can still hit - rendered as its raw token. The default still returns the raw token. Inventing prose for a permission nobody has seen is worse than showing its real name. Does not change any permission verdict, and does not fix Google sign-in (stablyai#15221). * fix(browser): keep permission denial attribution accurate Capture fallback URLs before asynchronous media permission handling and treat opaque requesters as unknown rather than blaming the top-level page. Clarify permission descriptions and cover origin normalization, navigation races, and mapped copy.


ELI5
When Orca refuses a website some capability, it shows a small notice saying who asked and for what. Both halves could be wrong: it named the wrong site when the request came from an embedded frame, and it often described the capability using an internal codename instead of words.
What Changed
Two independent defects in the same user-facing notice, both surfaced by the review of #15481 and deliberately left out of it.
1. The notice named the wrong site.
setPermissionRequestHandlerpassedwebContents.getURL()as the origin, which is the top-level document. A permission request from a cross-origin sub-frame was therefore attributed to the embedder — the user is toldhttps://news.example.comasked for their location when the request actually came from an ad frame athttps://widget.example.net.Every
PermissionRequestvariant carriesrequestingUrl(MediaAccessPermissionRequest,FilesystemPermissionRequestandOpenExternalPermissionRequestall extend it), so the requesting frame is available at all three call sites. It now uses that, falling back to the top-level document only when absent.2. The notice showed raw Chromium permission names.
humanizePermissionmapped exactly two permissions and returned the raw token for everything else, so users saw strings liketop-level-storage-access,idle-detectionanddisplay-captureverbatim.top-level-storage-accessis the one that matters now: #15481 granted ordinarystorage-accessand deliberately lefttop-level-storage-accessdenied, which makes it the storage denial a user can still hit — and the only one they'd see, in its rawest possible form.Added readable copy for the permissions users can actually reach. The default still returns the raw token, on purpose: inventing prose for a permission nobody has seen yet is worse than showing its real name.
Scope
This does not fix Google sign-in — that was #15216, fixed by #15221. It does not change which permissions are granted or denied; the verdicts are identical before and after. It only changes what the user is told when a denial happens.
Testing
Both halves verified red before the change; reverting both fixes fails both suites.
requestingUrl: https://widget.example.net/embedfrom a guest whose top-level document ishttps://example.com/accountnow reports the widget origin. Red before — it reported the embedder.requestingUrlstill reports the top-level document, rather than crashing or producing an empty origin.top-level-storage-accessrenders in words, and the notice is asserted not to contain the raw token.25/25 across both suites; typecheck clean.