Bug 1246842 - Correct once function to remove correct event listener r?cpearce
The once function should add and then remove an event listener after it is
invoked, but it appears to remove another event listener instead. This commit
adjusts that behaviour. Note that the dom/media/mediasource/test/mediasource.js
file has the same pattern and has been updated. This commit reflects using the
same changes to remedy the once function here.
MozReview-Commit-ID: DQ4bfxTQfjN
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -1350,17 +1350,17 @@ function removeNodeAndSource(n) {
while (n.firstChild) {
n.removeChild(n.firstChild);
}
}
function once(target, name, cb) {
var p = new Promise(function(resolve, reject) {
target.addEventListener(name, function() {
- target.removeEventListener(name, cb);
+ target.removeEventListener(name, arguments.callee);
resolve();
});
});
if (cb) {
p.then(cb);
}
return p;
}