function keepaliveCorsBasicTest(desc, origin) {
  const url = `${origin}${dirname(location.pathname)}${RESOURCES_DIR}top.txt`;
  const urlAllowCors = `${url}?pipe=header(Access-Control-Allow-Origin,*)`;

  promise_test((test) => {
    return fetch(urlAllowCors, {keepalive: true, 'mode': 'no-cors'})
        .then((resp) => {
          assert_equals(resp.status, 0, 'Opaque filter: status is 0');
          assert_equals(resp.statusText, '', 'Opaque filter: statusText is ""');
          assert_equals(
              resp.type, 'opaque', 'Opaque filter: response\'s type is opaque');
          return resp.text().then((value) => {
            assert_equals(
                value, '', 'Opaque response should have an empty body');
          });
        });
  }, `${desc} [no-cors mode]`);

  promise_test((test) => {
    return promise_rejects_js(
        test, TypeError, fetch(url, {keepalive: true, 'mode': 'cors'}));
  }, `${desc} [cors mode, server forbid CORS]`);

  promise_test((test) => {
    return fetch(urlAllowCors, {keepalive: true, 'mode': 'cors'})
        .then((resp) => {
          assert_equals(resp.status, 200, 'Fetch\'s response\'s status is 200');
          assert_equals(resp.type, 'cors', 'CORS response\'s type is cors');
        });
  }, `${desc} [cors mode]`);
}
Tests to cover the basic behaviors of keepalive + cors/no-cors mode requests
to different `origin` when the initiator document is still alive. They should
behave the same as without setting keepalive.