summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/fetch/orb/tentative/known-mime-type.sub.any.js
blob: b0521e8b363dcb1129618414311b0eb6fbb66c84 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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}/font.ttf`, null, contentType("font/ttf"))
    ),
  "ORB should block opaque font/ttf"
);

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

promise_test(
  t =>
    promise_rejects_js(
      t,
      TypeError,
      fetchORB(`${path}/data.json`, null, contentType("application/json"))
    ),
  "ORB should block opaque application/json (non-empty)"
);

promise_test(
  t =>
    promise_rejects_js(
      t,
      TypeError,
      fetchORB(`${path}/empty.json`, null, contentType("application/json"))
    ),
  "ORB should block opaque application/json (empty)"
);

promise_test(
  t =>
    promise_rejects_js(
      t,
      TypeError,
      fetchORB(`${path}/data_non_ascii.json`, null, contentType("application/json"))
    ),
  "ORB should block opaque application/json which contains non ascii characters"
);

promise_test(async () => {
  fetchORB(`${path}/image.png`, null, contentType("image/png"));
}, "ORB shouldn't block opaque image/png");

promise_test(async () => {
  await fetchORB(`${path}/script.js`, null, contentType("text/javascript"));
}, "ORB shouldn't block opaque text/javascript");

// Test javascript validation can correctly decode the content with BOM.
promise_test(async () => {
  await fetchORB(`${path}/script-utf16-bom.js`, null, contentType("application/json"));
}, "ORB shouldn't block opaque text/javascript (utf16 encoded with BOM)");

// Test javascript validation can correctly decode the content with the http charset hint.
promise_test(async () => {
  await fetchORB(`${path}/script-utf16-without-bom.js`, null, contentType("application/json; charset=utf-16"));
}, "ORB shouldn't block opaque text/javascript (utf16 encoded without BOM but charset is provided in content-type)");

// Test javascript validation can correctly decode the content for iso-8559-1 (fallback decoder in Firefox).
promise_test(async () => {
  await fetchORB(`${path}/script-iso-8559-1.js`, null, contentType("application/json"));
}, "ORB shouldn't block opaque text/javascript (iso-8559-1 encoded)");

// Test javascript validation can correctly parse asm.js.
promise_test(async () => {
  await fetchORB(`${path}/script-asm-js-valid.js`, null, contentType("application/json"));
}, "ORB shouldn't block text/javascript with valid asm.js");

// Test javascript validation can correctly parse invalid asm.js with valid JS syntax.
promise_test(async () => {
  await fetchORB(`${path}/script-asm-js-invalid.js`, null, contentType("application/json"));
}, "ORB shouldn't block text/javascript with invalid asm.js");