Skip to content

Commit

Permalink
Allow RTCDTMFToneChangeEvents to fire up to 1ms early.
Browse files Browse the repository at this point in the history
Firefox's timer implementation allows events to fire 250μs early. Instead of
using a non-fuzzy timer in Firefox (may cause extra wakeups) or an artificial
extra delay on every dtmf event, relax the test case a bit.

Differential Revision: https://phabricator.services.mozilla.com/D201821

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1785418
gecko-commit: 8175af8c6fb443418b4fb401b5a2ab282ed73846
gecko-reviewers: bwc
  • Loading branch information
Pehrsons authored and moz-wptsync-bot committed Feb 15, 2024
1 parent 7ecbda7 commit 616d362
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions webrtc/RTCDTMFSender-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ function test_tone_change_events(testFunc, toneChanges, desc) {
assert_equals(dtmfSender.toneBuffer, expectedToneBuffer,
`Expect dtmfSender.toneBuffer to be updated to ${expectedToneBuffer}`);

// We check that the cumulative delay is at least the expected one, but
// system load may cause random delays, so we do not put any
// realistic upper bound on the timing of the events.
assert_between_inclusive(Date.now() - start, expectedTime,
// We check that the cumulative delay is at least the expected one.
// Note that as a UA optimization events can fire a bit (<1ms) early,
// and system load may cause random delays. We therefore allow events
// to be 1ms early and do not put any realistic expectation on the upper
// bound of their timing.
assert_between_inclusive(Date.now() - start, Math.max(0, expectedTime - 1),
expectedTime + 4000,
`Expect tonechange event for "${tone}" to be fired approximately after ${expectedTime} milliseconds`);
if (cumulativeToneChanges.length === 0) {
Expand Down

0 comments on commit 616d362

Please sign in to comment.