Bug 883096 - Crash at nsEventListenerManager::GetListenerInfo, r=jst

--HG--
extra : rebase_source : 2073283f4b23586fac0a3ae4243a50b745912a20
This commit is contained in:
Olli Pettay 2013-06-14 20:10:22 +03:00
parent 2c2d131dc7
commit 5310ede209
3 changed files with 16 additions and 2 deletions

View File

@ -16,6 +16,7 @@ interface nsIEventListenerInfo : nsISupports
{
/**
* The type of the event for which the listener was added.
* Null if the listener is for all the events.
*/
readonly attribute AString type;
readonly attribute boolean capturing;

View File

@ -1167,8 +1167,12 @@ nsEventListenerManager::GetListenerInfo(nsCOMArray<nsIEventListenerInfo>* aList)
CompileEventHandlerInternal(const_cast<nsListenerStruct*>(&ls),
true, nullptr);
}
const nsDependentSubstring& eventType =
Substring(nsDependentAtomString(ls.mTypeAtom), 2);
nsAutoString eventType;
if (ls.mAllEvents) {
eventType.SetIsVoid(true);
} else {
eventType.Assign(Substring(nsDependentAtomString(ls.mTypeAtom), 2));
}
// EventListenerInfo is defined in XPCOM, so we have to go ahead
// and convert to an XPCOM callback here...
nsRefPtr<nsEventListenerInfo> info =

View File

@ -184,6 +184,15 @@ function testAllListener() {
}
els.addListenerForAllEvents(root, allListener, false, true);
var infos = els.getListenerInfoFor(root);
var nullTypes = 0;
for (var i = 0; i < infos.length; ++i) {
if (infos[i].type == null) {
++nullTypes;
}
}
is(nullTypes, 1, "Should have one all-event-listener!");
els.addListenerForAllEvents(root, allListener, false, true, true);
els.addListenerForAllEvents(root, allListenerTrustedOnly, false, false, true);
l3.dispatchEvent(new Event("testevent", { bubbles: true }));