comparison random-stuff/random-stuff.js @ 22:ecd868a32247

better error logging, streamlined example
author Atul Varma <varmaa@toolness.com>
date Thu, 07 May 2009 15:42:53 -0700
parents e82bff1ef296
children
comparison
equal deleted inserted replaced
21:e82bff1ef296 22:ecd868a32247
76 } 76 }
77 77
78 function logError(element) { 78 function logError(element) {
79 var window = element.ownerDocument.defaultView; 79 var window = element.ownerDocument.defaultView;
80 var console = window.wrappedJSObject.console; 80 var console = window.wrappedJSObject.console;
81 console.error.apply(console, arguments); 81 if (console)
82 console.error.apply(console, arguments);
83 else {
84 var items = ["<" + element.nodeName.toLowerCase() + ">"];
85 for (var i = 1; i < arguments.length; i++)
86 items.push(arguments[i].toString());
87 Components.utils.reportError(items.join(" "));
88 }
82 } 89 }
83 90
84 function absolutifyUrl(document, url) { 91 function absolutifyUrl(document, url) {
85 var anchor = document.createElement("a"); 92 var anchor = document.createElement("a");
86 anchor.setAttribute("href", url); 93 anchor.setAttribute("href", url);