async function loadFetchLaterIframe(origin, {
  targetUrl = undefined,
  uuid = undefined,
  activateAfter = undefined,
  referrer = undefined,
  method = undefined,
  bodyType = undefined,
  bodySize = undefined,
  allowDeferredFetch = false,
  expect = undefined
} = {}) {
  if (uuid && targetUrl && !targetUrl.includes(uuid)) {
    throw new Error(`Conflicted uuid=${
        uuid} is provided: must also be included in the targetUrl ${
        targetUrl}`);
  }
  if (!uuid) {
    uuid = targetUrl ? undefined : token();
  }
  targetUrl = targetUrl || generateSetBeaconURL(uuid);
  const params = new URLSearchParams(Object.assign(
      {},
      {url: encodeURIComponent(targetUrl)},
      activateAfter !== undefined ? {activateAfter} : null,
      referrer !== undefined ? {referrer} : null,
      method !== undefined ? {method} : null,
      bodyType !== undefined ? {bodyType} : null,
      bodySize !== undefined ? {bodySize} : null,
      ));
  const url =
      `${origin}/fetch/fetch-later/resources/fetch-later.html?${params}`;
  expect =
      expect || new FetchLaterIframeExpectation(FetchLaterExpectationType.DONE);

  const iframe = document.createElement('iframe');
  if (allowDeferredFetch) {
    iframe.allow = 'deferred-fetch';
  }
  iframe.src = url;

  const messageReceived = new Promise((resolve, reject) => {
    addEventListener('message', function handler(e) {
      if (e.source !== iframe.contentWindow) {
        return;
      }
      try {
        if (expect.run(e, url)) {
          removeEventListener('message', handler);
          resolve(e.data.type);
        }
      } catch (err) {
        reject(err);
      }
    });
  });

  await loadElement(iframe);
  const messageType = await messageReceived;
  if (messageType === FetchLaterIframeMessageType.DONE && uuid) {
    await expectBeacon(uuid, {count: 1});
  }

  return iframe;
}
A helper to load an iframe of the specified `origin` that makes a fetchLater
request to `targetUrl`.

If `targetUrl` is not provided, this function generates a target URL by
itself.

If `expect` is not provided:
- If `targetUrl` is not provided, this function will wait for the fetchLater
  request being received by the test server before returning.
- If `targetUrl` is provided and `uuid` is missing, it will NOT wait for the
  request.
- If both `targetUrl` and `uuid` are provided, it will wait for the request.

Note that the iframe posts various messages back to its parent document.

@param {!string} origin The origin URL of the iframe to load.
@param {FetchLaterIframeOptions=} nameIgnored
@return {!HTMLIFrameElement} the loaded iframe.