Adds check to useColors for ServiceWorker context

When bundling `debug` using `browserify` the browser version is used, and the `useColors` check crashes when in a ServiceWorker, because `document`, `window` and `navigator` are all `undefined`.
When in a browserify built bundle, it's an empty object. There is a global
'self' which resolves to 'global' which is a ServiceWorkerGlobalScope, but
that is just as bad or good. The spec is still unfinished, so the patch is
arguably questionable, but it shouldn't break anything in the form I've
submitted it.

.n
On 20 Sep 2014 19:46, "Nathan Rajlich" <notifications@github.com> wrote:

> In browser.js:
>
> > @@ -35,12 +35,14 @@ exports.colors = [
> >
> >  function useColors() {
> >    // is webkit? http://stackoverflow.com/a/16459606/376773
> > -  return ('WebkitAppearance' in document.documentElement.style) ||
> > +  return typeof ServiceWorkerGlobalScope == "undefined" && (
>
> Rather then special-casing ServiceWorkerGlobalScope, we should probably
> use global, global.document and global.navigator, which should work I
> would think.
>
> What does global resolve to when you execute a browserified script as a
> ServiceWorker?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/visionmedia/debug/pull/139/files#r17820437>.
>