-
Notifications
You must be signed in to change notification settings - Fork 2
Debugging
Aerilius edited this page Apr 6, 2013
·
2 revisions
You can use Firebug Lite to help debugging your HTML+JS in WebDialogs. http://getfirebug.com/lite.html
webdialog.execute_script("(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened');")
In Internet Explorer you can suppress script error popups by defining an onerror event handler that returns true
. With a Ruby callback you can redirect error message to the Ruby console.
Assuming you have an action callback "puts":
window.onerror = function(errorMsg, url, lineNumber){
window.location.href = "skp:puts@" + encodeURIComponent("JavaScript error:\n"+url+" (line "+lineNumber+"): "+errorMsg);
return true;
}
You can register a fake program (empty, without action) as a custom application protocol handler for skp:
(only in that browser) to suppress browser errors about "unknown protocol". This allows to test and inspect everything except callbacks to Ruby.
http://kb.mozillazine.org/Register_protocol