inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Property values on platform objects are misreported as "forbidden"

Open mootari opened this issue 4 years ago • 2 comments

When walking an object, valueof attempts to access properties on the object's prototype: https://github.com/observablehq/inspector/blob/fe14a1befb66d197f22750312e650a33d7c5608c/src/object.js#L18-L26

Due to implementation details for getters on platform objects this throws TypeError: Illegal invocation, which then gets caught and misinterpreted as SecurityError. As a result the property value is rendered as [forbidden].

To reproduce:

  1. Create a cell that returns a native object (e.g. screen, performance)
  2. Expand the object

mootari avatar Oct 07 '21 09:10 mootari

Slack thread: https://observablehq.slack.com/archives/C01LADG5CF6/p1633558706168700

mootari avatar Dec 31 '21 02:12 mootari

Proof of concept illustrating two parts of a potential fix:

  • Change the proto argument from a boolean to track the root object we are inspecting, and invoke getters with descriptor.get.apply
  • Show the getter name in an italic font

jleedev avatar Jan 25 '23 17:01 jleedev