function waitForUpdateMessageWrapper(prototype, name, methodName) {
    pendingWaitWrapperCalls += 1;
    const original = prototype[methodName];
    prototype[methodName] =
      /**
       * @this {Object}
       * @return {*}
       */
      // eslint-disable-next-line no-restricted-syntax
      async function() {
        pendingWaitWrapperCalls -= 1;
        shaka.log.debug(
            'Waiting for update message before calling ' +
            name + '.' + methodName + '...');
        const originalArguments = Array.from(arguments);
        await waitForUpdateMessages();
        return original.apply(this, originalArguments);
      };
    toRestore.push(() => {
      prototype[methodName] = original;
    });
  }
Creates a wrapper around a method on a given prototype, which makes it
wait on waitForUpdateMessages before returning, and registers that wrapper
to be uninstalled afterwards.
The replaced method is expected to be a method that returns a promise.
@param {!Object} prototype
@param {string} name
@param {string} methodName