sensors: Try to fix flakiness in iframe-related Generic Sensor tests. #23503
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.
The second test, for focus traversal within same-origin frames, was
occasionally failing, especially in the Mac bots.
The flakiness seems to come from the way the "is_sensor_suspended" command
was implemented in iframe_sensor_handler.html. The sensor in the iframe was
created with the default frequency of 5Hz and, consequently, a period of
200ms. "is_sensor_suspended" tried to detect whether the sensor was
suspended by either receiving a new "reading" event (in which case the
sensor was not suspended), or by reaching a timeout function with a period
of 250ms (200ms from the sensor + a small delay).
In some cases, it looks like the 250ms were not enough and we reached the
timeout function prior to the sensor emitting a new "reading" event. Try to
fix this by using a longer timeout of twice the sensor's period to be more
certain that if we reach that code at least one event should have been
emitted before.
While here, make the code easier to follow by documenting what we are doing
and relying on fewer magic numbers, and increase the sensor frequency so
that the test does not take unnecessarily long to run.
Bug: 1073865
Change-Id: I630ad6034f0839c17f11f111ead24a88affc9dd2
Reviewed-on: https://chromium-review.googlesource.com/2193672
WPT-Export-Revision: c6de5bb666abf21c56e386d67de05a95eeb63589