chromium/content/test/data/workers/fetch_from_worker.html

<script>
const worker = new Worker(`fetch_from_worker.js`);

let resolve;
worker.onmessage = e => { resolve(e.data); };

function fetch_from_worker(url) {
  let p = new Promise(r => { resolve = r; });
  worker.postMessage({url});
  return p;
}
</script>