summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/resources/access-control-sandboxed-iframe.html
blob: 7e47275b6ce5204e304b30566667d9751f3dcfb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html>
  <body>
  <script type="text/javascript">
window.addEventListener("message", (evt) => {
  const url = evt.data;
  const xhr = new XMLHttpRequest;

  xhr.open("GET", url, false);

  try {
    xhr.send();
  } catch(e) {
    parent.postMessage("Exception thrown. Sandboxed iframe XHR access was denied in 'send'.", "*");
    return;
  }

  parent.postMessage(xhr.responseText, "*");
}, false);

parent.postMessage("ready", "*");
  </script>
  </body>
</html>