Changeset 202568 in webkit


Ignore:
Timestamp:
Jun 28, 2016 8:33:49 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: selectElement.options shows unexpected entries in console (named indexes beyond collection length)
https://bugs.webkit.org/show_bug.cgi?id=159192

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2016-06-28
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

  • inspector/InjectedScriptSource.js:

(InjectedScript.prototype.arrayIndexPropertyNames):
Start with an empty array because we just push valid indexes.

(InjectedScript.prototype._propertyDescriptors):
Avoid the >100 length requirement, and always treat the
array-like objects the same. The frontend currently
doesn't show named indexes for arrays anyways, so they
would have been unused.

LayoutTests:

  • inspector/model/remote-object-get-properties-expected.txt:
  • inspector/model/remote-object-get-properties.html:
  • inspector/runtime/getProperties-expected.txt:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202566 r202568  
     12016-06-28  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: selectElement.options shows unexpected entries in console (named indexes beyond collection length)
     4        https://bugs.webkit.org/show_bug.cgi?id=159192
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * inspector/model/remote-object-get-properties-expected.txt:
     9        * inspector/model/remote-object-get-properties.html:
     10        * inspector/runtime/getProperties-expected.txt:
     11
    1122016-06-28  Brian Burg  <bburg@apple.com>
    213
  • trunk/LayoutTests/inspector/model/remote-object-get-properties-expected.txt

    r200585 r202568  
    319319    __proto__
    320320-----------------------------------------------------
     321
     322-----------------------------------------------------
     323EXPRESSION: document.getElementById('my-select').options
     324type: object
     325subtype: array
     326description: HTMLOptionsCollection
     327
     328OWN PROPERTIES:
     329    0
     330    __proto__
     331
     332DISPLAYABLE PROPERTIES:
     333    0
     334    selectedIndex
     335    length
     336    __proto__
     337
     338ALL PROPERTIES:
     339    0
     340    constructor
     341    selectedIndex
     342    length
     343    item
     344    namedItem
     345    add
     346    remove
     347    toString
     348    toLocaleString
     349    valueOf
     350    hasOwnProperty
     351    propertyIsEnumerable
     352    isPrototypeOf
     353    __defineGetter__
     354    __defineSetter__
     355    __lookupGetter__
     356    __lookupSetter__
     357    __proto__
     358-----------------------------------------------------
    321359DONE
    322360
  • trunk/LayoutTests/inspector/model/remote-object-get-properties.html

    r201855 r202568  
    4646var objectWithSymbolProperties = {prop:1, [Symbol()]:2, [Symbol('sym')]:3, [Symbol('sym')]:4, [Symbol()]: Symbol(), prop2: 5};
    4747
    48 
    4948// --------
    5049//   test
     
    6261        {expression: "window.boundFunction"},
    6362        {expression: "window.objectWithSymbolProperties"},
     63        {expression: "document.getElementById('my-select').options"},
    6464    ]
    6565
     
    116116</head>
    117117<body onload="window.loadEvent = event; runTest()">
     118    <select id="my-select" style="display: none">
     119        <option name="1" id="attr_1" value="1"></option>
     120    </select>
    118121</body>
    119122</html>
  • trunk/LayoutTests/inspector/runtime/getProperties-expected.txt

    r201619 r202568  
    1414  1 string green
    1515  2 string blue
    16   length number 3
    1716
    1817-- Running test case: CheckPropertiesOfBoundConstructor
  • trunk/Source/JavaScriptCore/ChangeLog

    r202567 r202568  
     12016-06-28  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: selectElement.options shows unexpected entries in console (named indexes beyond collection length)
     4        https://bugs.webkit.org/show_bug.cgi?id=159192
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * inspector/InjectedScriptSource.js:
     9        (InjectedScript.prototype.arrayIndexPropertyNames):
     10        Start with an empty array because we just push valid indexes.
     11
     12        (InjectedScript.prototype._propertyDescriptors):
     13        Avoid the >100 length requirement, and always treat the
     14        array-like objects the same. The frontend currently
     15        doesn't show named indexes for arrays anyways, so they
     16        would have been unused.
     17
    1182016-06-28  Per Arne Vollan  <pvollan@apple.com>
    219
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js

    r201168 r202568  
    667667        function arrayIndexPropertyNames(o, length)
    668668        {
    669             var array = new Array(length);
     669            var array = [];
    670670            for (var i = 0; i < length; ++i) {
    671671                if (i in o)
     
    677677        // FIXME: <https://webkit.org/b/143589> Web Inspector: Better handling for large collections in Object Trees
    678678        // For array types with a large length we attempt to skip getOwnPropertyNames and instead just sublist of indexes.
    679         var isArrayTypeWithLargeLength = false;
     679        var isArrayLike = false;
    680680        try {
    681             isArrayTypeWithLargeLength = injectedScript._subtype(object) === "array" && isFinite(object.length) && object.length > 100;
     681            isArrayLike = injectedScript._subtype(object) === "array" && isFinite(object.length);
    682682        } catch(e) {}
    683683
     
    685685            var isOwnProperty = o === object;
    686686
    687             if (isArrayTypeWithLargeLength && isOwnProperty)
    688                 processProperties(o, arrayIndexPropertyNames(o, 100), isOwnProperty);
     687            if (isArrayLike && isOwnProperty)
     688                processProperties(o, arrayIndexPropertyNames(o, Math.min(object.length, 100)), isOwnProperty);
    689689            else {
    690690                processProperties(o, Object.getOwnPropertyNames(o), isOwnProperty);
Note: See TracChangeset for help on using the changeset viewer.