summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/respond-with-body-accessed-response-iframe.html
blob: 7be3148794990088e60a7b61f533a7ea39cfce41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script>
var callback;

// Creates a <script> element with |url| source, and returns a promise for the
// result of the executed script. Uses JSONP because some responses to |url|
// are opaque so their body cannot be tested directly.
function getJSONP(url) {
  var sc = document.createElement('script');
  sc.src = url;
  var promise = new Promise(function(resolve, reject) {
      // This callback function is called by appending a script element.
      callback = resolve;
      sc.addEventListener(
          'error',
          function() { reject('Failed to load url:' + url); });
    });
  document.body.appendChild(sc);
  return promise;
}
</script>