Bug 21142 - Inspector needs a way to enumerate properties without side effects
Summary: Inspector needs a way to enumerate properties without side effects
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-26 05:31 PDT by Oliver Hunt
Modified: 2010-07-19 00:05 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2008-09-26 05:31:58 PDT
I noticed this while looking at an XSS issue, and finding that the console was getting filled with security errors

in the console do:
a = {get foo(){console.log("wibble");}} <enter>
a.<tab repeatedly>

watch as the console fills with output (or at least increases the log count for wibble)


I'm not sure exactly what the inspector is doing here, but it needs a side effect free way to enumerate properties, and a way to distinguish those properties that can be subsequently accessed without side effects from those that cannot.
Comment 1 Sam Weinig 2008-09-27 16:06:47 PDT
Enumerating properties should be side effect free.  The issue is that once you have completed a property which is a getter, trying to enumerate it causes a get, which can cause side effects.  While it is possible to solve this for vanilla JavaScript objects by checking to see if the property is a getter and not doing a get, I don't think it is possible to solve this for host objects, since any get can potentially have side effects.  ie. calling window.document calls a c++ function which can do whatever it wants and we have no way of knowing that.  I don't think the host object issue is really that relevant.
Comment 2 Sam Weinig 2008-09-27 16:09:26 PDT
Actually, I am not convinced that not getting is a good idea.  It seems plausible that someone would want to drill down into an object treating getters as plain old properties (for instance, in debugging the inspector itself, which makes heavy use of getters/setters).
Comment 3 Timothy Hatcher 2008-09-27 16:50:47 PDT
In reality getters don't usually have bad side-affects. Most cases of getters in the inspector code are just foo() { return this.foo }.

There is a bug in the Inspector completion code that I can't find yet, but we are triggering the getting in a case where we should not.
Comment 4 Oliver Hunt 2010-03-27 18:06:13 PDT
The inspector _could_ use getOwnPropertyDescriptor which is ostensibly side effect free.
Comment 5 Timothy Hatcher 2010-03-27 21:53:19 PDT
We use getOwnPropertyNames in TOT.
Comment 6 Oliver Hunt 2010-03-28 12:57:21 PDT
getOwnPropertyDescriptor can give you the value of a property without calling any getters, etc
Comment 7 Alexander Pavlov (apavlov) 2010-07-19 00:05:55 PDT
This issue seems fixed in ToT (r63644). The original test case produces no output.