summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/content-type/multipart.window.js
blob: 03b037a0e621cf72b9425625e7957ec6659a93ce (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
// META: title=Ensure capital letters can be used in the boundary value.
setup({ single_test: true });
(async () => {
  const form_string =
    "--Boundary_with_capital_letters\r\n" +
    "Content-Type: application/json\r\n" +
    'Content-Disposition: form-data; name="does_this_work"\r\n' +
    "\r\n" +
    'YES\r\n' +
    "--Boundary_with_capital_letters--\r\n";

  const r = new Response(new Blob([form_string]), {
    headers: [
      [
        "Content-Type",
        "multipart/form-data; boundary=Boundary_with_capital_letters",
      ],
    ],
  });

  var s = "";
  try {
    const fd = await r.formData();
    for (const [key, value] of fd.entries()) {
      s += (`${key} = ${value}`);
    }
  } catch (ex) {
    s = ex;
  }

  assert_equals(s, "does_this_work = YES");
  done();
})();