Skip to content
Permalink
Browse files
Web Inspector: selectElement.options shows unexpected entries in cons…
…ole (named indexes beyond collection length)

https://bugs.webkit.org/show_bug.cgi?id=159192

Patch by Joseph Pecoraro <pecoraro@apple.com> 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:

Canonical link: https://commits.webkit.org/177315@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Jun 28, 2016
1 parent 5bbf6be commit 62f11ed63c662551e3a6cf0cd955300909849d4e
@@ -1,3 +1,14 @@
2016-06-28 Joseph Pecoraro <pecoraro@apple.com>

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

Reviewed by Timothy Hatcher.

* inspector/model/remote-object-get-properties-expected.txt:
* inspector/model/remote-object-get-properties.html:
* inspector/runtime/getProperties-expected.txt:

2016-06-28 Brian Burg <bburg@apple.com>

Web Inspector: QuickConsole should update its selection when RuntimeManager.defaultExecutionContextIdentifier changes
@@ -318,5 +318,43 @@ ALL PROPERTIES:
constructor
__proto__
-----------------------------------------------------

-----------------------------------------------------
EXPRESSION: document.getElementById('my-select').options
type: object
subtype: array
description: HTMLOptionsCollection

OWN PROPERTIES:
0
__proto__

DISPLAYABLE PROPERTIES:
0
selectedIndex
length
__proto__

ALL PROPERTIES:
0
constructor
selectedIndex
length
item
namedItem
add
remove
toString
toLocaleString
valueOf
hasOwnProperty
propertyIsEnumerable
isPrototypeOf
__defineGetter__
__defineSetter__
__lookupGetter__
__lookupSetter__
__proto__
-----------------------------------------------------
DONE

@@ -45,7 +45,6 @@
var boundFunction = unboundFunction.bind(document.body, 1, 2, 3);
var objectWithSymbolProperties = {prop:1, [Symbol()]:2, [Symbol('sym')]:3, [Symbol('sym')]:4, [Symbol()]: Symbol(), prop2: 5};


// --------
// test
// --------
@@ -61,6 +60,7 @@
{expression: "window.unboundFunction"},
{expression: "window.boundFunction"},
{expression: "window.objectWithSymbolProperties"},
{expression: "document.getElementById('my-select').options"},
]

function runNextStep() {
@@ -115,5 +115,8 @@
</script>
</head>
<body onload="window.loadEvent = event; runTest()">
<select id="my-select" style="display: none">
<option name="1" id="attr_1" value="1"></option>
</select>
</body>
</html>
@@ -13,7 +13,6 @@ Properties:
0 string red
1 string green
2 string blue
length number 3

-- Running test case: CheckPropertiesOfBoundConstructor
Evaluating expression: Number.bind({}, 5)
@@ -1,3 +1,20 @@
2016-06-28 Joseph Pecoraro <pecoraro@apple.com>

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

Reviewed by Timothy Hatcher.

* 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.

2016-06-28 Per Arne Vollan <pvollan@apple.com>

[Win] Skip failing INTL test.
@@ -666,7 +666,7 @@ InjectedScript.prototype = {

function arrayIndexPropertyNames(o, length)
{
var array = new Array(length);
var array = [];
for (var i = 0; i < length; ++i) {
if (i in o)
array.push("" + i);
@@ -676,16 +676,16 @@ InjectedScript.prototype = {

// FIXME: <https://webkit.org/b/143589> Web Inspector: Better handling for large collections in Object Trees
// For array types with a large length we attempt to skip getOwnPropertyNames and instead just sublist of indexes.
var isArrayTypeWithLargeLength = false;
var isArrayLike = false;
try {
isArrayTypeWithLargeLength = injectedScript._subtype(object) === "array" && isFinite(object.length) && object.length > 100;
isArrayLike = injectedScript._subtype(object) === "array" && isFinite(object.length);
} catch(e) {}

for (var o = object; this._isDefined(o); o = o.__proto__) {
var isOwnProperty = o === object;

if (isArrayTypeWithLargeLength && isOwnProperty)
processProperties(o, arrayIndexPropertyNames(o, 100), isOwnProperty);
if (isArrayLike && isOwnProperty)
processProperties(o, arrayIndexPropertyNames(o, Math.min(object.length, 100)), isOwnProperty);
else {
processProperties(o, Object.getOwnPropertyNames(o), isOwnProperty);
if (Object.getOwnPropertySymbols)

0 comments on commit 62f11ed

Please sign in to comment.