chromium/third_party/blink/web_tests/http/tests/serviceworker/resources/fetch-request-with-gc.js

function wait(delay) {
  return new Promise(resolve => setTimeout(resolve, delay));
}

self.addEventListener('fetch', e => {
    self.gc();
    e.respondWith(wait(10).then(() => {
        self.gc();
        return fetch(e.request);
      }));
  });