Created
April 23, 2013 13:32
-
-
Save past/5443573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Ci = Components.interfaces; | |
var Cc = Components.classes; | |
let eventListenerService = Cc["@mozilla.org/eventlistenerservice;1"] | |
.getService(Ci.nsIEventListenerService); | |
let dbg = new Debugger(); | |
let DOwindow = dbg.addDebuggee(content.window); | |
let nodes = content.window.document.querySelectorAll("*"); | |
nodes = [content.window].concat(Array.prototype.slice.call(nodes)); | |
for (let node of nodes) { | |
let handlers = eventListenerService.getListenerInfoFor(node); | |
for (let handler of handlers) { | |
let listener = handler.listenerObject; | |
let fName = handler.type; | |
let dom0 = !!node["on" + fName]; | |
let nodeName = getNodeName(node); | |
log("Node: " + nodeName); | |
log("Type: " + fName); | |
log("DOM0: " + dom0); | |
log("Capturing: " + handler.capturing); | |
log("Allows Untrusted: " + handler.allowsUntrusted); | |
log("System Event: " + handler.inSystemEventGroup); | |
if (listener) { | |
var listenerDO = DOwindow.makeDebuggeeValue(listener); | |
var script = listenerDO.script; | |
var url = script.url; | |
var line = script.startLine; | |
log("Origin: " + url + ":" + line); | |
} | |
log("---------------------------------------------------------"); | |
} | |
} | |
function getNodeName(node) { | |
let nodeName = (node.nodeName + "").toLowerCase(); | |
if (node.id) { | |
nodeName += "#" + node.id; | |
} | |
if (node.className) { | |
nodeName += "." + node.className; | |
} | |
if (nodeName == "undefined") { | |
nodeName = "window " + node.document.location.href; | |
} | |
return nodeName; | |
} | |
dbg.removeDebuggee(DOwindow); | |
function log(msg) { | |
dump(msg + "\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment