dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
212 stars 75 forks source link

Evaluated variables that are DOM elements do not have any fields/getters #2183

Open DanTup opened 1 year ago

DanTup commented 1 year ago

Moving this from https://github.com/Dart-Code/Dart-Code/issues/4673 as it feels like a DWDS issue.

When hitting a breakpoint and looking at local variables (which come from the topFrame), variables that are DOM elements do not contain any fields like a standard class would.

When we walk up the class hierarchy looking for getters, we also find no getters - but I do see fields on the superclasses:

<== {
    "jsonrpc": "2.0",
    "result": {
        // ...
        "fields": [
            {
                "type": "@Field",
                "id": "742",
                "name": "mouseWheelEvent",
                // ...
            },

In the VM, fields from superclasses show up on the variable, so this seems like a difference. I think if these fields are really fields they should be on the variable itself, or if they are considered getters they should be marked as such (instead of fields).

bkonyi commented 3 weeks ago

cc @natebiggs I'm not sure what could be causing this. Do you have any thoughts?

bkonyi commented 3 weeks ago

@DanTup is this issue related? https://github.com/dart-lang/webdev/issues/2180

DanTup commented 3 weeks ago

Hmmm, I'm a little confused by these two issues. https://github.com/dart-lang/webdev/issues/2180 says that variables that are DOM elements do not show up in the topFrame, but this issue says that they show up but have no fields. It seems like only one of these can be true.

It's been a while since I filed these so I will retest and post back.

DanTup commented 3 weeks ago

Seems like both of them are issues, though the title here is a bit misleading so I'll update it.

This issue is that if you evaluate something that is a DOM element, it has no fields (see the Watch pane here):

image

We evaluate the expression back and get an instance, then call getObject() for it (and the result has no fields), and then getObject() for the class (and the result for that also has no fields or functions):


// Evaluate "a" and get back an instance
==> [VM] {"jsonrpc":"2.0","id":"711","method":"evaluateInFrame","params":{"isolateId":"1","frameIndex":0,"expression":"a","disableBreakpoints":true}}
<== [VM] {
    "jsonrpc": "2.0",
    "result": {
        "type": "@Instance",
        "id": "-8676362967872990568.1.508",
        "kind": "PlainInstance",
        "identityHashCode": 1044638811,
        "class": {
            "type": "@Class",
            "id": "classes|dart:_interceptors|InputElement",
            "name": "InputElement",
            "library": {
                "type": "@Library",
                "id": "dart:_interceptors",
                "name": "dart:_interceptors",
                "uri": "dart:_interceptors"
            }
        }
    },
    "id": "711"
}

// Get the object
==> [VM] {"jsonrpc":"2.0","id":"716","method":"getObject","params":{"isolateId":"1","objectId":"-8676362967872990568.1.508"}}
<== [VM] {
    "jsonrpc": "2.0",
    "result": {
        "type": "Instance",
        "id": "-8676362967872990568.1.508",
        "class": {
            "type": "@Class",
            "id": "classes|dart:_interceptors|InputElement",
            "name": "InputElement",
            "library": {
                "type": "@Library",
                "id": "dart:_interceptors",
                "name": "dart:_interceptors",
                "uri": "dart:_interceptors"
            }
        },
        "kind": "PlainInstance",
        "identityHashCode": 1044638811,
        "fields": []
    },
    "id": "716"
}

// Get the class
==> [VM] {"jsonrpc":"2.0","id":"717","method":"getObject","params":{"isolateId":"1","objectId":"classes|dart:_interceptors|InputElement"}}
<== [VM] {
    "jsonrpc": "2.0",
    "result": {
        "type": "Class",
        "id": "classes|dart:_interceptors|InputElement",
        "name": "InputElement",
        "library": {
            "type": "@Library",
            "id": "dart:_interceptors",
            "name": "dart:_interceptors",
            "uri": "dart:_interceptors"
        },
        "abstract": false,
        "const": false,
        "isSealed": false,
        "isMixinClass": false,
        "isBaseClass": false,
        "isInterfaceClass": false,
        "isFinal": false,
        "traceAllocations": false,
        "interfaces": [],
        "fields": [],
        "functions": [],
        "subclasses": []
    },
    "id": "717"
}