https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 829648dee8a4ea94b40c75e1b270b8ed9611bbd3 authored by Liam Quin on 25 June 2018, 19:13:57 UTC
Update META.yml
Tip revision: 829648d
constructing-form-data-set.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set">
<link ref="help" href="https://xhr.spec.whatwg.org/#dom-formdata">
<link rel="help" href="https://fetch.spec.whatwg.org/#concept-bodyinit-extract">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>

<iframe name="frame1"></iframe>
<form accept-charset="iso-8859-1" target="frame1" action="/common/blank.html">
<input type="hidden" name="_charset_">
</form>

<script>
test(() => {
  let formData = new FormData(document.querySelector('form'));
  assert_equals(formData.get('_charset_'), 'UTF-8');
}, 'FormData constructor always produces UTF-8 _charset_ value.');

let t = async_test('_charset_ control sets the expected encoding name.');
t.step(() => {
  let iframe = document.querySelector('iframe');
  iframe.onload = t.step_func_done(() => {
    assert_not_equals(iframe.contentDocument.URL.indexOf('_charset_=windows-1252'), -1);
  });
  document.querySelector('form').submit();
});
</script>
</body>
back to top