mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
d6616a0ca4
The test flake was caused by a leaked instance of Playhead interfering with NetworkingEngine unit tests. The quickest way to reproduce a failure on the networking tests was to focus the unit tests for Playhead and NetworkingEngine and run the suite on IE11. Playhead tests tear down the Playhead object after each test. However, one test created two Playheads, effectively leaking one. That leaked Playhead would continue to poll the fake video element after the test was complete. Polling used setTimeout. The NetworkingEngine unit tests would mock setTimeout and show that the engine was calling it appropriately. However, the leaked Playhead would also call setTimeout during the NetworkingEngine test, which would cause an expectation on the number of calls to fail. The Playhead tests should clean up after themselves, but the NetworkingEngine tests should not have to mock global setTimeout in the first place. This change not only fixes the Playhead tests, but isolates NetworkingEngine's use of setTimeout to a private method which can be mocked without affecting global state. Change-Id: I94dd7f6c39c25f81c7e4122895ab5fae0feef2cb