|
5 | 5 | import secrets |
6 | 6 | import sys |
7 | 7 | import threading |
| 8 | +from dataclasses import dataclass |
8 | 9 | from pathlib import Path |
9 | 10 | from urllib.parse import urljoin, urlsplit |
10 | 11 |
|
@@ -130,6 +131,50 @@ def _render_version_attempt( |
130 | 131 | ) |
131 | 132 |
|
132 | 133 |
|
| 134 | +@dataclass(frozen=True, slots=True) |
| 135 | +class _SchemeContext: |
| 136 | + page: object |
| 137 | + scheme: str |
| 138 | + errors: list |
| 139 | + resize_notices: list |
| 140 | + registry: dict |
| 141 | + widgets: dict |
| 142 | + state: dict |
| 143 | + markup: str |
| 144 | + here: int |
| 145 | + earlier: str | None |
| 146 | + touched: list |
| 147 | + replayed: bool |
| 148 | + unsettled: list |
| 149 | + |
| 150 | + |
| 151 | +@dataclass(frozen=True, slots=True) |
| 152 | +class _SchemeReadings: |
| 153 | + failsoft: list |
| 154 | + missing_upgrades: list |
| 155 | + missing_visual_providers: list |
| 156 | + tiny: list |
| 157 | + unmarkable: list |
| 158 | + overflow: int | float |
| 159 | + misplaced: list |
| 160 | + withheld: list |
| 161 | + squeezed: list |
| 162 | + clipped: list |
| 163 | + unreachable: list |
| 164 | + covered: list |
| 165 | + unread: list |
| 166 | + undeclared_shadow: list |
| 167 | + conflicts: list |
| 168 | + dishonest_verbatim: list |
| 169 | + silent: list |
| 170 | + missing_conversations: list |
| 171 | + undeclared_attrs: list |
| 172 | + retired: list |
| 173 | + trapped: list |
| 174 | + on_paper: list |
| 175 | + relative: list |
| 176 | + |
| 177 | + |
133 | 178 | def _render_scheme(browser, url, scheme, served_timeout_ms, opened_pages): |
134 | 179 | """Read and report the browser gate for one color scheme.""" |
135 | 180 | from playwright.sync_api import Error as PlaywrightError |
@@ -291,6 +336,37 @@ def probe_failure(error): |
291 | 336 | "the page never stopped moving: " |
292 | 337 | + ", ".join(evaluate_probe(page, "moving")) |
293 | 338 | ] |
| 339 | + context = _SchemeContext( |
| 340 | + page=page, |
| 341 | + scheme=scheme, |
| 342 | + errors=errors, |
| 343 | + resize_notices=resize_notices, |
| 344 | + registry=registry, |
| 345 | + widgets=widgets, |
| 346 | + state=state, |
| 347 | + markup=markup, |
| 348 | + here=here, |
| 349 | + earlier=earlier, |
| 350 | + touched=touched, |
| 351 | + replayed=replayed, |
| 352 | + unsettled=unsettled, |
| 353 | + ) |
| 354 | + readings = _read_scheme(context) |
| 355 | + page.close() |
| 356 | + return _scheme_result(context, readings) |
| 357 | + |
| 358 | + |
| 359 | +def _read_scheme(context: _SchemeContext) -> _SchemeReadings: |
| 360 | + page = context.page |
| 361 | + scheme = context.scheme |
| 362 | + registry = context.registry |
| 363 | + widgets = context.widgets |
| 364 | + state = context.state |
| 365 | + markup = context.markup |
| 366 | + here = context.here |
| 367 | + earlier = context.earlier |
| 368 | + touched = context.touched |
| 369 | + replayed = context.replayed |
294 | 370 | failsoft = evaluate_probe(page, "failSoftErrors") |
295 | 371 | missing_upgrades = evaluate_probe(page, "missingUpgrades", widgets) |
296 | 372 | missing_visual_providers = evaluate_probe(page, "missingVisualProviders", widgets) |
@@ -455,7 +531,63 @@ def probe_failure(error): |
455 | 531 | # delivers that notice in the next rendering turn, so closing on the write |
456 | 532 | # would call an attempt complete before its last error channel had spoken. |
457 | 533 | evaluate_probe(page, "nextFrame") |
458 | | - page.close() |
| 534 | + return _SchemeReadings( |
| 535 | + failsoft=failsoft, |
| 536 | + missing_upgrades=missing_upgrades, |
| 537 | + missing_visual_providers=missing_visual_providers, |
| 538 | + tiny=tiny, |
| 539 | + unmarkable=unmarkable, |
| 540 | + overflow=overflow, |
| 541 | + misplaced=misplaced, |
| 542 | + withheld=withheld, |
| 543 | + squeezed=squeezed, |
| 544 | + clipped=clipped, |
| 545 | + unreachable=unreachable, |
| 546 | + covered=covered, |
| 547 | + unread=unread, |
| 548 | + undeclared_shadow=undeclared_shadow, |
| 549 | + conflicts=conflicts, |
| 550 | + dishonest_verbatim=dishonest_verbatim, |
| 551 | + silent=silent, |
| 552 | + missing_conversations=missing_conversations, |
| 553 | + undeclared_attrs=undeclared_attrs, |
| 554 | + retired=retired, |
| 555 | + trapped=trapped, |
| 556 | + on_paper=on_paper, |
| 557 | + relative=relative, |
| 558 | + ) |
| 559 | + |
| 560 | + |
| 561 | +def _scheme_result( |
| 562 | + context: _SchemeContext, readings: _SchemeReadings |
| 563 | +) -> tuple[list, list, bool]: |
| 564 | + scheme = context.scheme |
| 565 | + errors = context.errors |
| 566 | + resize_notices = context.resize_notices |
| 567 | + unsettled = context.unsettled |
| 568 | + failsoft = readings.failsoft |
| 569 | + missing_upgrades = readings.missing_upgrades |
| 570 | + missing_visual_providers = readings.missing_visual_providers |
| 571 | + tiny = readings.tiny |
| 572 | + unmarkable = readings.unmarkable |
| 573 | + overflow = readings.overflow |
| 574 | + misplaced = readings.misplaced |
| 575 | + withheld = readings.withheld |
| 576 | + squeezed = readings.squeezed |
| 577 | + clipped = readings.clipped |
| 578 | + unreachable = readings.unreachable |
| 579 | + covered = readings.covered |
| 580 | + unread = readings.unread |
| 581 | + undeclared_shadow = readings.undeclared_shadow |
| 582 | + conflicts = readings.conflicts |
| 583 | + dishonest_verbatim = readings.dishonest_verbatim |
| 584 | + silent = readings.silent |
| 585 | + missing_conversations = readings.missing_conversations |
| 586 | + undeclared_attrs = readings.undeclared_attrs |
| 587 | + retired = readings.retired |
| 588 | + trapped = readings.trapped |
| 589 | + on_paper = readings.on_paper |
| 590 | + relative = readings.relative |
459 | 591 | found = [f"[{scheme}] console: {e}" for e in errors] |
460 | 592 | found += [f"[{scheme}] a widget failed soft: {t}" for t in failsoft] |
461 | 593 | if missing_upgrades: |
|
0 commit comments