test: fix interchange debonce test race condition #11279
Merged
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.
Description
Timeout delays are most often not respected and the differences between several timeouts running in parrallel can be huge. To prevent race conditions on slower browsers, we now run the debounce test several time to wait for the debounced event to be called, which may be finally called way after the expected time.
This is done using a new
testInterval
utility: it try and catch the given function everyinterval
delay, until it succedes (does not throw an error) or a given time passed.If the debounced event is was called when expected (just after 10ms), we wait and run the test again. If after many tries the debounced event is still not called after 1s, we consider the test as failed.
The test should be now safe enough regarding to race conditions.
Changes
testInterval
test utilityReferences
Motivation and Context
Fixes the following race condition with IE11:
Types of changes
functionality to change)
Checklist (all required):
develop
orsupport/*
).