[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Firefox Console hiding output

ram

6/27/2014 4:49:00 PM

What global objects are there? Well, ... it should be easy
to see! But the Console of Firefox shows me the output
only from line 316 on, it seems to hide the first 315 lines.
(I pasted the code into the Firefox Console prompt.)

{ let l = Object.getOwnPropertyNames( this );
let n = l.length; for( let i = 0; i < n; ++i )
console.log( i + ' ' + l[ i ]); }

undefined
"316 MediaStreamAudioDestinationNode"
"317 DynamicsCompressorNode"
"318 DeviceProximityEvent"
....

(»...« marks lines omitted by me [S.R.].)

If one does not know this and does not print line numbers,
one might be led to believe that this is all there is:

{ let l = Object.getOwnPropertyNames( this );
let n = l.length; for( let i = 0; i < n; ++i )
console.log( l[ i ]); }

undefined
"MediaStreamAudioDestinationNode"
"DynamicsCompressorNode"
"DeviceProximityEvent"
....

8 Answers

Thomas 'PointedEars' Lahn

6/27/2014 6:52:00 PM

0

Stefan Ram wrote:

> What global objects are there? Well, ... it should be easy
> to see! But the Console of Firefox shows me the output
> only from line 316 on, it seems to hide the first 315 lines.
> (I pasted the code into the Firefox Console prompt.)
>
> { let l = Object.getOwnPropertyNames( this );
> let n = l.length; for( let i = 0; i < n; ++i )
> console.log( i + ' ' + l[ i ]); }

I found it interesting that this cannot be written more naturally as

for (let l = Object.getOwnPropertyNames(this),
n = l.length,
i = 0;
i < n; ++i)
{
console.log(i, l[i]);
}

because that throws

| ReferenceError: l is not defined

in line 2 (at n = l.length), as a â??try { â?¦ } catch (e) { e.lineNumber }â?
shows.

I think that either the Mozilla JavaScript implementation of the ES 6 draft
or the ES 6 draft are borken with regard to â??letâ?. IMHO, â??letâ? should work
exactly like â??varâ? except that variables so declared should be scoped to the
statement and, in the case of the â??forâ?, â??ifâ? and â??whileâ? statements, the
statement that follows (here: a Block statement).

> undefined
> "316 MediaStreamAudioDestinationNode"
> "317 DynamicsCompressorNode"
> "318 DeviceProximityEvent"
> ...
> [â?¦]

I cannot reproduce that. It is worse here (Iceweasel 30.0):

var a = Object.getOwnPropertyNames(this); console.log(a.length); for (var
i = 0, len = a.length; i < len; ++i) console.log(i);
| > Object { }

But:

Object.getOwnPropertyNames(this);
| > Array [ "Object", "Function", "eval", "window", "location", "top",
| "Components", "XPCNativeWrapper", "TextDecoder", "TextEncoder", 601 moreâ?¦
| ]

I have Firebug 2.0.1 installed, apparently this has something do with it as
disabling Firebug gets me the elements starting from index 411. Regardless,
something is very wrong there. Sometimes, for a moment I can see there 601,
0, 1, 2, 3, 4 before it is replaced with 411, 412 and so on. There appears
to be a very limited non-scrollable output buffer.

BTW, disabling Firebug 2.0.1 killed the Web console input display until
Return. Sometimes it the input line disappears for no reason at all until I
resize the window.

Scrolling appears to be borken sometimes as well.

I think the Firefox Web Console is a poor substitute both for the Firebug
Console and the Chrome Dev Tools console at the moment. What bothers me in
particular is that code has to be input into a small line at the bottom of
the window (at the bottom of the screen if you have a full-screen window),
and the output appears *above* it, first *duplicating the input* (instead of
just displaying the output/result *below*). There is the Scratchpad, but it
is comparably clumsy, as I have to switch between windows.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

JJ

6/28/2014 9:38:00 PM

0

On 27 Jun 2014 16:49:15 GMT, Stefan Ram wrote:
> What global objects are there? Well, ... it should be easy
> to see! But the Console of Firefox shows me the output
> only from line 316 on, it seems to hide the first 315 lines.
> (I pasted the code into the Firefox Console prompt.)
>
> { let l = Object.getOwnPropertyNames( this );
> let n = l.length; for( let i = 0; i < n; ++i )
> console.log( i + ' ' + l[ i ]); }
>
> undefined
> "316 MediaStreamAudioDestinationNode"
> "317 DynamicsCompressorNode"
> "318 DeviceProximityEvent"
> ...
>
> (»...« marks lines omitted by me [S.R.].)
>
> If one does not know this and does not print line numbers,
> one might be led to believe that this is all there is:
>
> { let l = Object.getOwnPropertyNames( this );
> let n = l.length; for( let i = 0; i < n; ++i )
> console.log( l[ i ]); }
>
> undefined
> "MediaStreamAudioDestinationNode"
> "DynamicsCompressorNode"
> "DeviceProximityEvent"
> ...

Did that happen on all web pages, including blank HTML file?

ram

6/29/2014 12:47:00 AM

0

JJ <jj4public@vfemail.net> writes:
>Did that happen on all web pages, including blank HTML file?

I only ever tried it in the debugger with no web page at all:

JSON.stringify( document )
"{"location":{}}"

.

JJ

6/29/2014 8:03:00 AM

0

On 29 Jun 2014 00:47:16 GMT, Stefan Ram wrote:
> JJ <jj4public@vfemail.net> writes:
>>Did that happen on all web pages, including blank HTML file?
>
> I only ever tried it in the debugger with no web page at all:
>
> JSON.stringify( document )
> "{"location":{}}"
>
> .

There are log limits enforced.
So, only the last N number of lines are displayed.

Type this in the about:config.

devtools.hud.loglimit.

Thomas 'PointedEars' Lahn

6/29/2014 8:35:00 AM

0

Stefan Ram wrote:

> JJ <jj4public@vfemail.net> writes:
>> Did that happen on all web pages, including blank HTML file?
>
> I only ever tried it in the debugger with no web page at all:
>
> JSON.stringify( document )
> "{"location":{}}"

Works as designed, see ES 5.1 §15.12.3.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Thomas 'PointedEars' Lahn

6/29/2014 9:00:00 AM

0

JJ wrote:

> On 29 Jun 2014 00:47:16 GMT, Stefan Ram wrote:
>> JJ <jj4public@vfemail.net> writes:
>>> Did that happen on all web pages, including blank HTML file?
>>
>> I only ever tried it in the debugger with no web page at all:
>>
>> JSON.stringify( document )
>> "{"location":{}}"
>>
>> .
>
> There are log limits enforced.

Yes, but that is not the reason for the above result. This is:

Object.getOwnPropertyNames(document).filter(function (name) { return
Object.getOwnPropertyDescriptor(document, name).enumerable; })
| < Array [ "location" ]

And in Chromium:

JSON.stringify(document)
| TypeError: Converting circular structure to JSON

Object.getOwnPropertyNames(document).filter(function (name) { return
Object.getOwnPropertyDescriptor(document, name).enumerable; })
| Array[147]

The structure is â??circularâ? in WebCore because at least â??document.bodyâ? and
â??document.body.ownerDocumentâ? (=== document) are own, enumerable properties.

In general, it is a Bad Idea to subject host objects to JSON
stringification.

> So, only the last N number of lines are displayed.
>
> Type this in the about:config.
>
> devtools.hud.loglimit.

(easier with â??loglimitâ?)

Thanks; the default for devtools.hud.loglimit.console is 200 which explains
the observations. Unfortunately, there appears to be no way to disable the
limit (neither negative values nor 0 work).

The least that should be done by Mozilla is to display a notice that the log
limit has been reached and that output is incomplete.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

JJ

6/29/2014 1:48:00 PM

0

On Sun, 29 Jun 2014 10:59:33 +0200, Thomas 'PointedEars' Lahn wrote:
> JJ wrote:
>
>> On 29 Jun 2014 00:47:16 GMT, Stefan Ram wrote:
>>> JJ <jj4public@vfemail.net> writes:
>>>> Did that happen on all web pages, including blank HTML file?
>>>
>>> I only ever tried it in the debugger with no web page at all:
>>>
>>> JSON.stringify( document )
>>> "{"location":{}}"
>>>
>>> .
>>
>> There are log limits enforced.
>
> Yes, but that is not the reason for the above result.

You're right. That's just to show that there's no document loaded when he
tested the code.

> This is:
>
> Object.getOwnPropertyNames(document).filter(function (name) { return
> Object.getOwnPropertyDescriptor(document, name).enumerable; })
>| < Array [ "location" ]
>
> And in Chromium:
>
> JSON.stringify(document)
>| TypeError: Converting circular structure to JSON
>
> Object.getOwnPropertyNames(document).filter(function (name) { return
> Object.getOwnPropertyDescriptor(document, name).enumerable; })
>| Array[147]
>
> The structure is ?circular? in WebCore because at least ?document.body? and
> ?document.body.ownerDocument? (=== document) are own, enumerable properties.
>
> In general, it is a Bad Idea to subject host objects to JSON
> stringification.

I just noticed that. Why didn't JSON.stringify generate an exception?

>> So, only the last N number of lines are displayed.
>>
>> Type this in the about:config.
>>
>> devtools.hud.loglimit.
>
> (easier with ?loglimit?)
>
> Thanks; the default for devtools.hud.loglimit.console is 200 which explains
> the observations. Unfortunately, there appears to be no way to disable the
> limit (neither negative values nor 0 work).

Yes, disabling the log output completely doesn't seem possible. Zero or less
value settings are treated as 1. Disabling the limit on the other hand,
would mean having infinite lines, but the setting value itself is limited by
32-bit signed number.

Thomas 'PointedEars' Lahn

6/29/2014 4:08:00 PM

0

JJ wrote:

> On Sun, 29 Jun 2014 10:59:33 +0200, Thomas 'PointedEars' Lahn wrote:
>> JJ wrote:
>>> On 29 Jun 2014 00:47:16 GMT, Stefan Ram wrote:
>>>> JJ <jj4public@vfemail.net> writes:
>>>>> Did that happen on all web pages, including blank HTML file?
>>>>
>>>> I only ever tried it in the debugger with no web page at all:
>>>>
>>>> JSON.stringify( document )
>>>> "{"location":{}}"
>>>>
>>>> .
>>>
>>> There are log limits enforced.
>> Yes, but that is not the reason for the above result.
>
> You're right. That's just to show that there's no document loaded when he
> tested the code.

I see, but that is not a viable proof either. I get the same with a
document loaded because that is how JSON.stringify() works. See below.

>> This is:
>>
>> Object.getOwnPropertyNames(document).filter(function (name) { return
>> Object.getOwnPropertyDescriptor(document, name).enumerable; })
>>| < Array [ "location" ]
>>
>> And in Chromium:
>>
>> JSON.stringify(document)
>>| TypeError: Converting circular structure to JSON
>>
>> Object.getOwnPropertyNames(document).filter(function (name) { return
>> Object.getOwnPropertyDescriptor(document, name).enumerable; })
>>| Array[147]
>>
>> The structure is â??circularâ? in WebCore because at least â??document.bodyâ?
>> and â??document.body.ownerDocumentâ? (=== document) are own, enumerable
>> properties.
>>
>> In general, it is a Bad Idea to subject host objects to JSON
>> stringification.
>
> I just noticed that. Why didn't JSON.stringify generate an exception?

| > Object.getOwnPropertyNames(document)
| < Array [ "location" ]

indicates that the object referred to by â??documentâ? in the Gecko DOM does
not have own properties except â??locationâ?, which is also enumerable (and
deprecated in favor of â??window.locationâ?). It refers to an object that, as
far as Object.getOwnPropertyNames() is applicable to host objects, inherits
all of its properties:

| > Object.getOwnPropertyNames(document.location)
| Array [ ]

The next object in its prototype chain is

| > Object.getPrototypeOf(document.location)
| < XPC_WN_NoMods_NoCall_Proto_JSClass { href: Getter, hash: Getter, host:
| Getter, hostname: Getter, pathname: Getter, port: Getter, protocol:
| Getter, search: Getter, origin: Getter, reload: reload(), 5 moreâ?¦ }

which provides the expected properties.

So even though â??documentâ? is in that sense â??circularâ? in the Gecko DOM, too,
no object in that network of references is visited twice by Mozilla
JavaScriptâ??s JSON.stringify(). But the latter is a requirement for throwing
a TypeError exception, see ES 5.1, §15.12.3, JO(value), step 1.

This is different in the WebCore DOM, even if Google V8 JavaScript that is
used by Chromium implements the same algorithm as Mozilla JavaScript that is
used by Firefox/Iceweasel.


A draft reference implementation of ECMAScript (current target is the 5.1
Edition) in ECMAScript [1] is available on the ES Matrix site with the
global â??esâ? property. For example, you can enter

try { es.JSON.stringify(document); } catch (e) { e.stack }

in the console to see where and why the exception should be thrown. I have
also included a call tracer that you can enable with

es.enableTrace = true;

(assigning the default â??falseâ? disables tracing again).


It is considered polite to post using oneâ??s real name.

________
[1] <http://PointedEars.de/scripts/test/es-matrix/application/scripts...
--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not Cc: me. / Bitte keine Kopien per E-Mail.