[André, if you are not up for reviewing this, let me know and I will get someone else, but I thought you might be an interested party...]

Change 20070930-ptw-P by [EMAIL PROTECTED] on 2007-09-30 18:01:29 EDT
    in /Users/ptw/OpenLaszlo/ringding-2
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Don't trust length as an indicator of array elements

Bugs Fixed:
LPP-4441 'Debugger misbehaves when debugging objects with "length" attribute.'

Technical Reviewer: [EMAIL PROTECTED] (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: jsundman (pending)

Documentation:
NOTE:  If you have Firebug enabled in Firefox, the LZX debugger echos
all messages to the Firebug console, preserving objects.  The Firebug
debugger will attempt to interpret an object with a `length` field as
an array and try to print every array element.  This may cause a
'Script Running Slowly' error.  Disabling Firebug will prevent that.

Details:
    Don't trust length to indicate how many properties are in an
    object (or elements in an array).  Instead, get the properties
    from the object using `for ... in`.  We still present any object
    with a `length` property that is non-negative as an array, but we
    won't try to iterate through the entire array.  This is useful for
    sparse arrays, but also for objects that just happen to have a
    non-negative length property.

    LzDebug.lzs:  Added Debug.objectOwnProperties that gets the names
    of all the 'own' properties of the object.  If the object has a
    non-negative `length` property, accumulate the properties that are
    between 0 and that length in a separate list of indices.

    LzDebug.{as,js}:  Use that to print and inspect objects and arrays
    without falling into the trap of iterating from 0 to length.
    Basically, the old presentation style is preserved, but we iterate
    _only_ over the properties the object actually has.

Tests:
lzx> Debug.write({1: 'one', 97: 'ninety-seven', a: 'eh?', floogle: 'snort', length: 100000000, __proto__: {bar: 'bletch'}})
    «Object(100000000)#127| [..., one, ..., ninety-seven]»
    lzx> Debug.inspect([..., one, ..., ninety-seven])
    «Object(100000000)#127| [..., one, ..., ninety-seven]» {
      a: 'eh?'
      floogle: 'snort'
      length: 100000000
      1: 'one'
      97: 'ninety-seven'
    }
    [..., one, ..., ninety-seven]
    lzx>

    Above completes without "Script Running Slowly".  Tested in SWF
    and DHTML (with Firebug disabled, see Documentation NOTE above).

    smokecheck passes in DHTML and SWF (which tests Debug.format,
which uses __String, showing that the expected presentation is preserved).

Files:
M      WEB-INF/lps/lfc/debugger/LzDebug.lzs
M      WEB-INF/lps/lfc/debugger/platform/swf/LzDebug.as
M      WEB-INF/lps/lfc/debugger/platform/dhtml/LzDebug.js

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20070930-ptw- P.tar

Reply via email to