summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/orb/tentative/nosniff.sub.any.js
blob: 3df9d22e0b7beb0b6f25dde7d9e3d8f9cd1ebfd6 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// META: script=/fetch/orb/resources/utils.js

const path = "http://{{domains[www1]}}:{{ports[http][0]}}/fetch/orb/resources";

promise_test(
  t =>
    promise_rejects_js(
      t,
      TypeError,
      fetchORB(
        `${path}/text.txt`,
        null,
        contentType("text/plain"),
        contentTypeOptions("nosniff")
      )
    ),
  "ORB should block opaque text/plain with nosniff"
);

promise_test(
  t =>
    promise_rejects_js(
      t,
      TypeError,
      fetchORB(
        `${path}/data.json`,
        null,
        contentType("application/json"),
        contentTypeOptions("nosniff")
      )
    ),
  "ORB should block opaque-response-blocklisted MIME type with nosniff"
);

promise_test(
  t =>
    promise_rejects_js(
      t,
      TypeError,
      fetchORB(
        `${path}/data.json`,
        null,
        contentType(""),
        contentTypeOptions("nosniff")
      )
    ),
  "ORB should block opaque response with empty Content-Type and nosniff"
);

promise_test(
  () =>
    fetchORB(
      `${path}/image.png`,
      null,
      contentType(""),
      contentTypeOptions("nosniff")
    ),
  "ORB shouldn't block opaque image with empty Content-Type and nosniff"
);