Repository navigation
test: wait for the page's own looks and clock before the freshness tests' absence checks - #5603
Merged
Merged
Conversation
…sts' absence checks Four tests in tests/browser/startup/test_freshness.py slept a fixed time (3 s, 500 ms, 500 ms, 1 s) and then asserted that the page had not asked for state, not reloaded, or not looked while hidden. On a slower machine the unwanted ask lands after the sleep and the test passes with the bug present, against tests/AGENTS.md's "Absences"; #5541's sweep missed this file. Each now waits for an event the page orders after the moment it would have misbehaved, counting asks in the page (COUNT_ASKS, moved to the top): - A quiet page: a round of the shared clock (`ran_its_clock`, a page timer longer than TICK_MS, which the page fires after every timer due before it), then a handled look (`looked_since`). - A durable restart: the look after the one that heard the new server, or a reloaded document, whichever comes first. - A hidden page: a round of the clock, with the looks it asked counted from the moment it hid, so a look it failed to cancel shows as well as a state read. - A page whose read failed: eight looks, allowing one ask per round of the clock by the page's own time, plus one. Each failed with the behavior it guards planted in state-feed.js: every look asking for state, the clock asking every round, a hidden page left listening, and a reload on the new server.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Four tests in
tests/browser/startup/test_freshness.pyslept for a fixed time and then checked that something had not happened: the page asking for state, reloading, or looking for news while hidden. On a slow machine the unwanted request or reload can arrive after the sleep, so the test passes with the bug present. That breaks the rule intests/AGENTS.md, "Absences", and #5541's sweep missed this file. Each check now waits for something the page itself does after the moment it would have misbehaved. The page counts its own requests (COUNT_ASKS, moved to the top of the file). Each rewritten check failed with the bug it guards against planted inbrowser/runtime/state-feed.js, and all twelve tests in the file pass without it.test_a_quiet_page_reads_only_freshness_and_hears_changesasks = true || …)test_a_durable_server_restart_keeps_the_current_editortest_a_hidden_page_stops_its_freshness_reads_until_it_is_visiblestopListeningnot called)test_a_page_whose_read_failed_asks_again_on_its_ownif (true) item(observed)), which made 9 reads in about 2 sran_its_clockhas the page set a timer one interval of the shared clock long (TICK_MS, plus 500 ms). The browser fires timers in deadline order, so the clock's next round and any freshness check still scheduled run before it, however slowly the machine runs them. A fixed sleep, by contrast, runs on the test's clock, which knows nothing about the page's timers.TICK_MSis copied fromstate-feed.js, and a comment says so.The 100 ms sleep before the hidden-page test writes its news is left in place: it is setup, not a check that something stayed absent.