Bug 917583 - part 3: fix the event-listeners test; r=fitzgen

This commit is contained in:
Panos Astithas 2013-11-20 08:49:55 -08:00
parent f5faeb076a
commit 71a5f95334

View File

@ -60,55 +60,77 @@ function testEventListeners(aThreadClient) {
let deferred = promise.defer(); let deferred = promise.defer();
aThreadClient.eventListeners(aPacket => { aThreadClient.eventListeners(aPacket => {
if (aPacket.error) {
let msg = "Error getting event listeners: " + aPacket.message;
ok(false, msg);
deferred.reject(msg);
return;
}
is(aPacket.listeners.length, 3, is(aPacket.listeners.length, 3,
"Found all event listeners."); "Found all event listeners.");
let types = []; promise.all(aPacket.listeners.map(listener => {
const lDeferred = promise.defer();
aThreadClient.pauseGrip(listener.function).getDefinitionSite(aResponse => {
if (aResponse.error) {
const msg = "Error getting function definition site: " + aResponse.message;
ok(false, msg);
lDeferred.reject(msg);
return;
}
listener.function.url = aResponse.url;
lDeferred.resolve(listener);
});
return lDeferred.promise;
})).then(listeners => {
let types = [];
for (let l of aPacket.listeners) { for (let l of listeners) {
let node = l.node; let node = l.node;
ok(node, "There is a node property."); ok(node, "There is a node property.");
ok(node.object, "There is a node object property."); ok(node.object, "There is a node object property.");
ok(node.selector == "window" || ok(node.selector == "window" ||
content.document.querySelectorAll(node.selector).length == 1, content.document.querySelectorAll(node.selector).length == 1,
"The node property is a unique CSS selector."); "The node property is a unique CSS selector.");
let func = l.function; let func = l.function;
ok(func, "There is a function property."); ok(func, "There is a function property.");
is(func.type, "object", "The function form is of type 'object'."); is(func.type, "object", "The function form is of type 'object'.");
is(func.class, "Function", "The function form is of class 'Function'."); is(func.class, "Function", "The function form is of class 'Function'.");
is(func.url, TAB_URL, "The function url is correct."); is(func.url, TAB_URL, "The function url is correct.");
is(l.allowsUntrusted, true, is(l.allowsUntrusted, true,
"'allowsUntrusted' property has the right value."); "'allowsUntrusted' property has the right value.");
is(l.inSystemEventGroup, false, is(l.inSystemEventGroup, false,
"'inSystemEventGroup' property has the right value."); "'inSystemEventGroup' property has the right value.");
types.push(l.type); types.push(l.type);
if (l.type == "keyup") { if (l.type == "keyup") {
is(l.capturing, true, is(l.capturing, true,
"Capturing property has the right value."); "Capturing property has the right value.");
is(l.isEventHandler, false, is(l.isEventHandler, false,
"'isEventHandler' property has the right value."); "'isEventHandler' property has the right value.");
} else if (l.type == "load") { } else if (l.type == "load") {
is(l.capturing, false, is(l.capturing, false,
"Capturing property has the right value."); "Capturing property has the right value.");
is(l.isEventHandler, false, is(l.isEventHandler, false,
"'isEventHandler' property has the right value."); "'isEventHandler' property has the right value.");
} else { } else {
is(l.capturing, false, is(l.capturing, false,
"Capturing property has the right value."); "Capturing property has the right value.");
is(l.isEventHandler, true, is(l.isEventHandler, true,
"'isEventHandler' property has the right value."); "'isEventHandler' property has the right value.");
}
} }
}
ok(types.indexOf("click") != -1, "Found the click handler."); ok(types.indexOf("click") != -1, "Found the click handler.");
ok(types.indexOf("change") != -1, "Found the change handler."); ok(types.indexOf("change") != -1, "Found the change handler.");
ok(types.indexOf("keyup") != -1, "Found the keyup handler."); ok(types.indexOf("keyup") != -1, "Found the keyup handler.");
aThreadClient.resume(deferred.resolve); aThreadClient.resume(deferred.resolve);
});
}); });
return deferred.promise; return deferred.promise;