summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/form-submission-0/FormDataEvent.window.js
blob: 4890fd862394bd08c47f60ba95cf020467a1909f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-formdataevent-interface

test(() => {
  let fd = new FormData();
  assert_throws_js(TypeError, () => { FormDataEvent('', {formData:fd}) }, "Calling FormDataEvent constructor without 'new' must throw");
  assert_throws_js(TypeError, () => { new FormDataEvent() }, '0 arguments');
  assert_throws_js(TypeError, () => { new FormDataEvent('foo') }, '1 argument');
  assert_throws_js(TypeError, () => { new FormDataEvent(fd, fd) }, '2 invalid arguments');
  assert_throws_js(TypeError, () => { new FormDataEvent('foo', null) }, 'Null dictionary');
  assert_throws_js(TypeError, () => { new FormDataEvent('foo', undefined) }, 'Undefined dictionary');
  assert_throws_js(TypeError, () => { new FormDataEvent('foo', { formData: null }) }, 'Null formData');
  assert_throws_js(TypeError, () => { new FormDataEvent('foo', { formData: undefined }) }, 'Undefined formData');
  assert_throws_js(TypeError, () => { new FormDataEvent('foo', { formData: 'bar' }) }, 'Wrong type of formData');
}, 'Failing FormDataEvent constructor');

test(() => {
  let fd = new FormData();
  let event = new FormDataEvent('bar', { formData: fd, bubbles: true });
  assert_equals(event.formData, fd);
  assert_true(event.bubbles);
}, 'Successful FormDataEvent constructor');