Bug 1519597 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

On any web page, select a node in the inspector and type the following in the console:

    $0.addEventHandler('click', {})

Then, in the inspector, click on the 'event' marker that appears to the right of the node's start tag display. The attached image shows what I see: a silly-looking popup with an interior height of zero.

This problem arises from the following code in NodeActor's processHandlerForEvent method in devtools/server/actors/inspector/node.js:
```
    // If the listener is an object with a 'handleEvent' method, use that.
    if (listenerDO.class === "Object" || /^XUL\w*Element$/.test(listenerDO.class)) {
      let desc;

      while (!desc && listenerDO) {
        desc = listenerDO.getOwnPropertyDescriptor("handleEvent");
        listenerDO = listenerDO.proto;
      }

      if (desc && desc.value) {
        listenerDO = desc.value;
      }
    }

    // If the listener is bound to a different context then we need to switch
    // to the bound function.
    if (listenerDO.isBoundFunction) {
      listenerDO = listenerDO.boundTargetFunction;
    }
```
If the `while` loop exits without having found a `handleEvent` property, `listenerDO` is left set to `null`, and the check of the `isBoundFunction` property throws an exception.

(I'm not too familiar with this area of the code, but exceptions thrown from this code seem to be eaten. They don't appear in the browser console, the browser content console, or on stderr. That seems like a good way to waste people's time.)
On any web page, select a node in the inspector and type the following in the console:

    $0.addEventHandler('click', {})

Then, in the inspector, click on the 'event' marker that appears to the right of the node's start tag display. The attached image shows what I see: a silly-looking popup with an interior height of zero.

This problem arises from the following code in NodeActor's processHandlerForEvent method in devtools/server/actors/inspector/node.js:
```
    // If the listener is an object with a 'handleEvent' method, use that.
    if (listenerDO.class === "Object" || /^XUL\w*Element$/.test(listenerDO.class)) {
      let desc;

      while (!desc && listenerDO) {
        desc = listenerDO.getOwnPropertyDescriptor("handleEvent");
        listenerDO = listenerDO.proto;
      }

      if (desc && desc.value) {
        listenerDO = desc.value;
      }
    }

    // If the listener is bound to a different context then we need to switch
    // to the bound function.
    if (listenerDO.isBoundFunction) {
      listenerDO = listenerDO.boundTargetFunction;
    }
```
If the `while` loop exits without having found a `handleEvent` property, `listenerDO` is left set to `null`, and the check of the `isBoundFunction` property throws an exception.

Back to Bug 1519597 Comment 0