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
This commit is contained in:
Rob Wu 2016-10-17 18:54:23 +02:00
Родитель 2dda282bea
Коммит 90c596e654
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -611,7 +611,8 @@ function makeFilteringListener(eventType, listener)
// Some events are actually targeted at the <browser> 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;
}