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.

(cherry picked from commit f752ae3677)
This commit is contained in:
2026-10-02 14:51:48 -07:00
parent 0157b4b325
commit be3157baf2
2 changed files with 48 additions and 12 deletions

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"