T16.4: browser probes pass; cdp.py starts from an elevated shell

files_check.py 36/36 (T16.2), sample_check.py 10/10 and
critical_reopen_check.py 11/11 (T16.3), run on Matt's machine with
Edge 154. T16.2 and T16.3 done; wave 16 verification complete.

tests/cdp.py: every probe first failed 'exited rc=0 without binding
the port'. The shell was elevated; Edge and Chrome de-elevate by
relaunching through Explorer and the relaunch drops the debugging
port ('Edge is running elevated: 1' in the browser log). Adds
--do-not-de-elevate on Windows and a 15 s grace for the port after an
rc=0 exit. Both inert on a normal shell and off Windows.
This commit is contained in:
2026-10-02 14:51:48 -07:00
parent f0750212ca
commit f752ae3677
2 changed files with 48 additions and 12 deletions

View File

@@ -62,7 +62,7 @@ with an ASCII fallback and an RFC 5987 `filename*`. Reference code:
- [x] PNG, JPEG and PDF still open inline
- [x] `Plan é.pdf` downloads (was 500)
- [x] a name with CR/LF produces a valid header
- [ ] `tests/files_check.py` passes on a machine with Edge (CR-007 offline drawings)
- [x] `tests/files_check.py` passes on a machine with Edge (CR-007 offline drawings)
---
@@ -89,7 +89,7 @@ uses it.
- [x] POST without an id lands on `sop__<project_id>`
- [x] a rogue complete SOP made before the fix no longer drives the baseline
or the QA and PM/CM recipients
- [ ] `tests/sample_check.py` and `tests/critical_reopen_check.py` pass on a
- [x] `tests/sample_check.py` and `tests/critical_reopen_check.py` pass on a
machine with Edge
---
@@ -128,11 +128,24 @@ Run 2026-10-02 in the build sandbox (Linux, Python 3.10, no browser), on branch
| `server/seed_demo.py` | Seeds the demo project; its SOP lands on the canonical id |
| `pip-audit -r server/requirements.txt` | No known vulnerabilities |
**Not run (no headless browser in the sandbox).** These done-when items stay
open until someone runs them on a machine with Edge, so T16.2 and T16.3 are
**not marked done** yet:
**Browser probes, run 2026-10-02 on Matt's machine (Windows, Edge 154,
Python 3.12.10, `.venv`), one at a time:**
- T16.2: `python tests/files_check.py` (CR-007 drawings, offline cache)
- T16.3: `python tests/sample_check.py` and `python tests/critical_reopen_check.py`
| Probe | Task | Result |
|---|---|---|
| `tests/files_check.py` | T16.2 | **36/36**, including the 1440px creator, 390px Field View, and the offline drawing cache with the server gone |
| `tests/sample_check.py` | T16.3 | **10/10** |
| `tests/critical_reopen_check.py` | T16.3 | **11/11**, PM + CM + assignee mail, sink-verified |
Run them one at a time (file-map.md: chained runs exhaust the browser's ports).
T16.2 and T16.3 are done.
**Harness fix needed to get there (`tests/cdp.py`, committed with this record).**
Every probe failed first with "browser would not start ... exited rc=0
without binding the port". Cause: the PowerShell session was elevated, and
Edge and Chrome de-elevate by relaunching themselves through Explorer as a
normal user; the relaunch drops `--remote-debugging-port`. Edge's log said so
(`Edge is running elevated: 1`). No browser policy was involved (all hives
checked). Two changes, both inert on a normal shell and on Linux/macOS:
`--do-not-de-elevate` on Windows, and a 15-second grace for the port when the
launched process exits rc=0. Probe results are unchanged by it; it only lets
the browser start.

View File

@@ -190,8 +190,26 @@ class Browser:
f"--user-data-dir={self.profile}", "--remote-allow-origins=*",
"--no-first-run", "--no-default-browser-check", "--disable-gpu",
"--disable-extensions", "--disable-sync",
"--window-size=1400,1000", "about:blank"],
"--window-size=1400,1000"]
# Run from an elevated (Administrator) shell, Edge and Chrome
# "de-elevate": they relaunch themselves as a normal user through
# Explorer and the launched process exits rc=0. The relaunch does
# not keep the debugging port, so the port is never bound (found
# 2026-10-02; Edge logs "Edge is running elevated: 1"). This
# Chromium switch keeps the process we started. Ignored when the
# shell is not elevated, and on other platforms.
+ (["--do-not-de-elevate"] if sys.platform == "win32" else [])
+ ["about:blank"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
# On some Windows installs msedge.exe is a launcher: it starts the real
# browser and exits rc=0 at once, and the real browser binds the port a
# moment later. Giving up the instant the launched process exited
# failed every attempt on such a machine although Edge worked when
# started by hand (found 2026-10-02 running the wave 16 probes). An
# rc=0 exit now gets a grace period to bind; a non-zero exit is still
# a failure at once. Teardown is unaffected: close() sweeps by the
# unique profile path, which also catches the handed-off process.
exited_at = None
for _ in range(160):
try:
with urllib.request.urlopen(
@@ -199,9 +217,14 @@ class Browser:
json.load(r)
return
except Exception:
if self.proc.poll() is not None:
last = f"exited rc={self.proc.returncode} without binding the port"
break
rc = self.proc.poll()
if rc is not None:
last = f"exited rc={rc} without binding the port"
if rc != 0:
break
exited_at = exited_at or time.time()
if time.time() - exited_at > 15:
break
time.sleep(0.25)
else:
last = "never bound the debugging port"