You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stops intermittent RBE failures in the JS BiDi script tests and the atoms window-size test.
Tests now wait for asynchronous BiDi events (console logs, JavaScript errors, DOM mutations, pinned-script output) to arrive before asserting on them, instead of reading them immediately after the triggering action.
The window setSize test polls the reported size (up to 2s) instead of asserting the resize took effect synchronously.
🔧 Implementation Notes
The waiter uses a loose != null check so tests whose handler var starts as undefined (not null) still wait rather than passing through instantly.
Verified locally with --runs_per_test=15 --cache_test_results=no: webdriver_script_test now passes 15/15 (previously failed several runs on the pin and DOM-mutation cases).
🤖 AI assistance
No substantial AI assistance used
AI assisted (complete below)
Tool(s): Claude Code
What was generated: the test wait/poll helpers and their usage
I reviewed all AI output and can explain the change
💡 Additional Considerations
click_link_test still flakes locally on headed macOS (Tests timed out after 21 s), but it is not part of the RBE failures and is out of scope here.
Stabilize JS BiDi and window resize tests by waiting for async events
🐞 Bug fix🧪 Tests🕐 10-20 Minutes
AI Description
• Add explicit waits for async BiDi log, error, mutation, and pinned-script events.
• Poll for window resize completion before asserting the final dimensions.
• Reduce intermittent CI/RBE failures caused by timing-dependent assertions.
The following are alternative approaches to this PR:
1. Promisify handlers (event-driven) instead of polling
➕ More deterministic than polling loops
➕ Clearer coupling between handler invocation and test continuation
➖ Requires additional plumbing to resolve/reject promises from handler callbacks
➖ More intrusive refactor across existing tests
2. Extract shared test wait utilities into a common helper module
➕ Reduces duplication as more flaky async-event tests are added
➕ Encourages consistent timeout messages and semantics
➖ Slightly more overhead for a small set of tests
➖ May require updating imports/structure across the test suite
Recommendation: Current approach is appropriate for stabilizing flakes with minimal churn: using driver.wait with a loose != null gate for single-entry handlers and includes() for log arrays. Consider extracting these helpers into a shared test utility if additional BiDi event-wait patterns appear elsewhere.
Files changed (2) +27 / -1
Tests (2) +27 / -1
window_size_test.htmlPoll window size after setSize before asserting+12/-1
Poll window size after setSize before asserting
• Converts the setSize test to async and polls bot.window.getSize() until the expected size is observed or 2s elapses. This avoids assuming the resize takes effect synchronously and reduces intermittent failures.
webdriver_script_test.jsWait for BiDi console/error/mutation/pinned-script events before assertions+15/-0
Wait for BiDi console/error/mutation/pinned-script events before assertions
• Adds local wait helpers that block until handler state is populated ('!= null') or until expected console text appears. Updates multiple BiDi script() tests to await event delivery before asserting, reducing timing-related flakes.
In window_size_test.html, the new polling loop only exits early on an exact width/height match, but
verifySize() explicitly skips assertions for IE_DOC_9 and allows approximate sizing for IE_DOC_PRE9.
In those modes the test may run until the 2s deadline even when verifySize() would already
pass/skip, adding avoidable latency to the test run.
+ var actual = bot.window.getSize();+ if ((actual.width === size.width && actual.height === size.height) ||+ new Date().getTime() - start > 2000) {+ verifySize(assert, size);
Evidence
The poll loop’s early-exit condition requires strict equality, but verifySize() defines the test’s
actual pass criteria (including skip/tolerance paths) which the poll condition does not account for.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
`QUnit.test('setSize')` now waits for an *exact* `getSize()` match before finishing early, but the existing `verifySize()` helper has browser-specific behavior:
- returns early (skip) on `bot.userAgent.IE_DOC_9`
- accepts approximate sizing on `bot.userAgent.IE_DOC_PRE9`
This mismatch can cause the poll loop to wait until the timeout even though `verifySize()` would already pass/skip.
### Issue Context
The polling is intended to reduce flakes by waiting for resize to take effect, but its completion predicate should be consistent with the assertion predicate already encoded in `verifySize()`.
### Fix Focus Areas
- javascript/atoms/test/window_size_test.html[40-85]
Suggested direction: extract a `sizeSettled(actual, expected)` predicate that mirrors `verifySize()`’s special cases (including IE_DOC_9 skip and IE_DOC_PRE9 tolerance) and use that predicate in the poll loop’s early-exit condition.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B-atomsJavaScript chunks generated by Google closureC-nodejsJavaScript Bindings
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issues
💥 What does this PR do?
setSizetest polls the reported size (up to 2s) instead of asserting the resize took effect synchronously.🔧 Implementation Notes
!= nullcheck so tests whose handler var starts asundefined(notnull) still wait rather than passing through instantly.--runs_per_test=15 --cache_test_results=no:webdriver_script_testnow passes 15/15 (previously failed several runs on the pin and DOM-mutation cases).🤖 AI assistance
💡 Additional Considerations
click_link_teststill flakes locally on headed macOS (Tests timed out after 21 s), but it is not part of the RBE failures and is out of scope here.🔄 Types of changes