[whatwg] Exposing UA information to workers

Aaron Boodman aa at google.com
Fri Nov 14 19:05:57 PST 2008


Jonas asked me about this in IRC, and specifically why I suggested
appCodeName (since everyone claims they are Mozilla). My thinking was:

a) Browser detection is a mess, scripts use everything on the
navigator object (often incorrectly) to try and figure out which
browser is which
b) HTML5 may eventually define something better

Therefore, I could see two rational things for workers to expose: all
of whatever window.navigator has today, or whatever the new better API
is that HTML5 defines. I guess doing some subset of what
window.navigator does today could also be rational, but I don't know
how to pick the subset.

FWIW, here is the browser detection code that many Google apps use:

http://code.google.com/p/doctype/wiki/ArticleUserAgent

It uses:
- userAgent
- product
- vendor
- platform

- a

On Mon, Nov 3, 2008 at 3:59 PM, Jonas Sicking <jonas at sicking.cc> wrote:
> For future compat it would be good to expose to workers information on what
> browser is currently being used. This can be used to work around bugs and
> lack of features.
>
> In a 'normal' window context the navigator object exposes a set of
> properties, such as userAgent, that can be used for this purpose. I suggest
> we add something similar to the worker context. The HTML5 spec defines the
> following:
>
> interface Navigator {
>  // client identification
>  readonly attribute DOMString appName;
>  readonly attribute DOMString appVersion;
>  readonly attribute DOMString platform;
>  readonly attribute DOMString userAgent;
>
>  // ... other things not related to identifying the UA
> };
>
> I'm not sure how stable this part of the HTML5 spec is, (I know firefox
> exposes a whole host of more properties), but it seems like a good set to
> start with. We should probably keep the two in sync if the window context
> Navigator object changes in the future.
>
>
> Orthoginally, it seems like at least the 'onLine' boolean on the Navigator
> interface would be useful too, and could be exposed at the same place.
>
> Let me know what you think.
>
> / Jonas
>



More information about the whatwg mailing list