Skip to content

fix(browser): label popups from committed document origins - #30540

Merged
AmethystLiang merged 12 commits into
mainfrom
youtube-popup-identity-repair
Oct 19, 2026
Merged

AmethystLiang merged 12 commits into
mainfrom
youtube-popup-identity-repair

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​754 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​726
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​644 $\color{#cf222e}{\Huge{\mathbf{−}}}$​100 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​544

ELI5

A popup could show the site it intended to load while an opener-written blank page was still running. Both popup presenters now start at about:blank and show an origin only after a document commits. An opaque error page stays neutral even when Electron retains the failed HTTPS URL.

What Changed

The origin bar and native window title read the committed main frame and its security origin. Pending or canceled navigation retains the prior label; page-controlled titles cannot replace the native trust title. Both presenters reuse the existing origin formatter.

Added hidden Electron checks and a harness using the production preload subscription, renderer bridge, store, and mounted browser guest. The harness records current profile-handoff failures for the dependent repair.

Why

The requested URL and load-completion events cannot establish which document is running. Reading committed frame state preserves the original popup and its settings while preventing an uncommitted destination or opaque error page from borrowing a site's label.

Linked Issue

Internal YouTube Studio reauthentication investigation; no existing issue was supplied for this preparation.

Visual Proof

Actual candidate origin-bar renderers captured through CDP, with every window hidden. A baseline screenshot is unavailable; baseline initialization from the requested URL is source-backed.

Pending navigation:

Pending origin bar

Committed origin:

Committed origin bar

Opaque error document:

Opaque error origin bar

Native title checks use hidden main-process snapshots.

Testing

  • Hidden Electron 43.7.8 checks on macOS arm64.
  • Focused and existing popup regressions: 106 passed; one expected baseline failure and two future-contract TODOs are explicitly documented.
  • After the final fixture-launch correction, both CDP suites were rebuilt and rerun: 10 passed, two TODOs.
  • Runtime/exclusion/PR-job routing: 51 checks passed.
  • Node and renderer typechecks; changed-file code quality.

Detailed commands, observations, tested scope and limits: preparation evidence.

Review

This implements the committed-origin portion of the design. The opener-preservation, routing, ownership-lifetime and tab-handoff repair remains blocked by the prerequisite findings in #30537. The YouTube routing defect remains present, and a fresh YouTube challenge has not been validated.

The harness deliberately records three unsafe baseline profile cases; they are not passing repair gates. It starts at synthetic main dispatch and does not prove modifier association or first-navigation authorization.

Agent skill upstream boundary

  • Not applicable; no upstream skill source was copied.

Notes

The existing Linux Electron boundary job includes the new suites, with aggregate/check names preserved. Linux/Windows runtime, SSH/server-hosted authentication, full CI/build and visible/native-focus behavior remain unverified locally. No remote protocol or persistence format changed.

Checklist

  • Scope, before/after behavior, mechanism and rationale explained.
  • Self-reviewed; cross-platform, workspace and remote limits recorded.
  • Candidate visual evidence retained outside Git; missing baseline proof stated.
  • Full CI/build and isolated native-focus validation.
  • Dependent routing safety gates and fresh YouTube challenge.

@AmethystLiang
AmethystLiang force-pushed the youtube-popup-identity-repair branch 2 times, most recently from ca92669 to 094481c Compare October 19, 2026 19:07
@AmethystLiang
AmethystLiang marked this pull request as ready for review October 19, 2026 20:13
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Popup titles and origin-bar labels now use committed main-frame state, with updates for navigation and main-frame load failures. New Electron tests exercise popup-origin behavior and browser link materialization, including profile selection, guest mounting, and source-tab or profile changes. The Linux Electron test command and test discovery include both suites. A missing-source-tab unit test is marked as an expected failure, and a review-evidence README is deleted.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 52442

A popup showing an opaque or sandboxed document can still display a page-controlled title in the native window chrome, which weakens the trust label this change adds. The impact is small and the fix is localized. A pending-navigation test may also pass before its held request starts.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 20 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: labeling popups from committed document origins.
Description check Passed The description is mostly complete and covers the required explanation, changes, rationale, visual proof, testing, limitations, and checklist. It does not provide an actual linked issue and leaves som…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is mostly complete and covers the required explanation, changes, rationale, visual proof, testing, limitations, and checklist. It does not provide an actual linked issue and leaves some validation items incomplete, but the overall description is detailed and relevant.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d149ba9c-a13e-4ac2-b18c-45db11e59d92
📥 Commits

Reviewing files that changed from the base of the PR and between feba21d and aa326a31760e05130027d9c4afd57eb19b41c2b7.

📒 Files selected for processing: 21
  • .github/workflows/pr.yml
  • config/scripts/ci-unit-files.mjs
  • config/scripts/pr-package-test-paths.mjs
  • config/scripts/vitest-node-runtime-files.mjs
  • docs/review-evidence/youtube-popup-origin-preparation/PR_BODY.md
  • docs/review-evidence/youtube-popup-origin-preparation/README.md
  • src/main/browser/browser-link-materialization-electron-fixture.ts
  • src/main/browser/browser-link-materialization.electron.test.ts
  • src/main/browser/browser-popup-background-cdp-probe.ts
  • src/main/browser/browser-popup-native-compatibility.electron.test.ts
  • src/main/browser/browser-popup-native-window.test.ts
  • src/main/browser/browser-popup-native-window.ts
  • src/main/browser/popup-committed-document-url.ts
  • src/main/browser/popup-identity-electron-probe.ts
  • src/main/browser/popup-origin-bar-window.test.ts
  • src/main/browser/popup-origin-bar-window.ts
  • src/main/browser/popup-origin-chrome-electron-fixture.ts
  • src/main/browser/popup-origin-chrome.electron.test.ts
  • src/main/browser/popup-origin-description.ts
  • src/renderer/src/hooks/ipc-events/browser-link-materialization-probe.tsx
  • src/renderer/src/hooks/ipc-events/browser-state-open-link-profile.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@AmethystLiang
AmethystLiang force-pushed the youtube-popup-identity-repair branch from aa326a3 to 7c8b8e7 Compare October 19, 2026 20:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Prevent page titles from replacing the committed-origin… · popup-origin-bar-window.ts:247-252

src/main/browser/popup-origin-bar-window.ts:247-252
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prevent page titles from replacing the committed-origin title.

When a committed page emits page-title-updated, handlePageTitleUpdated calls window.setTitle(title). This replaces the title derived from the committed document origin, while the origin bar still shows the committed origin. Prevent the event before setting the title from page content.

Suggested fix
-  const handlePageTitleUpdated = (_event: Electron.Event, title: string): void => {
+  const handlePageTitleUpdated = (event: Electron.Event, title: string): void => {
+    event.preventDefault()
     if (!window.isDestroyed() && title && currentUrl !== 'about:blank') {
       window.setTitle(title)
     }

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b6cd271-6184-4947-a905-2683a3cbd1d7
📥 Commits

Reviewing files that changed from the base of the PR and between 7c8b8e7471cbb645a12c38a382195819c4414120 and a46e3e7680e221eebe980e038d8a6cc6996e81aa.

📒 Files selected for processing: 2
  • src/main/browser/popup-identity-electron-probe.test.ts
  • src/main/browser/popup-identity-electron-probe.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/main/browser/popup-identity-electron-probe.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@AmethystLiang
AmethystLiang force-pushed the youtube-popup-identity-repair branch from a46e3e7 to 5be5857 Compare October 19, 2026 21:10
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai Fixing. Will be in the next commit

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/main/browser/popup-origin-chrome.electron.test.ts: 1

177-177: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Wait for each held request before asserting retention.

page.evaluate schedules /hold-initial, and the fixture starts loadURL without awaiting it. The redirect path also starts loadURL without waiting for /hold-redirect. Therefore, expectOrigin can observe the previous label before the held request begins, and stop() can run without testing a pending navigation.

Track the request count before each navigation and wait for it to increase before the assertion.

Suggested synchronization
+      const initialHeldCount = requestedPaths.filter(
+        (path) => path === '/hold-initial'
+      ).length
       await page.evaluate((url) => {
         const child = window.open('about:blank', '', 'width=600,height=400')
@@
         child.location.href = url
       }, `${origin}/hold-initial`)
+      await expect
+        .poll(
+          () => requestedPaths.filter((path) => path === '/hold-initial').length,
+          { timeout: 10_000 }
+        )
+        .toBeGreaterThan(initialHeldCount)
       const initial = await expectOrigin('about:blank', kind)
@@
       expect(requestedPaths).not.toContain('/blocked')
       await command('navigate', { url: `${origin}/committed` })
       await expectOrigin(origin, kind)
       const otherOrigin = origin.replace('127.0.0.1', 'localhost')
+      const redirectHeldCount = requestedPaths.filter(
+        (path) => path === '/hold-redirect'
+      ).length
       await command('navigate', { url: `${otherOrigin}/redirect` })
+      await expect
+        .poll(
+          () => requestedPaths.filter((path) => path === '/hold-redirect').length,
+          { timeout: 10_000 }
+        )
+        .toBeGreaterThan(redirectHeldCount)
       await expectOrigin(origin, kind)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9209ebbb-93f3-4e29-8250-9153b65003b5
📥 Commits

Reviewing files that changed from the base of the PR and between a46e3e7680e221eebe980e038d8a6cc6996e81aa and 5be58579f17ae10e7d367eb8313a1713dc2a73e5.

📒 Files selected for processing: 1
  • src/main/browser/popup-origin-chrome.electron.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang Thanks for the update. The finding remains open pending the next commit.

You are interacting with an AI system.

@AmethystLiang
AmethystLiang force-pushed the youtube-popup-identity-repair branch from 5be5857 to 5244266 Compare October 19, 2026 21:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b40c610-c970-4b10-bf09-eb7be604de94
📥 Commits

Reviewing files that changed from the base of the PR and between 5be58579f17ae10e7d367eb8313a1713dc2a73e5 and 5244266.

📒 Files selected for processing: 10
  • src/main/browser/browser-manager-guest-popup-policy.ts
  • src/main/browser/browser-popup-adapter-probe-fixture.ts
  • src/main/browser/browser-popup-native-window.test.ts
  • src/main/browser/browser-popup-native-window.ts
  • src/main/browser/browser-route-guest-popups.ts
  • src/main/browser/popup-committed-origin.ts
  • src/main/browser/popup-origin-bar-window.test.ts
  • src/main/browser/popup-origin-bar-window.ts
  • src/main/browser/popup-origin-chrome-electron-fixture.ts
  • src/main/browser/popup-origin-chrome.electron.test.ts
💤 Files with no reviewable changes: 3
  • src/main/browser/browser-manager-guest-popup-policy.ts
  • src/main/browser/browser-popup-adapter-probe-fixture.ts
  • src/main/browser/browser-route-guest-popups.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai Fixing. Will be in the next commit

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang Thanks for the update. The finding remains open until the fix is complete.

You are interacting with an AI system.

@AmethystLiang
AmethystLiang merged commit f14475c into main Oct 19, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant