shaka-project / eme_logger

Logs Encrypted Media Extension (EME) events and calls to help investigate issues in premium media sites.
https://chrome.google.com/webstore/detail/eme-call-and-event-logger/cniohcjecdcdhgmlofniddfoeokbpbpb
Apache License 2.0
104 stars 24 forks source link

Pollution in global scope #44

Closed jrummell-chromium closed 1 year ago

jrummell-chromium commented 2 years ago

With EME Logger enabled, on an internal site, I get the following error and the page fails to load properly. Without EME Logger enabled the page loads properly.

alerts.js:formatted:1 Uncaught SyntaxError: Identifier 'options' has already been declared (at alerts.js:formatted:1:1)

eme-trace-config.js does define const options = ..., so I assume that alerts.js does the same. The page should probably be changed to use unique names that are unlikely to collide with other pages, or wrap the variables inside a function.

(I also noticed that there are some global functions like byteToHexString. I wonder if they should be renamed (or placed inside a class)?)

joeyparrish commented 2 years ago

Perhaps instead, the scripts that are injected into the page should have a scope wrapper:

(() => {
  const whateverIWantToCallIt = 'This will not leak';
})();
joeyparrish commented 2 years ago

See #45 for an example of a public site that breaks because of this

matthuisman commented 2 years ago

Fyi. This has been issue for quite a few years. I only just thought of disabling extensions to try to fix :)

joeyparrish commented 2 years ago

@matthuisman, thanks for letting us know. We will work on an update to fix it.