async function injectStorage(page, storage, storageType) {
    if (!page || !storage || !storageType) {
      return;
    }

    /* istanbul ignore next */
    await page.evaluateOnNewDocument(
      (storage, storageType, SESSION_STORAGE, LOCAL_STORAGE) => {
        const keys = Object.keys(storage);
        const values = Object.values(storage);
        if (storageType === SESSION_STORAGE) {
          for (let i = 0; i < keys.length; i++) {
            sessionStorage.setItem(keys[i], values[i]);
          }
        }
        if (storageType === LOCAL_STORAGE) {
          for (let i = 0; i < keys.length; i++) {
            localStorage.setItem(keys[i], values[i]);
          }
        }
      },
      storage,
      storageType,
      SESSION_STORAGE,
      LOCAL_STORAGE
    );
  }
Inject the given storage into the specified page storage.
Either localStorage or sessionStorage

@param {Page} page in which page the storage should be injected
@param {Object} storage the JSON object consisting of the storage keys and values
@param {string} storageType either localStorage or sessionStorage