-
Code Snippet to Log All Events as They Are Triggered - [Javascript]
2009-04-28
I paired with Josh Price wrote the javascript code below, just before that we noticed something abnormal about event handling and wanted to find out what happened.
Just paste the code below into Firebug console of Firefox, run it, do something triggering events in page and watch the log printed out.
Please note that this requires jQuery.
var counter = 0; $("*").each(function() { var events = $(this).data('events'); if(events) { $.each(events, function(type, handlers) { $.each(handlers, function(i, handler){ handlers[i] = function(){ handler.apply(this, arguments); console.log(++counter, type); }; }); }); } });
You can add more logging per your need, e.g. the time used for each handler call.随机文章:
A Quick Check of Javascript Code Quality 2009-03-30利用客户端Javascript代码简化Selenium测试 2008-12-23将客户端逻辑封装进Javascript对象,并用Jsunit做单元测试 2008-11-04敏捷和精益对我日常生活观点的影响 2008-12-17关于书架是库存的一段对话 2008-01-22
收藏到:Del.icio.us
<< A Quick Check of Javascript Code Quality | Home | Remove the Noisy Thread.Sleep and WaitForCondition from Selenium Tests >>