[whatwg] Example wrong in web workers
atwilson at google.com
Mon Oct 26 13:31:48 PDT 2009
FWIW, I've usually looked at self.postMessage when trying to determine
whether running in dedicated or shared worker context, although Anne's
suggestion (using "in") is better.
On Mon, Oct 26, 2009 at 7:00 AM, Anne van Kesteren <annevk at opera.com> wrote:
> On Mon, 26 Oct 2009 13:57:10 +0100, Simon Pieters <simonp at opera.com>
>> Web Workers has the following in some example (twice):
>> // support being used as a shared worker as well as a dedicated worker
>> if (this.onmessage) // dedicated worker
>> This ought to be doing something like (typeof this.onmessage !=
>> 'undefined') , as the event property is presumably 'null' by the time of the
> ("onmessage" in this) might be somewhat safer fwiw.
> Anne van Kesteren
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the whatwg