Skip to content

Commit

Permalink
FormData: Fix a crash by passing null or non-HTMLFormElement instance…
Browse files Browse the repository at this point in the history
…s to a FormData constructor

Add back nullptr check to FormData::Create(HTMLFormElement*).

This CL fixes a regression caused by crrev.com/609210.
According to standards, |new FormData(nullptr)| and |new
FormData("string")| should throw TypeErrors. However this CL applies the
behavior before crrev.com/609210.

Bug: 906649
Change-Id: I78aa53559592ef0e14cc941175dc9f1b44342bb0
Reviewed-on: https://chromium-review.googlesource.com/c/1343414
Reviewed-by: Yoshifumi Inoue <[email protected]>
Commit-Queue: Kent Tamura <[email protected]>
Cr-Commit-Position: refs/heads/master@{#609614}
  • Loading branch information
tkent-google authored and chromium-wpt-export-bot committed Nov 20, 2018
1 parent c0afacb commit 3e5c53c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xhr/formdata.htm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html lang=en>
<meta charset=utf-8>
<title>XMLHttpRequest: upload formdata</title>
<title>XMLHttpRequest: Construct and upload FormData</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://xhr.spec.whatwg.org/#interface-formdata" data-tested-assertations="following::P[1]" />
Expand Down Expand Up @@ -35,6 +35,11 @@
return fd;
}

test(() => {
assert_throws(new TypeError(), () => { new FormData(null); });
assert_throws(new TypeError(), () => { new FormData("string"); });
}, "Constructors");

do_test("empty formdata", new FormData(), '\n');
do_test("formdata with string", create_formdata(['key', 'value']), 'key=value,\n');
do_test("formdata with named string", create_formdata(['key', new Blob(['value'], {type: 'text/plain'}), 'kv.txt']), '\nkey=kv.txt:text/plain:5,');
Expand Down

0 comments on commit 3e5c53c

Please sign in to comment.