Repository navigation
fix(window): reuse named windows and frames for noopener opens - #2782
lanyue-llk wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Independent review of 65d5ff5
No blocking findings
- Correctness: the fix is in the right place. The named lookup in
renderer_owned.rs:124(open_renderer_owned_auxiliary_window, shared bywindow.openand hyperlinks) and the named-iframe branch indialogs.rs:298-308are no longer gated on opener exposure. The noopener call still returnsnull(dialogs.rs:303,:461). The reused window's opener is neither set nor cleared (update_existing_opener && exposes_opener). Chrome 157 behaves the same: afteropen(u,'report3','noopener')reuses a popup,p.opener===windowstaystrue. A noopener open with an unmatched name still creates a context with its ownRendererBrowsingContextName::default()group, whichis_related_tokeeps out of later lookups. Reuse resolves on the browser side throughbrowsing_context_name(target/popup.rs:203), so it does not depend onexposes_opener. Named targets that are cross-origin or sandboxed now use exactly the same lookup and navigation path as opens without noopener._blank,_self,_parentand_topare handled before this code and are unchanged. - Issue comment (self-named case):
named_related_windowchecks the initiator's own context first (document_isolate.rs:488), soopen('#self2','shared2','noopener')withwindow.name==='shared2'now selects the page itself, as Chrome does, and does not create ap.html#self2target. That is what the non-noopener path already does on v1.1.23 (selectedSelf:true, no new target). On v1.1.23 the noopener variant and<a target=shared3 rel=noopener href=#self3>both create a new target, while Chrome navigates the page itself. This case is not in the verification table or the test; adding one line for it to the CDP test would cover the issue comment. - Tests:
noopener_window_open_reuses_existing_named_window_and_framefails without the fix:wait_for_value(p1 ... "/second")times out because main opens a new window. It checks only Chromium behaviour. Updatingpopup_navigation_referrer.rsis right because the oldchild-0sharing assumed non-Chromium behaviour. - Cost: the lookup that now also runs for noopener opens already ran for every named open. The before/after numbers are within noise.
- CI: Format, Clippy, Node, Python and Windows checks pass on 65d5ff5. Nextest, CDP smoke and both release builds were still pending when this was posted, about 35 minutes after the push. The previous run (7f111d7) failed Nextest. The PR says the failing test was
popup_navigation_uses_source_referrer_policy_and_window_features, which assumed non-Chromium behaviour and is updated in 65d5ff5. I could not fetch that log to confirm it was the only failure. Confirm that Nextest is green before merging. - Picture: pending
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of 306f6a2
No blocking findings
- Lightweight path (
popups.rs:687,open_lightweight_popup_window) now matches the browser-side path:window.openstill returnsnullunder noopener (dialogs.rs:461, after the lightweight branch).- The reused popup's opener is neither set nor cleared.
openerisNoneunder noopener (dialogs.rs:328,targets.rs:43), soupdate_existing_opener && let Some(opener)(popups.rs:699) skips the slot. The new test checkspopup.opener === windowafter reuse. - Isolated noopener popups stay invisible to later lookups. A popup created with
opener == Nonegetsname_lookup_allowed: false(popups.rs:934), and the lookup still requiresrecord.name_lookup_allowed(popups.rs:694). A secondopen(u,'x','noopener')with no opener-visiblextherefore still creates a new popup.
- Other
moli fetchpopup behaviour is unchanged:- Service-worker
clients.openWindowand the notification navigate path pass"_blank".trackable_lightweight_popup_window_namereturnsNonefor it, so they never reach the lookup. - Unnamed and
_blanknoopener opens and hyperlinks are unaffected, includingelement_navigation.rs(_blank) andwindow_open_noopener_lightweight_popup_uses_fresh_session_storage. - Only a noopener open or link that names a lookup-visible popup changes: it now navigates that popup instead of creating a duplicate.
- The CDP projection resolves the reused popup by
popup_id(moli-protocol/src/domains/target/popup.rs:204), which does not depend onexposes_opener.
- Service-worker
- Reuse with no opener passes
opener = Noneintoreopen_lightweight_popup_window. For anabout:blanktarget, the commit origin then comes fromlightweight_popup_opener_storage_scope(None, None). That falls back to the top document's scope (popups.rs:~1385), not an opaque origin, so same-origin access to the reused popup is kept, as in Chromium. The initiator still gets no referrer leak: the noopener referrer comes fromnavigation_initiator.document_referrer. - Tests:
window_open_noopener_navigates_existing_named_lightweight_popupfails without thepopups.rschange. The old gate skips the lookup, so a new popup is created andpopup.location.hrefstaysabout:blank. It asserts only Chromium behaviour (nullreturn, navigated popup, opener kept). The self-named CDP case added in 65d5ff5..306f6a2 covers the issue comment. - Cost: removing a condition in front of a lookup that already runs for every named open adds no new work.
- Body: the picture (webstone d415f0ae) matches the diff and the verification table.
Closes #2766and thefix(window): ...title are correct. - CI on 306f6a2: Format, Clippy, Node, Python, Windows storage and Resolve revisions pass. Nextest, CDP smoke and both release builds are still queued (not started) about 25 minutes after the push. The org's runner queue is backed up: main's own run from 08:31Z is also queued. The 65d5ff5 Nextest also never ran. The last Nextest result on this PR is the 7f111d7 failure, and its cause was fixed in 65d5ff5. Nextest must be green on this head before merge.
Sequential Navigation Soak A/B✅ HEAD completed the 200-navigation resilience and memory observation. One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Common ancestor Session resilience
A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence. Process-tree memory
HEAD memory by 50-navigation quarter
Raw reports and per-navigation boundary samples: workflow run and full Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold. |
CI Regression ReportSource CI run · source state at render:
Release regression — ✅ HEAD/base failures 0/0; raw binary 0.00%Package and image size
Startup latency and PSS
Concurrency matrix
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues; 1 Chromium reference recoveries
Recovered Chromium reference infrastructure failures
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
CDP smoke — ✅ 118/118 groups passed; 1,754 scenariosWorkers: 4 · cumulative group time: 417.30 s · failed groups: 0
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Frozen HTML · Linux · Diagnostics: All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable. |
Spider Bench A/B✅ All benchmark browser service runs completed; results are informational. Public HEAD: 184 / 240 rows; 38 / 48 sites produced rows; 10 unexpected empty sites. ✅ Deterministic fixture contract is clean. Common ancestor Public 48-site run · informational
Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression. CPU and memory timelinesThese are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available. Basexychart-beta
title "Base CPU"
x-axis "Elapsed seconds" [1.536, 3.038, 4.539, 6.042, 8.044, 9.546, 11.047, 12.549, 14.05, 15.551, 16.552, 17.053, 18.554, 20.055, 22.058, 23.06, 23.56, 25.063, 26.566, 28.068, 29.571, 31.074, 32.575, 34.077, 36.08, 37.582, 39.083, 40.586, 42.088, 43.59, 45.092, 46.594, 48.096, 50.098, 51.601, 52.603, 53.104, 54.605]
y-axis "CPU percent" 0 --> 200
line [125.88, 128.06, 141.73, 129.69, 127.92, 93.9, 133.69, 63.82, 141.88, 27.99, 0, 3.99, 0, 120.09, 137.7, 103.85, 101.92, 125.75, 95.9, 101.83, 131.87, 101.85, 71.96, 49.95, 129.74, 75.81, 91.91, 2, 73.93, 2, 25.98, 17.97, 31.95, 101.84, 139.8, 153.65, 105.92, 117.89]
xychart-beta
title "Base memory: RSS then PSS"
x-axis "Elapsed seconds" [0.035, 1.536, 3.038, 4.539, 6.042, 8.044, 9.546, 11.047, 12.549, 14.05, 15.551, 16.552, 17.053, 18.554, 20.055, 22.058, 23.06, 23.56, 25.063, 26.566, 28.068, 29.571, 31.074, 32.575, 34.077, 36.08, 37.582, 39.083, 40.586, 42.088, 43.59, 45.092, 46.594, 48.096, 50.098, 51.601, 52.603, 53.104, 54.605, 56.103]
y-axis "Memory MiB" 0 --> 500
line [13.57, 102.18, 118.63, 149.13, 147.92, 154.68, 144.37, 144.89, 124.47, 145.2, 123.3, 124.11, 123.04, 123.07, 148.79, 131.54, 250.76, 192.82, 198.11, 143.32, 194.8, 131.37, 135.11, 151.09, 142.43, 234.12, 229.36, 230.9, 231.54, 233.86, 232.03, 232.25, 153.58, 143.66, 160.11, 154.73, 139.44, 148.72, 141.48, 0]
line [10.18, 98.61, 115.2, 145.6, 144.38, 151.19, 140.54, 141.33, 120.87, 141.6, 119.72, 120.5, 119.44, 119.47, 145.2, 128.16, 248.04, 188.79, 194.84, 139.73, 191.18, 127.79, 131.52, 147.52, 139.18, 230.51, 225.76, 227.39, 227.94, 230.26, 228.43, 228.64, 149.98, 140.59, 156.5, 151.13, 134.66, 145.12, 137.94, 0]
HEADxychart-beta
title "HEAD CPU"
x-axis "Elapsed seconds" [1.54, 2.54, 3.041, 4.043, 4.544, 6.046, 7.047, 8.55, 10.053, 11.555, 13.057, 14.559, 16.061, 17.561, 19.063, 20.065, 21.568, 22.569, 23.07, 24.571, 26.073, 27.575, 29.077, 30.578, 32.079, 33.08, 34.582, 36.084, 37.585, 39.087, 40.588, 42.089, 43.591, 45.093, 46.094, 47.596, 49.098, 50.601]
y-axis "CPU percent" 0 --> 200
line [125.86, 123.99, 73.89, 99.81, 53.89, 119.97, 133.84, 125.89, 107.9, 77.93, 161.82, 77.85, 73.94, 0, 61.96, 77.87, 139.77, 103.93, 117.83, 113.99, 47.87, 81.96, 97.88, 99.88, 71.92, 133.85, 103.84, 23.98, 45.94, 25.94, 2, 25.98, 73.81, 5.99, 11.99, 105.88, 151.82, 113.85]
xychart-beta
title "HEAD memory: RSS then PSS"
x-axis "Elapsed seconds" [0.039, 1.54, 2.54, 3.041, 4.043, 4.544, 6.046, 7.047, 8.55, 10.053, 11.555, 13.057, 14.559, 16.061, 17.561, 19.063, 20.065, 21.568, 22.569, 23.07, 24.571, 26.073, 27.575, 29.077, 30.578, 32.079, 33.08, 34.582, 36.084, 37.585, 39.087, 40.588, 42.089, 43.591, 45.093, 46.094, 47.596, 49.098, 50.601, 52.072]
y-axis "Memory MiB" 0 --> 500
line [13.56, 100.18, 108.59, 118.8, 119.58, 110.73, 145.01, 149.22, 151.86, 141.61, 151.84, 138.85, 139.54, 119.22, 124.61, 146.97, 139.09, 155.14, 253.54, 177.43, 208.48, 141.55, 188.1, 135.98, 144.69, 143.41, 178.02, 242.84, 222.5, 233.51, 228.41, 230.58, 229.41, 178.78, 132.73, 132.89, 153.75, 137.33, 163.66, 0]
line [10.08, 96.46, 105.05, 115.33, 113.82, 107.25, 141.51, 145.73, 147.84, 138.14, 148.36, 135.35, 136.07, 115.71, 121.09, 143.16, 135.91, 151.68, 250.51, 174.17, 205.57, 137.85, 184.19, 132.3, 141.04, 139.76, 174.45, 238.85, 218.84, 229.86, 224.75, 226.93, 225.75, 175.14, 129.08, 129.23, 150.42, 133.65, 160.1, 0]
Deterministic fixture · required contractThe fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.
Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking. |
ff18374 to
bc9e307
Compare

