function testOriginAfterRedirection(
    desc, method, fromUrl, toUrl, statusCode, expectedOrigin) {
  desc = `[${method}] Redirect ${statusCode} ${desc}`;
  const token1 = token();
  const url = `${fromUrl}?token=${token1}&max_age=0` +
      `&redirect_status=${statusCode}` +
      `&location=${encodeURIComponent(toUrl)}`;

  const requestInit = {method, 'mode': 'cors', 'redirect': 'follow'};

  promise_test(function(test) {
    return fetch(`${RESOURCES_DIR}clean-stash.py?token=${token1}`)
        .then((cleanResponse) => {
          assert_equals(
              cleanResponse.status, 200,
              `Clean stash response's status is 200`);
          return fetch(url, requestInit).then((redirectResponse) => {
            assert_equals(
                redirectResponse.status, 200,
                `Inspect header response's status is 200`);
            assert_equals(
                redirectResponse.headers.get('x-request-origin'),
                expectedOrigin, 'Check origin header');
          });
        });
  }, desc);
}
Fetches `fromUrl` with 'cors' and 'follow' modes that returns response to
redirect to `toUrl`.