зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1300606 - DeviceType event handlers/listeners aren't removed properly, r=mccr8
This commit is contained in:
Родитель
6b94deded3
Коммит
16a7908638
|
@ -652,7 +652,6 @@ EventListenerManager::RemoveEventListenerInternal(
|
|||
Listener* listener;
|
||||
|
||||
uint32_t count = mListeners.Length();
|
||||
uint32_t typeCount = 0;
|
||||
bool deviceType = IsDeviceType(aEventMessage);
|
||||
|
||||
RefPtr<EventListenerManager> kungFuDeathGrip(this);
|
||||
|
@ -661,23 +660,18 @@ EventListenerManager::RemoveEventListenerInternal(
|
|||
listener = &mListeners.ElementAt(i);
|
||||
if (EVENT_TYPE_EQUALS(listener, aEventMessage, aUserType, aTypeString,
|
||||
aAllEvents)) {
|
||||
++typeCount;
|
||||
if (listener->mListener == aListenerHolder &&
|
||||
listener->mFlags.EqualsForRemoval(aFlags)) {
|
||||
mListeners.RemoveElementAt(i);
|
||||
--count;
|
||||
NotifyEventListenerRemoved(aUserType);
|
||||
if (!deviceType) {
|
||||
return;
|
||||
if (!aAllEvents && deviceType) {
|
||||
DisableDevice(aEventMessage);
|
||||
}
|
||||
--typeCount;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!aAllEvents && deviceType && typeCount == 0) {
|
||||
DisableDevice(aEventMessage);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -927,6 +921,9 @@ EventListenerManager::RemoveEventHandler(nsIAtom* aName,
|
|||
if (listener) {
|
||||
mListeners.RemoveElementAt(uint32_t(listener - &mListeners.ElementAt(0)));
|
||||
NotifyEventListenerRemoved(aName);
|
||||
if (IsDeviceType(eventMessage)) {
|
||||
DisableDevice(eventMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@ is(hasListeners(), false, "Must not have listeners before tests start");
|
|||
|
||||
function dumbListener(event) {}
|
||||
function dumbListener2(event) {}
|
||||
function dumbListener3(event) {}
|
||||
|
||||
window.addEventListener("deviceorientation", dumbListener, false);
|
||||
window.addEventListener("random_event_name", function() {}, false);
|
||||
window.addEventListener("deviceorientation", dumbListener2, false);
|
||||
|
||||
is(hasListeners(), true, "Listeners should have been added");
|
||||
|
@ -46,11 +48,23 @@ window.setTimeout(function() {
|
|||
window.removeEventListener("deviceorientation", dumbListener2, false);
|
||||
window.setTimeout(function() {
|
||||
is(hasListeners(), false, "Listeners should have been removed");
|
||||
SimpleTest.finish();
|
||||
testEventHandler();
|
||||
}, 0);
|
||||
}, 0);
|
||||
}, 0);
|
||||
|
||||
function testEventHandler() {
|
||||
window.ondeviceorientation = function() {}
|
||||
window.setTimeout(function() {
|
||||
is(hasListeners(), true, "Handler should have been added");
|
||||
window.ondeviceorientation = null;
|
||||
window.setTimeout(function() {
|
||||
is(hasListeners(), false, "Handler should have been removed");
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
}, 0)
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче