3

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

ldlchina
  • 927
  • 2
  • 12
  • 31
  • 1
    As you can see https://crbug.com/661613 is WontFix so to convince the developers you'll need to prove it's their fault by [providing a bisect log](https://www.chromium.org/developers/bisect-builds-py) that would identify the cause. Or simply install a working version of Chrome. – wOxxOm Nov 12 '16 at 12:49
  • I saw that bug. I can not believe it is marked WontFix. Everything works well with previous versions of Chrome 54. Is it not regression of Chrome 54? I can not believe. – ldlchina Nov 12 '16 at 13:09
  • The protocol within Chrome can change over time. As said in the issue, file a bug report with `node-inspector` as it is not a Chrome issue. Recently the Chrome team has been working on native Node debugging. Might be worth checking out that work and see if it works for you. – Garbee Nov 13 '16 at 21:15
  • Does the software development need to consider backward compatibility? – ldlchina Nov 14 '16 at 02:34
  • I understand the change in Chrome may be reasonable. But does the software development need to consider backward compatibility? Avoid regression once a product is released to user. I'm using CEF 31.0.1650.57. It works well all the time before updating to Chrome 54. Sometimes, it is expensive to update the CEF components for big products. Any way to resolve this problem without updating CEF components? I also found node-inspector has the same issue with Chrome 54, just took node-inspector for example. – ldlchina Nov 14 '16 at 02:41
  • Same problem here http://stackoverflow.com/questions/41083622/chrome-console-doesnt-work-for-variables-in-node-inspector-browser-ui-how-to-e – Green Dec 11 '16 at 06:37
  • It's caused by Chrome 54 deprecating `KeyboardEvent.keyIdentifier` – spex Mar 29 '17 at 15:47

2 Answers2

4

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;
}
Ricardo
  • 3,696
  • 5
  • 36
  • 50
  • Thanks. This workaround should work for node-inspector. What about the workaround for old cef? – ldlchina Dec 01 '16 at 02:23
  • This will only fix the enter key. It will not fix tab-complete, arrow keys, etc. Please see the other answer for a fix that handles all of these scenarios. – spex Apr 07 '17 at 14:29
2

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.

spex
  • 1,110
  • 10
  • 21