function keepaliveRedirectTest(desc, {
  origin1 = '',
  origin2 = '',
  withPreflight = false,
  unloadIframe = false,
  expectFetchSucceed = true,
} = {}) {
  desc = `[keepalive][iframe][load] ${desc}` +
      (unloadIframe ? ' [unload at end]' : '');
  promise_test(async (test) => {
    const tokenToStash = token();
    const iframe = document.createElement('iframe');
    iframe.src = getKeepAliveAndRedirectIframeUrl(
        tokenToStash, origin1, origin2, withPreflight);
    document.body.appendChild(iframe);
    await iframeLoaded(iframe);
    assert_equals(await getTokenFromMessage(), tokenToStash);
    if (unloadIframe) {
      iframe.remove();
    }

    assertStashedTokenAsync(
        desc, tokenToStash, {expectTokenExist: expectFetchSucceed});
  }, `${desc}; setting up`);
}
In an iframe, and in `load` event handler, test to fetch a keepalive URL that
involves in redirect to another URL.

`unloadIframe` to unload the iframe before verifying stashed token to
simulate the situation that unloads after fetching. Note that this test is
different from `keepaliveRedirectInUnloadTest()` in that the latter
performs fetch() call directly in `unload` event handler, while this test
does it in `load`.