Fix issue for running under node-webkit.
Under node-webkit we have both contexts 'window' and 'global'.
'window' is default context then we should check for window first.