summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/orb/tentative/known-mime-type.sub.any.js
blob: cc6d208fd3fbac3164d82e3d467b7ca347f158ca (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
87
88
89
90
91
92
93
94
95
96
97
98
99
// META: script=/fetch/orb/resources/utils.js

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

expected_block(
  `${path}/font.ttf`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("font/ttf")),
      message("ORB should block opaque font/ttf")));

expected_block(
  `${path}/text.txt`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("text/plain")),
      message("ORB should block opaque text/plain")));

expected_block(
  `${path}/data.json`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json")),
      message("ORB should block opaque application/json (non-empty)")));

expected_block(
  `${path}/empty.json`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json")),
      message("ORB should block opaque application/json (empty)")));

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

expected_allow(
  `${path}/image.png`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("image/png")),
      message("ORB shouldn't block opaque image/png")),
  { skip: ["audio", "video", "script"] });

expected_allow(
  `${path}/script.js`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("text/javascript")),
      message("ORB shouldn't block opaque text/javascript")),
  { skip: ["image", "audio", "video"] });

// Test javascript validation can correctly decode the content with BOM.
expected_allow(
  `${path}/script-utf16-bom.js`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json")),
      message("ORB shouldn't block opaque text/javascript (utf16 encoded with BOM)")),
  { skip: ["image", "audio", "video"] });

// Test javascript validation can correctly decode the content with the http charset hint.
expected_allow(
  `${path}/script-utf16-without-bom.js`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json; charset=utf-16")),
      message("ORB shouldn't block opaque text/javascript (utf16 encoded without BOM but charset is provided in content-type)")),
  { skip: ["image", "audio", "video"] });

// Test javascript validation can correctly decode the content for iso-8559-1 (fallback decoder in Firefox).
expected_allow(
  `${path}/script-iso-8559-1.js`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json")),
      message("ORB shouldn't block opaque text/javascript (iso-8559-1 encoded)")),
  { skip: ["image", "audio", "video"] });

// Test javascript validation can correctly parse asm.js.
expected_allow(
  `${path}/script-asm-js-valid.js`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json")),
      message("ORB shouldn't block text/javascript with valid asm.js")),
  { skip: ["image", "audio", "video"] });

// Test javascript validation can correctly parse invalid asm.js with valid JS syntax.
expected_allow(
  `${path}/script-asm-js-invalid.js`,
  (orb_test, message) =>
    promise_test(
      t => orb_test(t, contentType("application/json")),
      message("ORB shouldn't block text/javascript with invalid asm.js")),
  { skip: ["image", "audio", "video"] });