Bug 1246842 - Correct once function to remove correct event listener r?cpearce draft
authorBryce Van Dyk <bvandyk@mozilla.com>
Tue, 09 Feb 2016 17:32:13 +1300
changeset 329750 378e19db373465231531311c897d3598de12baa2
parent 326148 211a4c710fb6af2cad10102c4cabc7cb525998b8
child 329778 4a64af279222792c4d02475143afadaa162ec60e
child 329890 1e0d0ef7ebae1040d6c23f03ec1698915a60d820
push id10594
push userbvandyk@mozilla.com
push dateTue, 09 Feb 2016 04:39:36 +0000
reviewerscpearce
bugs1246842
milestone47.0a1
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
dom/media/test/manifest.js
--- 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;
 }