summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/access-control-basic-cors-safelisted-response-headers.htm
blob: fb58957f4b8a45c8777d8a542d5181e8c4b686e3 (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
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
  <head>
    <title>Tests that CORS-safelisted response headers are permitted in cross-origin request</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="/common/get-host-info.sub.js"></script>
  </head>
  <body>
    <script type="text/javascript">
    test(function() {
      const xhr = new XMLHttpRequest;

      xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN +
          "/xhr/resources/access-control-basic-cors-safelisted-response-headers.py", false);
      xhr.send();

      assert_not_equals(xhr.getResponseHeader("cache-control"), null);
      assert_not_equals(xhr.getResponseHeader("content-language"), null);
      assert_not_equals(xhr.getResponseHeader("content-type"), null);
      assert_not_equals(xhr.getResponseHeader("content-length"), null);
      assert_not_equals(xhr.getResponseHeader("expires"), null);
      assert_not_equals(xhr.getResponseHeader("last-modified"), null);
      assert_not_equals(xhr.getResponseHeader("pragma"), null);
      assert_equals(xhr.getResponseHeader("x-webkit"), null);

      assert_not_equals(xhr.getAllResponseHeaders().match("en"), null);
      assert_equals(xhr.getAllResponseHeaders().match("foobar"), null);
    }, "Response with CORS-safelisted headers");
    </script>
  </body>
</html>