noscript icon indicating copy to clipboard operation
noscript copied to clipboard

patchWindow.js might try to patch non-window objects and log errors

Open Karuljonnai opened this issue 1 year ago • 5 comments

On my SO post, I enter in detail on how I got a bug because of NoScript. But, basically, on patchWindow.js:291, it's using a deprecated interface HTMLFrameElement, which throws an TypeError: win[(("HTML" + (intermediate value)) + "Element")] is undefined

Karuljonnai avatar Feb 21 '24 18:02 Karuljonnai

On my SO post

That link seems broken.

Which browser version are you finding this in?

However probably checking if the interface is there is a good idea anyway.

hackademix avatar Feb 21 '24 19:02 hackademix

I updated the link. I'm on Kubuntu 22.04, Firefox 123.0, NoScript 11.4.29

Karuljonnai avatar Feb 21 '24 19:02 Karuljonnai

Is the i variable numeric (i.e. "0")?

hackademix avatar Feb 21 '24 20:02 hackademix

Yes, .map enumerates the results with the 2nd argument i.

Karuljonnai avatar Feb 21 '24 20:02 Karuljonnai

Yes, .map enumerates the results with the 2nd argument i.

Then what is happening is quite clear: you're adding your elements as window[number], which would normally reference subframes' window objects (where HTMLFrameElement is defined - deprecation is not the issue here).

Fortunately this cannot alias the actual window objects (meant to be wrapped) if they're present, and your code won't break anyway because the exception is just logged, not rethrown, but that's annoying nonetheless, if nothing else because of the console noise.

Therefore I'm fixing this in next NoScript version, thanks.

hackademix avatar Feb 21 '24 20:02 hackademix