路宁(luning)的博客

    <<  A Quick Check of Javascript Code Quality | Home | Remove the Noisy Thread.Sleep and WaitForCondition from Selenium Tests  >>
  • 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.

     


    历史上的今天:

    软件开发中的准时化生产 2008-04-28

    随机文章:

    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
    Tag:Javascript Firebug Firefox Events
    Cite url:
    published this at 19:18:38 | Edit | Continue This Topic | Forward | 分享 0
  • RSS EMail Me

Search

Latest logs

  • Manage Mock Dependencies of Controllers with IoC Container
  • The Waste from Very Fat to Very Lean's Perspective
  • A Misleading Analogy between Software Development and Manufacturing
  • Selenium Test Powered by jQuery.parcel
  • Remove the Noisy Thread.Sleep and WaitForCondition from Selenium Tests
  • Code Snippet to Log All Events as They Are Triggered
  • A Quick Check of Javascript Code Quality
  • Implement Object Builder for Testing in a .NET Object Initializer Style
  • 看过《丰田现场管理方式》,30年前出版的书
  • Make visible both progress and smell
全部日志>>

Comments

  • taowen:http://taowen.github.com/bay...
  • dewwind88:呵呵,我信!我也是自己深有同感~-网络上的陌生人,搜索到...
  • sean xu:项目忙完了吗?好像很久没写精益方面的文章了:)...
  • 菜头:good summary ^.^
  • luning:你是说如何确定适合自己team的switch频率吧,多尝...
  • jackie chen:LN,想问问:怎样计算switch pair rate ...
  • sabrina:路子分析的很有道理哦!...
  • sabrina:虽然我不是很懂技术,但是能看出你的用心,加油哦!...
  • ncholas ren:where is the 'continue...'
  • laura:不错,好好学习!

Categories

  • Lean[21]
  • Software Development[2]
  • Agile[15]
  • Life[1]
  • Economics[3]
  • Misc[0]
  • Test[7]
  • Javascript[2]

Tag

  • 敏捷[32]
  • 精益[29]
  • Agile[22]
  • 软件开发[19]
  • Lean[15]
More..