Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome inspector console does not work with version 54.0.2840.99

I use node-inspector to debug JS with Chrome version 54.0.2840.99. I enter "node-inspector" in one windows cmd console and "node --debug-brk l:\dev\debug\test.js" in another windows cmd console. Open "http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858" in Chrome. It's able to debug as usual. But I input "1 + 2" in Chrome console, press "Enter", nothing happen. I would expect "3" is output to Chrome console. It did work with Chrome version 48.0.2564.116. I did not test with other Chrome versions.

Is it a defect of the new Chrome versions? How to resolve the problem? I captured the pictures as below: enter image description here

enter image description here enter image description here

like image 230
ldlchina Avatar asked Feb 21 '26 17:02

ldlchina


2 Answers

A workaround, as suggested here, by trojanliu would be editing DOMExtension.js file, changing the isEnterKey() function...

vi /usr/local/lib/node_modules/node-inspector/front-end/platform/DOMExtension.js 
/isEnterKey

... to check for the keyCode === 13:

function isEnterKey(event) {
  //suit for event.keyIdentifier
  return (event.keyCode !== 229 && event.keyIdentifier === "Enter") || event.keyCode === 13;
}
like image 52
Ricardo Avatar answered Feb 24 '26 05:02

Ricardo


It's caused by Chrome deprecating KeyboardEvent.keyIdentifier.

The workaround would be to add keyIdentifier back to the KeyboardEvent prototype.

I also noticed that the KeyboardEvent.key string values are different from those from KeyboardEvent.keyIdentifier so I show below how to handle those differences if needed.

Object.defineProperty(KeyboardEvent.prototype, 'keyIdentifier', {
    get: function() {
        switch (this.key) {
            case "ArrowDown":
                return "Down";
                break;
            case "ArrowLeft":
                return "Left";
                break;
            case "ArrowRight":
                return "Right";
                break;
            case "ArrowUp":
                return "Up";
                break;
            case "Tab":
                return "U+0009";
                break;
            case "Escape":
                return "U+001B";
                break;
            default:
                return this.key;
        } 
    }
});

Simply replacing isEnterKey() is not sufficient and the above code handles this fix.

like image 31
spex Avatar answered Feb 24 '26 07:02

spex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!