michael@0: // ---------------------- michael@0: // DumpDOM(node) michael@0: // michael@0: // Call this function to dump the contents of the DOM starting at the specified node. michael@0: // Use node = document.documentElement to dump every element of the current document. michael@0: // Use node = top.window.document.documentElement to dump every element. michael@0: // michael@0: // 8-13-99 Updated to dump almost all attributes of every node. There are still some attributes michael@0: // that are purposely skipped to make it more readable. michael@0: // ---------------------- michael@0: function DumpDOM(node) michael@0: { michael@0: dump("--------------------- DumpDOM ---------------------\n"); michael@0: michael@0: DumpNodeAndChildren(node, ""); michael@0: michael@0: dump("------------------- End DumpDOM -------------------\n"); michael@0: } michael@0: michael@0: michael@0: // This function does the work of DumpDOM by recursively calling itself to explore the tree michael@0: function DumpNodeAndChildren(node, prefix) michael@0: { michael@0: dump(prefix + "<" + node.nodeName); michael@0: michael@0: var attributes = node.attributes; michael@0: michael@0: if ( attributes && attributes.length ) michael@0: { michael@0: var item, name, value; michael@0: michael@0: for ( var index = 0; index < attributes.length; index++ ) michael@0: { michael@0: item = attributes.item(index); michael@0: name = item.nodeName; michael@0: value = item.nodeValue; michael@0: michael@0: if ( (name == 'lazycontent' && value == 'true') || michael@0: (name == 'xulcontentsgenerated' && value == 'true') || michael@0: (name == 'id') || michael@0: (name == 'instanceOf') ) michael@0: { michael@0: // ignore these michael@0: } michael@0: else michael@0: { michael@0: dump(" " + name + "=\"" + value + "\""); michael@0: } michael@0: } michael@0: } michael@0: michael@0: if ( node.nodeType == 1 ) michael@0: { michael@0: // id michael@0: var text = node.getAttribute('id'); michael@0: if ( text && text[0] != '$' ) michael@0: dump(" id=\"" + text + "\""); michael@0: } michael@0: michael@0: if ( node.nodeType == Node.TEXT_NODE ) michael@0: dump(" = \"" + node.data + "\""); michael@0: michael@0: dump(">\n"); michael@0: michael@0: // dump IFRAME && FRAME DOM michael@0: if ( node.nodeName == "IFRAME" || node.nodeName == "FRAME" ) michael@0: { michael@0: if ( node.name ) michael@0: { michael@0: var wind = top.frames[node.name]; michael@0: if ( wind && wind.document && wind.document.documentElement ) michael@0: { michael@0: dump(prefix + "----------- " + node.nodeName + " -----------\n"); michael@0: DumpNodeAndChildren(wind.document.documentElement, prefix + " "); michael@0: dump(prefix + "--------- End " + node.nodeName + " ---------\n"); michael@0: } michael@0: } michael@0: } michael@0: // children of nodes (other than frames) michael@0: else if ( node.childNodes ) michael@0: { michael@0: for ( var child = 0; child < node.childNodes.length; child++ ) michael@0: DumpNodeAndChildren(node.childNodes[child], prefix + " "); michael@0: } michael@0: }