resolveWithTestChecks = function(urlStr, baseStr = undefined) {
  let packageThrow = null;
  let nativeThrow = null;
  let packageResolve;
  let nativeResolve;
  try {
    packageResolve = resolveUrl(urlStr, baseStr);
  } catch (e) {
    packageThrow = e;
  }
  if (COMPLIANT_BROWSER) {
    try {
      // Safari throws a TypeError if you call the constructor with a second
      // argument that isn't defined, so we can't pass baseStr all the time.
      nativeResolve = baseStr ? new URL(urlStr, baseStr) : new URL(urlStr);
    } catch (e) {
      nativeThrow = e;
    }

    // Did only one impl throw?
    if ((!packageThrow && nativeThrow) || (packageThrow && !nativeThrow)) {
      // Fail test case here
      raiseException(`parsing of (${urlStr}, ${
          baseStr}) caused mismatch between native and package tests:\npackage: ${
          packageThrow}\nnative throw: ${nativeThrow}`);
    }
    if (packageThrow) {
      throw packageThrow;
    }
    assertEquals(nativeResolve.protocol, packageResolve.protocol);
    assertEquals(nativeResolve.username, packageResolve.username);
    assertEquals(nativeResolve.password, packageResolve.password);
    assertEquals(nativeResolve.hostname, packageResolve.hostname);
    assertEquals(nativeResolve.host, packageResolve.host);
    assertEquals(nativeResolve.origin, packageResolve.origin);
    assertEquals(nativeResolve.port, packageResolve.port);
    assertEquals(nativeResolve.pathname, packageResolve.pathname);
    assertEquals(nativeResolve.search, packageResolve.search);
    assertEquals(nativeResolve.hash, packageResolve.hash);
    assertEquals(nativeResolve.href, packageResolve.href);
    assertEquals(nativeResolve.toString(), packageResolve.toString());
  }
  if (packageThrow) {
    throw packageThrow;
  }
  return packageResolve;
}
This is a wrapper around the resolveUrl call from the URL package that will
check the native implementation against the package's implementation for all
known "COMPLIANT BROWSERS" (defined above).
If the native parsing and package parsing disagree (e.g. there is some
mismatch between the returned data, or only one implementation throws an
error), then the test is automatically failed.
For browsers not in the "COMPLIANT BROWSER" definition, this simply wraps the
package function with no additional expectations.
@param {string} urlStr
@param {string=} baseStr
@return {!UrlLike}