Closed Bug 2073418 Opened 1 month ago Closed 1 month ago

Intermittent browser/extensions/newtab/test/browser/browser_newtab_ping.js | test_newtab_dwell_time_in_ping - dwell_time is in the newtab ping - null == true

Categories

(Firefox :: New Tab Page, defect)

defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: florian, Assigned: florian)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

test_newtab_dwell_time_in_ping notifies user-interaction-active-non-synthesized by hand, sleeps 100 ms, closes the tab and asserts that Glean.newtab.dwellTime has a sample. TelemetryFeed credits each session's dwell stopwatch only up to the timestamp of the last "active" notification, which is deliberate: an idle tick means the user did nothing since then.

Because the test fabricates that notification instead of generating input, it has no control over the idle deadline. EventStateManager's user-activity timer is armed by any trusted event, which test-synthesized events are, and its tick notifies user-interaction-inactive-non-synthesized, the topic the feed observes. When a tick lands inside the test's 100 ms window the feed credits zero and stops the clock, so no sample is accumulated and the ping carries no newtab.dwell_time:

TEST-UNEXPECTED-FAIL | test_newtab_dwell_time_in_ping - dwell_time is in the newtab ping - null == true

The per-test profiles show the tick: user-interaction-inactive-non-synthesized from UITimerCallback::Notify 93 ms after the test's own "active" notification and 31 ms before its cleanup. It has failed this way twice on central in the 21 days to 2026-09-16, and much more often under test-verify, which runs the file about 30 times per task.

The fix is to stub the feed's now(), which exists so tests can drive the clock, and notify "active" twice with the fake clock advanced in between, the shape a continuing interaction has. An idle tick then credits the interval between the two notifications wherever it lands.

Test dashboard: https://tests.firefox.dev/test.html?test=browser/extensions/newtab/test/browser/browser_newtab_ping.js

test_newtab_dwell_time_in_ping fabricated one "active" notification and slept
100ms, but TelemetryFeed credits dwell only up to its last "active"
notification, so EventStateManager's idle tick, whose deadline the test does not
control, could land in the sleep, stop the stopwatch at zero and submit a ping
with no newtab.dwell_time.

Notify twice with the feed's clock advanced in between, so a tick anywhere in
the window still has an interval to credit.

Assignee: nobody → florian
Status: NEW → ASSIGNED
Pushed by fqueze@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/aa6a813c3c23 https://hg.mozilla.org/integration/autoland/rev/4dc39463692a Drive the newtab dwell time test's clock instead of racing EventStateManager's idle tick, r=mconley.
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: