Skip to content

Instantly share code, notes, and snippets.

@iamcal
Created January 8, 2019 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamcal/bc95fed0d4567f53ae5cae1420446a2f to your computer and use it in GitHub Desktop.
Save iamcal/bc95fed0d4567f53ae5cae1420446a2f to your computer and use it in GitHub Desktop.
xul runner helper script
function myDumpO(x, no_recurse){
myDump(parse_obj("", x, no_recurse));
}
function parse_obj(prefix, x, no_recurse){
//myDump('called with '+no_recurse+' and '+prefix.length);
if (typeof(x)=='object'){
if (no_recurse && prefix != ''){
return 'object';
}
var buffer = "{\n";
for (var i in x){
//myDump('found prop '+i);
var value = '[Exception]';
try {
value = parse_obj(prefix+"\t", x[i], no_recurse);
}catch(e){ }
buffer += prefix+"\t"+i+": "+value+"\n";
}
buffer += prefix+"}";
return buffer;
}else if (typeof(x)=='function'){
return 'function(){}';
try { return x.toString(); }catch(e){ }
}else{
try { return x.toString(); }catch(e){ }
}
return '[Exception]';
}
function myDump(aMessage) {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(aMessage);
}
function myDumpXML(root){
myDump(new XMLSerializer().serializeToString(root));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment