summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/xhr-iframe.html
blob: 4c57bbbc6589d9738924b0acb91b440efc141622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<meta charset="utf-8">
<title>iframe for xhr tests</title>
<script>
async function xhr(url, options) {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    const opts = options ? options : {};
    xhr.onload = () => {
      resolve(xhr);
    };
    xhr.onerror = () => {
      reject('xhr failed');
    };

    xhr.open('GET', url);
    if (opts.responseType) {
      xhr.responseType = opts.responseType;
    }
    xhr.send();
  });
}
</script>