chromium/third_party/blink/web_tests/http/tests/cachestorage/detached-context.html

<!DOCTYPE html>
<meta charset=utf-8>
<title>Cache Storage: Verify Cache Storage on detached context</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../serviceworker/resources/test-helpers.js"></script>
<style>iframe { display: none; }</style>
<body>
Something
<script>
var frame_url = "resources/self-detach-iframe.html";
promise_test(function(t) {
  return new Promise(function(resolve, reject) {
      var f = with_iframe(frame_url);
      return resolve(f);
    }).then(function(frame) {
      frame.contentWindow.postMessage('go', '*');
      // Listen to reply from iframe.
      var listener = new Promise(function(resolve, reject) {
        window.onmessage = t.step_func(function(e) {
          resolve(e.data);
        });
      });
      // Since iframe doesn't receive response from Cache API, we limit the wait to 2 seconds.
      var timeout = new Promise(resolve => {
         setTimeout(function() {
           resolve({status: 'timeout doc', keys: []});
         }, 2000);
      });
      return Promise.race([listener, timeout]);
     })
     .then(function(data) {
       assert_equals(data.keys.length, 0, 'Keys return empty from the cache since nothing is cached.');
       assert_equals(data.status, 'timeout doc', 'Currently detached iframe doesn\'t receive the reply.');
     });
});
</script>
</body>