Index: lib/child/requestNotifier.js |
=================================================================== |
--- a/lib/child/requestNotifier.js |
+++ b/lib/child/requestNotifier.js |
@@ -361,8 +361,54 @@ RequestNotifier.addNodeData = function(n |
*/ |
RequestNotifier.getWindowStatistics = function(/**Window*/ wnd) |
{ |
if (windowStats.has(wnd.document)) |
return windowStats.get(wnd.document); |
else |
return null; |
} |
+ |
+/** |
+ * Retrieves the request data associated with a DOM node. |
+ * @param {Node} node |
+ * @param {Boolean} noParent if missing or false, the search will extend to the parent nodes until one is found that has data associated with it |
+ * @param {Integer} [type] request type to be looking for |
+ * @param {String} [location] request location to be looking for |
+ * @result {[Node, Object]} |
+ * @static |
+ */ |
+RequestNotifier.getDataForNode = function(node, noParent, type, location) |
+{ |
+ while (node) |
+ { |
+ let data = nodeData.get(node); |
+ if (typeof data != "undefined") |
+ { |
+ let entry = null; |
+ // Look for matching entry |
+ for (let k in data) |
+ { |
+ if ((!entry || entry.id < data[k].id) && |
+ (typeof type == "undefined" || data[k].type == type) && |
+ (typeof location == "undefined" || data[k].location == location)) |
+ { |
+ entry = data[k]; |
+ } |
+ } |
+ if (entry) |
+ return [node, entry]; |
+ } |
+ |
+ // If we don't have any match on this node then maybe its parent will do |
+ if ((typeof noParent != "boolean" || !noParent) && |
+ node.parentNode instanceof Ci.nsIDOMElement) |
+ { |
+ node = node.parentNode; |
+ } |
+ else |
+ { |
+ node = null; |
+ } |
+ } |
+ |
+ return null; |
+}; |