My favorites | Sign in
Project Home Wiki Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 2244: Some JavaScript 1.7+ features do not work in Console panel
6 people starred this issue and may be notified of changes. Back to list
 
Reported by mitcho%m...@gtempaccount.com, Aug 18, 2009
It seems that there is some scoping issue and JS1.7 array comprehensions
are not correctly interpreted in the console. Try some of these inputs:

> [a for each (a in [0,1])]

I get 'ReferenceError: a is not defined'

> var a = null; [a for each (a in [0,1])]

returns [null,null,null]. Incorrect. The variable a in the comprehension
should be given let (local) scope.

> eval("[b for each (b in [0,1])]")

This works: [0,1]. But if the console input is eval'ed anyway, how does
eval(eval()) magically make it work? Is it a scoping issue? Or a problem
with js1.7 code?

This is happening in Firefox 3.5.2, Firebug 1.4.2, though I have seen it on
other combinations before as well.

Aug 18, 2009
#1 mitcho%m...@gtempaccount.com
Correction:

> var a = null; [a for each (a in [0,1])]

returns [null,null], which makes a little more sense. The third element was a
different issue.
Aug 18, 2009
Project Member #2 johnjbar...@johnjbarton.com
So...is this a bug or not?

Command line works by eval in the web page in side of a block.  That aspect is
slightly wrong but we don't fix it since we will completely re-write the console.
Status: NeedInfo
Cc: johnjbar...@johnjbarton.com
Aug 18, 2009
#3 mitcho%m...@gtempaccount.com
John, I think it is clear that this is a bug. It is not interpreting the array
comprehension correctly at all, and I don't know why that would be, given that it's
being eval'ed.

If you're going to be rewriting the console, I guess maybe it's not of immediate
concern. :/
Aug 19, 2009
Project Member #4 johnjbar...@johnjbarton.com
For the test case in comment 1, what would be the correct answer? [0,1]?
Labels: Type-Enhancement commandLine 1.4 Test-case-available
Aug 19, 2009
#5 mitcho%m...@gtempaccount.com
Indeed. [0,1] is the correct answer, and is what you get when you wrap it in an eval
or execute in a regular script rather than the console.
Aug 25, 2009
Project Member #6 johnjbar...@johnjbarton.com
(No comment was entered for this change.)
Status: Triaged
Oct 13, 2009
#7 brianpeiris
According to MDC[1][2] you need to change the `type` attribute of your
`<script></script>` tag in order to use some of the new features added in JavaScript
1.7 and 1.8.
It took some Googling but I found a blog post[3] about the issue and it seems (from
what I can understand from the translated Japanese) you have to modify Firebug to use
the appropriate version setting before you can use the new features in the console:

https://code.google.com/p/fbug/source/browse/branches/firebug1.4/content/firebug/lib.js
287c287
<     element.setAttribute("type", "text/javascript");
---
>     element.setAttribute("type", "application/javascript;version=1.8");

Of course, more general solution would probably allow the user to opt-in to newer
versions of JavaScript via a menu option or perhaps Firebug could scan a page's
existing `type` attributes for the highest/lowest version and use whatever is
appropriate in the console.

I think this issue applies to Firebug 1.5 as well.

[1]: https://developer.mozilla.org/en/New_in_JavaScript_1.7
[2]: https://developer.mozilla.org/en/New_in_JavaScript_1.8#Using_JavaScript_1.8
[3]:
http://translate.google.ca/translate?hl=en&sl=ja&tl=en&u=http://niku.suku.name/item/611
Oct 13, 2009
Project Member #8 johnjbar...@johnjbarton.com
From one cryptic comment in an obscure file I guess that the current code should work
if the page itself uses js 1.8.

http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/e29883e29b206a92#

Based on your suggestion, we need a page with 1.8 code to test.
Labels: -Test-case-available Test-case-needed
Nov 14, 2011
#9 sebastia...@gmx.de
I finally created a test case for this issue, which should be available soon at http://getfirebug.com/tests/issues/2244/issue2244.html. For the case the server sync takes too long I also attached the file here.
issue2244.html
1.7 KB   View   Download
Cc: -johnjbar...@johnjbarton.com sebastia...@gmx.de
Labels: -Test-case-needed Test-case-in-suite
Nov 20, 2011
#10 BlindWan...@gmail.com
Not having access to the new javascript features drives me nuts.
Nov 20, 2011
#11 BlindWan...@gmail.com
This is duplicated by  Issue 3358 .
Nov 20, 2011
#12 sebastia...@gmx.de
 Issue 3358  has been merged into this issue.
Cc: odva...@gmail.com
Nov 20, 2011
#13 sebastia...@gmx.de
I generalized this issue, because not just array comprehensions are affected by this, but several other features like e.g. the 'let' statement and expression closures, too. See also  issue 3358 .
This seems to need platform support:
https://bugzilla.mozilla.org/show_bug.cgi?id=591961

@Honza: Because we don't want the Console panel to activate JSD by default ( issue 4978 ), how can this be achieved?

Sebastian
Summary: Some JavaScript 1.7+ features do not work in Console panel
Labels: platform
Mar 23, 2013
Project Member #14 sebastia...@gmail.com
(No comment was entered for this change.)
Cc: sebastia...@gmail.com
Mar 23, 2013
Project Member #15 sebastia...@gmail.com
(No comment was entered for this change.)
Cc: -sebastia...@gmx.de
Sign in to add a comment

Powered by Google Project Hosting