Bug 1508576 [wpt PR 14140] - FormData: Fix a crash by passing null or non-HTMLFormElement instances to a FormData constructor, a=testonly

Automatic update from web-platform-testsFormData: Fix a crash by passing null or non-HTMLFormElement instances 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 <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609614}

--

wpt-commits: 3e5c53caa5517b2940f0e49441021cac78a84042
wpt-pr: 14140
This commit is contained in:
Kent Tamura 2018-11-22 10:34:30 +00:00 committed by moz-wptsync-bot
parent a7f7f006b4
commit 65fe01fee6

View File

@ -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]" />
@ -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,');