Bug 930097 - Fix an exact rooting false positive in worker event dispatch; r=bent

--HG--
extra : rebase_source : 8fcffa0b3aa4e381b8fdce6abfd9f05e88829768
This commit is contained in:
Terrence Cole 2013-10-23 15:32:50 -07:00
parent 5a05edfe2d
commit 115bbf99fa

View File

@ -338,29 +338,14 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
return false;
}
ContextAllocPolicy ap(aCx);
// XXXbent There is no reason to use nsAutoJSValHolder here as we should be
// able to use js::AutoValueVector. Worse, nsAutoJSValHolder is much
// slower. However, js::AutoValueVector causes crashes on Android at
// the moment so we don't have much choice.
js::Vector<nsAutoJSValHolder, 10, ContextAllocPolicy> listeners(ap);
JS::AutoValueVector listeners(aCx);
for (ListenerData* listenerData = collection->mListeners.getFirst();
listenerData;
listenerData = listenerData->getNext()) {
// Listeners that don't want untrusted events will be skipped if this is an
// untrusted event.
if (eventIsTrusted || listenerData->mWantsUntrusted) {
nsAutoJSValHolder holder;
if (!holder.Hold(aCx)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return false;
}
holder = listenerData->mListener;
if (!listeners.append(holder)) {
if (!listeners.append(OBJECT_TO_JSVAL(listenerData->mListener))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return false;
}