**Track:** Trajectory Replay (Browser Eval). Replaces part of #853.Closes #2766.
Replaces #853.
Problem
window.open(url, name, "noopener")(and<a target=name rel=noopener>) opened a new window even when a window or iframe namednamealready existed, leaving the named window on its old page. Chromium follows the HTML rules for choosing a navigable: an existing familiar navigable is reused whether or notnoopeneris set, andwindow.openstill returnsnull. Repro: on a page with<iframe name=fr>, runp1 = open('c.html','w1'), thenopen('b.html','w1','noopener')andopen('c.html','fr','noopener')withTarget.setDiscoverTargetson.Reproduce (steps from #2766)
n.html:<iframe name=fr src="b.html"></iframe>. WithTarget.setDiscoverTargets {discover:true}, evaluate on the page (userGesture: true):p1 = window.open('c.html', 'w1')window.open('b.html', 'w1', 'noopener'), wait 1 s, readp1.location.hrefand count theTarget.targetCreatedevents of type pagewindow.open('c.html', 'fr', 'noopener'), then readframes[0].location.hrefAfter step 1, clicking
<a href="b.html" target="w1" rel="noopener">behaves the same way.Expected (Chromium; HTML "rules for choosing a navigable")
A familiar navigable with a matching name is reused whether or not
noopeneris set.noopeneronly affects a newly created window, and the call still returnsnull:null, no new target, andp1.location.hrefends with/b.htmlnull, no new target, and the iframe navigates toc.htmlActual
nulland creates a newb.htmltarget, whilep1stays atc.htmlc.htmlwindow, while the iframe stays atb.htmlrel=noopenerlink also creates a new targetChange
The lookup for an existing named context was gated on opener exposure:
moli-renderer-v8/src/native_bridge/context_host/popups/renderer_owned.rs: look up the named related window regardless ofexposes_opener; only update the reused window's opener when the opener is exposed. Covers bothwindow.openand hyperlinks.moli-renderer-v8/src/context_bootstrap/window_runtime/dialogs.rs: drop&& !suppress_openerfrom the named-iframe path and returnnullwhen the opener is suppressed.moli-renderer-v8/src/native_bridge/context_host/popups.rs(open_lightweight_popup_window): the same gate (opener.is_some()) on the lightweight popup path, which serves pages without a browser-owned page factory, e.g.moli fetch. Removed somoli fetchbehaves the same.popup_navigation_uses_source_referrer_policy_and_window_featuresopened itsnoopener/noreferrercases under the namechild-0and expected a new context; under the HTML rules (and Chromium) that name selects the existing popup. Those cases now use their own names, so the test still checks referrer policy for new noopener/noreferrer windows.noopener_window_open_reuses_existing_named_window_and_frame(protocol-server CDP test) opens a named popup and a named iframe, then checks thatnoopeneropens returnnull, navigate the existing popup/iframe and create no new target; it also covers the self-named case (window.name='shared2'with a popup also namedshared2:open('#self2','shared2','noopener')navigates the page itself, leaves the popup alone, no new target).window_open_noopener_navigates_existing_named_lightweight_popup(renderer, lightweight path) checks the same reuse formoli fetch-style pages.Verification
Repro over CDP (
moli serve,userGesture: true); before: released v1.1.23 binary (same code path asorigin/maincbf4d01), after: debug build of this branch.cargo fmt --all: clean.cargo clippy -p moli-renderer-v8 -p moli-protocol-server --all-targets --all-features -- -D warnings: passed.cargo nextest run -p moli-protocol-server -E 'test(noopener) | test(auxiliary_page) | test(named)' --no-fail-fast: 51 passed (includes the new test).cargo nextest run -p moli-protocol-server -E 'test(popup_navigation) | test(noopener)': 9 passed (after the referrer test update; CI's first run flagged that test).cargo nextest run -p moli-renderer-v8 -E 'test(window_open) | test(popup)': 165 passed. Negative control: with thepopups.rschange reverted,window_open_noopener_navigates_existing_named_lightweight_popupfails (hrefstaysabout:blank).cargo nextest run -p moli-protocol-server -E 'test(noopener) | test(popup_navigation) | test(auxiliary_page)': 41 passed.moli fetch n.html --eval-file(open named popup, thennoopeneropens of the popup and of the named iframe): main[null,"/c.html",null,"/b.html"](popup and iframe not navigated) → this PR[null,"/b.html",null,"/c.html"].Cost
Debug builds of
origin/main(f935014) and this branch,/usr/bin/time -l, median of 5 runs (two interleaved rounds for the repro; shared host, so absolute times vary between rounds):moli serve, ~6 s of fixed sleeps)moli fetchof a local 46 KB articleThe change removes a condition in front of the existing named-window lookup, which already runs for every named
window.open/link target; nothing new is retained. The repro uses slightly less memory because it no longer creates two extra pages.