Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 6f353f1

Browse files
Guilherme GonçalvesNephyrin
authored andcommitted
Bug 863813 - Only call the done function once per test, failure or success. r=smaug
1 parent 84f8dff commit 6f353f1

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

  • content/media/webspeech/recognition/test

content/media/webspeech/recognition/test/head.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ function EventManager(sr) {
4343
"audioend": "audiostart"
4444
};
4545

46+
var isDone = false;
47+
4648
// AUDIO_DATA events are asynchronous,
4749
// so we queue events requested while they are being
4850
// issued to make them seem synchronous
@@ -59,7 +61,10 @@ function EventManager(sr) {
5961
}
6062

6163
ok(false, message);
62-
if (self.done) self.done();
64+
if (self.doneFunc && !isDone) {
65+
isDone = true;
66+
self.doneFunc();
67+
}
6368
};
6469
})(allEvents[i]);
6570
}
@@ -78,8 +83,10 @@ function EventManager(sr) {
7883
}
7984

8085
cb && cb(evt, sr);
81-
if (self.done && nEventsExpected === self.eventsReceived.length) {
82-
self.done();
86+
if (self.doneFunc && !isDone &&
87+
nEventsExpected === self.eventsReceived.length) {
88+
isDone = true;
89+
self.doneFunc();
8390
}
8491
}
8592
}
@@ -150,7 +157,7 @@ function performTest(options) {
150157
em.expect(eventName, cb);
151158
}
152159

153-
em.done = function() {
160+
em.doneFunc = function() {
154161
em.requestTestEnd();
155162
options.doneFunc();
156163
}

0 commit comments

Comments
 (0)