function getSubresourceOrigin(originType) {
  const httpProtocol = "http";
  const httpsProtocol = "https";
  const wsProtocol = "ws";
  const wssProtocol = "wss";

  const sameOriginHost = "{{host}}";
  const crossOriginHost = "{{domains[www1]}}";

  // These values can evaluate to either empty strings or a ":port" string.
  const httpPort = getNormalizedPort(parseInt("{{ports[http][0]}}", 10));
  const httpsRawPort = parseInt("{{ports[https][0]}}", 10);
  const httpsPort = getNormalizedPort(httpsRawPort);
  const wsPort = getNormalizedPort(parseInt("{{ports[ws][0]}}", 10));
  const wssRawPort = parseInt("{{ports[wss][0]}}", 10);
  const wssPort = getNormalizedPort(wssRawPort);

  /**
    @typedef OriginType
    @type {string}

    Represents the origin of the subresource request URL.
    The keys of `originMap` below are the valid values.

    Note that there can be redirects from the specified origin
    (see RedirectionType), and thus the origin of the subresource
    response URL might be different from what is specified by OriginType.
  */
  const originMap = {
    "same-https": httpsProtocol + "://" + sameOriginHost + httpsPort,
    "same-http": httpProtocol + "://" + sameOriginHost + httpPort,
    "cross-https": httpsProtocol + "://" + crossOriginHost + httpsPort,
    "cross-http": httpProtocol + "://" + crossOriginHost + httpPort,
    "same-wss": wssProtocol + "://" + sameOriginHost + wssPort,
    "same-ws": wsProtocol + "://" + sameOriginHost + wsPort,
    "cross-wss": wssProtocol + "://" + crossOriginHost + wssPort,
    "cross-ws": wsProtocol + "://" + crossOriginHost + wsPort,

    // The following origin types are used for upgrade-insecure-requests tests:
    // These rely on some unintuitive cleverness due to WPT's test setup:
    // 'Upgrade-Insecure-Requests' does not upgrade the port number,
    // so we use URLs in the form `http://[domain]:[https-port]`,
    // which will be upgraded to `https://[domain]:[https-port]`.
    // If the upgrade fails, the load will fail, as we don't serve HTTP over
    // the secure port.
    "same-http-downgrade":
        httpProtocol + "://" + sameOriginHost + ":" + httpsRawPort,
    "cross-http-downgrade":
        httpProtocol + "://" + crossOriginHost + ":" + httpsRawPort,
    "same-ws-downgrade":
        wsProtocol + "://" + sameOriginHost + ":" + wssRawPort,
    "cross-ws-downgrade":
        wsProtocol + "://" + crossOriginHost + ":" + wssRawPort,
  };

  return originMap[originType];
}
Construct subresource (and related) origin.

  @param {string} originType
  @returns {object} the origin of the subresource.