text-plain.window.js (3884B)
1 // META: script=enctypes-helper.js 2 3 const formTest = formSubmissionTemplate("text/plain"); 4 5 formTest({ 6 name: "basic", 7 value: "test", 8 expected: "basic=test\r\n", 9 description: "Basic test", 10 }); 11 12 formTest({ 13 name: "basic", 14 value: new File([], "file-test.txt"), 15 expected: "basic=file-test.txt\r\n", 16 description: "Basic File test", 17 }); 18 19 formTest({ 20 name: "a\0b", 21 value: "c", 22 expected: "a\0b=c\r\n", 23 description: "0x00 in name", 24 }); 25 26 formTest({ 27 name: "a", 28 value: "b\0c", 29 expected: "a=b\0c\r\n", 30 description: "0x00 in value", 31 }); 32 33 formTest({ 34 name: "a", 35 value: new File([], "b\0c"), 36 expected: "a=b\0c\r\n", 37 description: "0x00 in filename", 38 }); 39 40 formTest({ 41 name: "a\nb", 42 value: "c", 43 expected: "a\r\nb=c\r\n", 44 description: "\\n in name", 45 }); 46 47 formTest({ 48 name: "a\rb", 49 value: "c", 50 expected: "a\r\nb=c\r\n", 51 description: "\\r in name", 52 }); 53 54 formTest({ 55 name: "a\r\nb", 56 value: "c", 57 expected: "a\r\nb=c\r\n", 58 description: "\\r\\n in name", 59 }); 60 61 formTest({ 62 name: "a\n\rb", 63 value: "c", 64 expected: "a\r\n\r\nb=c\r\n", 65 description: "\\n\\r in name", 66 }); 67 68 formTest({ 69 name: "a", 70 value: "b\nc", 71 expected: "a=b\r\nc\r\n", 72 description: "\\n in value", 73 }); 74 75 formTest({ 76 name: "a", 77 value: "b\rc", 78 expected: "a=b\r\nc\r\n", 79 description: "\\r in value", 80 }); 81 82 formTest({ 83 name: "a", 84 value: "b\r\nc", 85 expected: "a=b\r\nc\r\n", 86 description: "\\r\\n in value", 87 }); 88 89 formTest({ 90 name: "a", 91 value: "b\n\rc", 92 expected: "a=b\r\n\r\nc\r\n", 93 description: "\\n\\r in value", 94 }); 95 96 formTest({ 97 name: "a", 98 value: new File([], "b\nc"), 99 expected: "a=b\r\nc\r\n", 100 description: "\\n in filename", 101 }); 102 103 formTest({ 104 name: "a", 105 value: new File([], "b\rc"), 106 expected: "a=b\r\nc\r\n", 107 description: "\\r in filename", 108 }); 109 110 formTest({ 111 name: "a", 112 value: new File([], "b\r\nc"), 113 expected: "a=b\r\nc\r\n", 114 description: "\\r\\n in filename", 115 }); 116 117 formTest({ 118 name: "a", 119 value: new File([], "b\n\rc"), 120 expected: "a=b\r\n\r\nc\r\n", 121 description: "\\n\\r in filename", 122 }); 123 124 formTest({ 125 name: 'a"b', 126 value: "c", 127 expected: 'a"b=c\r\n', 128 description: "double quote in name", 129 }); 130 131 formTest({ 132 name: "a", 133 value: 'b"c', 134 expected: 'a=b"c\r\n', 135 description: "double quote in value", 136 }); 137 138 formTest({ 139 name: "a", 140 value: new File([], 'b"c'), 141 expected: 'a=b"c\r\n', 142 description: "double quote in filename", 143 }); 144 145 formTest({ 146 name: "a'b", 147 value: "c", 148 expected: "a'b=c\r\n", 149 description: "single quote in name", 150 }); 151 152 formTest({ 153 name: "a", 154 value: "b'c", 155 expected: "a=b'c\r\n", 156 description: "single quote in value", 157 }); 158 159 formTest({ 160 name: "a", 161 value: new File([], "b'c"), 162 expected: "a=b'c\r\n", 163 description: "single quote in filename", 164 }); 165 166 formTest({ 167 name: "a\\b", 168 value: "c", 169 expected: "a\\b=c\r\n", 170 description: "backslash in name", 171 }); 172 173 formTest({ 174 name: "a", 175 value: "b\\c", 176 expected: "a=b\\c\r\n", 177 description: "backslash in value", 178 }); 179 180 formTest({ 181 name: "a", 182 value: new File([], "b\\c"), 183 expected: "a=b\\c\r\n", 184 description: "backslash in filename", 185 }); 186 187 formTest({ 188 name: "áb", 189 value: "ç", 190 expected: "\xC3\xA1b=\xC3\xA7\r\n", 191 description: "non-ASCII in name and value", 192 }); 193 194 formTest({ 195 name: "a", 196 value: new File([], "ə.txt"), 197 expected: "a=\xC9\x99.txt\r\n", 198 description: "non-ASCII in filename", 199 }); 200 201 formTest({ 202 name: "aəb", 203 value: "c\uFFFDd", 204 formEncoding: "windows-1252", 205 expected: "aəb=c�d\r\n", 206 description: "characters not in encoding in name and value", 207 }); 208 209 formTest({ 210 name: "á", 211 value: new File([], "💩"), 212 formEncoding: "windows-1252", 213 expected: "\xE1=💩\r\n", 214 description: "character not in encoding in filename", 215 }); 216 217 formTest({ 218 name: "\uD800", 219 value: "\uD800", 220 formEncoding: "windows-1252", 221 expected: "�=�\r\n", 222 description: "lone surrogate in name and value", 223 });