Skip to content

Commit 616d362

Browse files
Pehrsonsmoz-wptsync-bot
authored andcommitted
Allow RTCDTMFToneChangeEvents to fire up to 1ms early.
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
1 parent 7ecbda7 commit 616d362

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

webrtc/RTCDTMFSender-helper.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ function test_tone_change_events(testFunc, toneChanges, desc) {
117117
assert_equals(dtmfSender.toneBuffer, expectedToneBuffer,
118118
`Expect dtmfSender.toneBuffer to be updated to ${expectedToneBuffer}`);
119119

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

0 commit comments

Comments
 (0)