fix: Fix conflicts with multiple installations #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Most polyfills used in Shaka Player can be installed more than once, because they can check for the necessity of the polyfill synchronously. This is not the case for eme-encryption-scheme-polyfill, which has to install a temporary shim to determine the need for a true polyfill on the first call.
This polyfill checked for a previous installation, but only using a static field on the class. This system breaks in our test environment, where there can be multiple copies of the polyfill: one compiled into Shaka Player as an internal component, and one in source form for unit tests. When both of these are installed at once, they couldn't detect each other because their private static fields were on distinct classes.
To resolve this, we attach bools to
navigator
that allow multiple versions of the polyfill to detect each other. This fixes Shaka Player test failures and mistakenly skipped tests on some platforms.