Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE8 has console error #161

Closed
sdaikichi opened this issue Jul 25, 2016 · 14 comments · Fixed by #241
Closed

IE8 has console error #161

sdaikichi opened this issue Jul 25, 2016 · 14 comments · Fixed by #241

Comments

@sdaikichi
Copy link

I running multi-browser Javascript tests which catch console messages.
Only IE 8(and older) has Console Error:"'prototype' is null or not an object"

(Screenshots with BrowserStack Live)
image

Probably it comes from JSON3
bestiejs/json3#86

@jzaefferer
Copy link
Contributor

@flore77 this might've been introduced by #159, can you check that?

@flore77
Copy link
Contributor

flore77 commented Jul 25, 2016

Yes, I will check.

@flore77
Copy link
Contributor

flore77 commented Jul 25, 2016

@sdaikichi from where have you installed browserstack-runner? npm? or here from github?

@jzaefferer if he got it from npm, then it is definitely not from #159, because they didn't make a new release after merging.

@sdaikichi
Copy link
Author

@flore77 I installed from npm.

@vedharish
Copy link
Contributor

vedharish commented Jul 26, 2016

The console error is from browserstack-util.js and is present in the already released version. Issue is with IE 8 and lower.

@jzaefferer
Copy link
Contributor

@tr4n2uil could you look into that? Seems like a recent regression

@vedharish
Copy link
Contributor

@sdaikichi Can you please confirm the test framework that you are using? If you are using qunit, you need to include qunit.js in your html files. Also qunit >= 2.0.0 does not support IE8

@sdaikichi
Copy link
Author

@vedharish Im using mocha.

@jzaefferer
Copy link
Contributor

Its not documented anywhere and accordingly hard to tell, but I think Mocha supports IE8: https://github.com/mochajs/mocha/blob/master/karma.conf.js#L91

@tr4n2uil
Copy link
Contributor

tr4n2uil commented Aug 4, 2016

@sdaikichi Are you still facing this issue ?

@sdaikichi
Copy link
Author

@tr4n2uil yes.

@oliverfriedmann
Copy link

The issue seems to be that Webpack injects an empty exports = {} as a "root" object into JSON3, but JSON3 sort-of requires the global window object as a root on IE <= 8.

@mohitmun
Copy link
Contributor

mohitmun commented Mar 9, 2018

As mentioned by @oliverfriedmann, JSON3 requires the global window object as a root, but here issue is not with webpack, but with following condition in json3

var freeGlobal = typeof global == "object" && global;
if (freeGlobal && (freeGlobal["global"] === freeGlobal || freeGlobal["window"] === freeGlobal)) {
  root = freeGlobal;
}

apart from IE8, other browsers evaluates window.window === window as true, but IE8 evaluates to false. it doesn't enter if condition and window is not assigned to root.
Checkout this comment.

@carhartl
Copy link

carhartl commented Jan 3, 2019

I‘m running out of ideas.. is there any way to workaround this? We aimed to but can‘t run automated tests in IE 6-8 due to this.

The question whether we should still be testing in these browsers is another one :)

Krinkle added a commit to Krinkle/browserstack-runner that referenced this issue Apr 11, 2021
Follows-up 826d2c7.

Before that commit, the reason global "console" was globbered is that the
`var console` part of the inner `var console = {}` assignment was hosted by
the JavaScript engine. Thus the variable always existed in the local scope as
type "undefined", and so the conditional check never saw the real console, and
always created a custom one. Thus it always deleted the original console reference,
as well as any other it contained.

In commit 826d2c7, this was incorrectly fixed by assigning the unchecked
expression referring to `console`, thus no longer having a fallback to `{}` in older
browsers, because an unchecked reference like that throws an Uncaught ReferenceError.

As a result, browserstack-runner was unable to run in IE 9 or older.

Fixes browserstack#161.
Fixes browserstack#164.
Fixes browserstack#212.
Krinkle added a commit to qunitjs/browserstack-runner that referenced this issue Apr 11, 2021
Follows-up 826d2c7.

Before that commit, the reason global "console" was globbered is that the
`var console` part of the inner `var console = {}` assignment was hosted by
the JavaScript engine. Thus the variable always existed in the local scope as
type "undefined", and so the conditional check never saw the real console, and
always created a custom one. Thus it always deleted the original console reference,
as well as any other it contained.

In commit 826d2c7, this was incorrectly fixed by assigning the unchecked
expression referring to `console`, thus no longer having a fallback to `{}` in older
browsers, because an unchecked reference like that throws an Uncaught ReferenceError.

As a result, browserstack-runner was unable to run in IE 9 or older.

Fixes browserstack#161.
Fixes browserstack#164.
Fixes browserstack#212.
Ref browserstack#241.
francisf pushed a commit that referenced this issue Apr 21, 2021
Follows-up 826d2c7.

Before that commit, the reason global "console" was globbered is that the
`var console` part of the inner `var console = {}` assignment was hosted by
the JavaScript engine. Thus the variable always existed in the local scope as
type "undefined", and so the conditional check never saw the real console, and
always created a custom one. Thus it always deleted the original console reference,
as well as any other it contained.

In commit 826d2c7, this was incorrectly fixed by assigning the unchecked
expression referring to `console`, thus no longer having a fallback to `{}` in older
browsers, because an unchecked reference like that throws an Uncaught ReferenceError.

As a result, browserstack-runner was unable to run in IE 9 or older.

Fixes #161.
Fixes #164.
Fixes #212.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants