Truly independent web browser
Tests/LibWebView: Retry the force-dark test’s screenshot until it paints
sideshowbarkercde50113248c
diff --git a/Tests/LibWebView/test-webdriver-force-dark.py b/Tests/LibWebView/test-webdriver-force-dark.pyindex c66495a8f53..4b05fa1eeac 100755--- a/Tests/LibWebView/test-webdriver-force-dark.py+++ b/Tests/LibWebView/test-webdriver-force-dark.py@@ -120,11 +120,21 @@ def run_test(default):raise AssertionError(f"Expected {url}, got {state}")def assert_force_dark(description, expected, check_initial=True):- status, payload, raw = command("GET", "screenshot")- assert status == 200, raw- color = png_pixel(base64.b64decode(payload["value"]), 10, 10)+ # A frame that fails to draw (when the GPU drops a command buffer, e.g.) leaves a screenshot showing+ # the page's previous colors. So take screenshots until the page and its iframe both paint as expected,+ # for up to 10 seconds, the way the other waits here poll.+ deadline = time.monotonic() + 10+ while True:+ status, payload, raw = command("GET", "screenshot")+ assert status == 200, raw+ screenshot = base64.b64decode(payload["value"])+ color = png_pixel(screenshot, 10, 10)+ iframe_color = png_pixel(screenshot, 110, 110)+ painted = (max(color) < 128) == expected and (max(iframe_color) < 128) == expected+ if painted or time.monotonic() >= deadline:+ break+ time.sleep(0.05)assert (max(color) < 128) == expected, f"{description} expected dark={expected}, got {color}"- iframe_color = png_pixel(base64.b64decode(payload["value"]), 110, 110)assert (max(iframe_color) < 128) == expected, f"{description} iframe painted {iframe_color}"status, payload, raw = command("POST",