[Webkit-unassigned] [Bug 137306] Web Inspector: Expanding event objects in console shows undefined for most values, it should have real values

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Dec 15 16:47:54 PST 2014


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

--- Comment #2 from Joseph Pecoraro <joepeck at webkit.org> ---
Seems like under the hood the inspector depends on the Object.getOwnPropertyNames.

Given a simple test:

    <button id="x">Click Me</button>
    <script>
    document.getElementById('x').addEventListener('click', function(event) {
        console.log( Object.getOwnPropertyNames(event) );
    }, false);
    </script>

Browsers seem to disagree:

    Safari: ["clipboardData"]
    Firefox: [ "isTrusted" ]
    Chrome: ["dataTransfer", "which", "toElement", "fromElement", "y", "x", "offsetY", "offsetX", "webkitMovementY", "webkitMovementX", "movementY", "movementX", "relatedTarget", "button", "metaKey", "altKey", "shiftKey", "ctrlKey", "clientY", "clientX", "screenY", "screenX", "keyCode", "charCode", "pageY", "pageX", "layerY", "layerX", "detail", "view", "clipboardData", "path", "cancelBubble", "returnValue", "srcElement", "defaultPrevented", "timeStamp", "cancelable", "bubbles", "eventPhase", "currentTarget", "target", "type"]


So, it looks like what is happening is:

  1. Inspector builds RemoteObject for “event”
    => gets a shallow list of event’s own properties and __proto__
    => the own properties list is pretty shallow, most event properties are on the __proto__
    => inspector UI builds an object tree (ObjectPropertiesSection)
  2. When expanding __proto__ Inspector builds a RemoteObject for “event.__proto__”
    => gets a shallow list of event.__proto__’s pwn properties, using event.__proto__ as the base obj
    => the list of properties is correct
    => the values of properties is incorrect (event.__proto__[x] !== event[x])

So, this looks totally broken.

My interpretation of this is that prototype properties would have never worked in an ObjectPropertiesSection, as they would always have been relative to the wrong object.

Doing the same steps manually in the console I would have gotten a deprecation warning anyways:

    js> Object.getOwnPropertyDescriptor(x.__proto__.screenX)
    [Error] Deprecated attempt to access property 'screenX' on a non-MouseEvent object.
    < undefined

The move of properties to prototype is expected behavior defined by WebIDL implemented in WebKit in:
http://trac.webkit.org/changeset/r163562

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20141216/c6d906ab/attachment-0002.html>


More information about the webkit-unassigned mailing list