From 90c596e654274e1ad524061f40814b7786e0685e Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Mon, 17 Oct 2016 18:54:23 +0200 Subject: [PATCH] Bug 1310718 - Don't wrap invalid listeners r=billm `makeFilteringListener` uses the listener as a key for a WeakMap, so we cannot blindly use the listener as a WeakMap key. addEventListener and removeEventListeer only accept objects/functions (and undefined/null), so not wrapping will lead to a descriptive error message from addEventListener/removeEventListeer. MozReview-Commit-ID: HF2WAyXDeD9 --HG-- extra : rebase_source : 5574c118cf0881ddc1477ceeb1b9c979814d67d6 --- toolkit/components/addoncompat/RemoteAddonsParent.jsm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toolkit/components/addoncompat/RemoteAddonsParent.jsm b/toolkit/components/addoncompat/RemoteAddonsParent.jsm index 782b32965900..808ceebcd7f7 100644 --- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm @@ -611,7 +611,8 @@ function makeFilteringListener(eventType, listener) // Some events are actually targeted at the element // itself, so we only handle the ones where know that won't happen. let eventTypes = ["mousedown", "mouseup", "click"]; - if (eventTypes.indexOf(eventType) == -1) { + if (!eventTypes.includes(eventType) || !listener || + (typeof listener != "object" && typeof listener != "function")) { return listener; }