Skip to content

fix: Measure the browser UI size once the viewport is stable at session start - #274

Closed
amanabiy wants to merge 2 commits into
mainfrom
fix/measure-browser-ui-size
Closed

amanabiy wants to merge 2 commits into
mainfrom
fix/measure-browser-ui-size

Conversation

@amanabiy

Copy link
Copy Markdown
Member

Why

To make the Firefox screenshot tests less flaky. #272 made setWindowSize wait for the viewport after a resize, but Alpha still shows the same failures: the first host in a session renders against a shorter viewport, and the second host renders at full size.

The likely cause is how #272 measures the browser UI size (window size minus viewport). It measures it right before each resize. The session-start resize doesn't wait, so when IntegrationTests' resetWindowSize runs for the first host, Firefox can still report a short viewport. The measured UI size then comes out too big, and the wait accepts the short viewport on the first poll. This cause is assumed, not confirmed yet. It's being checked with debug logging in the dev pipeline.

What changed

  • After the session-start resize, browser-creator.ts calls measureBrowserUISize. It waits until the window size and viewport read the same 3 times in a row, 100ms apart, for up to 3s. Then it stores the browser UI size for that browser. If the viewport never stabilizes, it logs a warning and stores nothing.
  • setWindowSize uses the stored UI size when there is one, and otherwise measures it before the resize as before. A short viewport no longer matches, so the wait keeps polling until the viewport reaches its full size.

Testing

  • npm run build, ESLint, Prettier and tsc --noEmit pass.
  • New fake-browser tests in test/browser-ui-size.test.ts cover a stable viewport, a viewport that keeps changing, and rethrowing other errors.
  • Not tested in Firefox yet. Draft until a dev pipeline run confirms the cause and shows fewer failures.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.83%. Comparing base (e27bc5d) to head (d73b95f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #274      +/-   ##
==========================================
+ Coverage   93.47%   93.83%   +0.35%     
==========================================
  Files          20       21       +1     
  Lines         506      535      +29     
  Branches       87       91       +4     
==========================================
+ Hits          473      502      +29     
  Misses         29       29              
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amanabiy

Copy link
Copy Markdown
Member Author

Not needed

@amanabiy amanabiy closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant