chromium/third_party/blink/web_tests/http/tests/devtools/service-workers/resources/service-workers-bypass-for-network-cors-iframe.html

<script>
function xhr(url) {
  return new Promise((resolve, reject) => {
      let request = new XMLHttpRequest();
      request.addEventListener('error',() => { reject(new Error()); });
      request.addEventListener('load', (e) => { resolve(request.response); });
      request.open('GET', url);
      request.send();
    });
}

function load_cors_image(url) {
  return new Promise(function(resolve, reject) {
      let img = document.createElement('img');
      document.body.appendChild(img);
      img.onload = () => { resolve(); };
      img.onerror = () => { reject(new Error()); };
      img.crossOrigin = 'anonymous';
      img.src = url;
    });
}
</script>