Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: storm.mark@gmail.com Newsgroups: comp.lang.javascript Subject: Is this the only way to unit-test an events abstraction? Date: Tue, 20 Dec 2011 09:16:52 -0800 (PST) Organization: http://groups.google.com Lines: 35 Message-ID: <6567149.685.1324401412063.JavaMail.geo-discussion-forums@yqbo42> Reply-To: comp.lang.javascript@googlegroups.com NNTP-Posting-Host: 82.69.39.185 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1324401412 24632 127.0.0.1 (20 Dec 2011 17:16:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 20 Dec 2011 17:16:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.69.39.185; posting-account=T4f16goAAADn50g7_7A3mHd3PneLhXVB User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:9460 Hi, I have two questions: 1.) How best to unit-test an event listener? 2.) Have I properly understood isHostMethod? I'm trying to unit-test an event listener abstraction but the only way I ca= n think to test it is against the window 'load' event. I've a code example here: https://gist.github.com/1502326 Also, I'm using David Mark's (@cinsoft) isHostMethod to detect the relevant= host object support but was wondering if I had properly understood the con= cepts or not? So for example, am I right in thinking that a host object/met= hod should be available under the following conditions (although I understa= nd that these 'conditions' are unreliable): - if typeof returns 'function' (for majority browsers) - if typeof returns 'unknown' (for IE < 9 where its implementation used Act= iveX objects for native Functions) - if typeof returns 'object' and the value isn't 'null' (because ES3 specs = have allowed null to return 'object' which is incorrect behaviour) If any of these conditions are true then that (again, unreliably) *should* = mean that the specified host method is available to use. But even still the host object/method might be implemented differently to h= ow the specification dictates it should be and so it would be more accurate= to do full 'feature detection' where I create the object and see if an eve= nt is triggered (or some similar test)? Thanks for any advice regarding both these enquiries. Mark.