Bug 1508576 [wpt PR 14140] - FormData: Fix a crash by passing null or non-HTMLFormElement instances to a FormData constructor, a=testonly
authorKent Tamura <tkent@chromium.org>
Thu, 22 Nov 2018 10:34:30 +0000
changeset 504351 02868188c96f86cde78d1242b7cb15d888d42ad7
parent 504350 c46b59962f2e00e7f1d5e3957c4186e9b056888c
child 504352 a10a77ee35afb76664e632f7847f8b295e2db241
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1508576, 14140, 609210, 906649, 1343414, 609614
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/web-platform/tests/xhr/formdata.htm
--- a/testing/web-platform/tests/xhr/formdata.htm
+++ b/testing/web-platform/tests/xhr/formdata.htm
@@ -1,12 +1,12 @@
 <!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]" />
     <link rel="help" href="https://xhr.spec.whatwg.org/#dom-formdata" data-tested-assertations=".. following::P[1]" />
     <link rel="help" href="https://xhr.spec.whatwg.org/#dom-formdata-append" data-tested-assertations=".. following::UL[1]/LI[1] following::UL[1]/LI[2] following::UL[1]/LI[3]" />
     <link rel="help" href="https://xhr.spec.whatwg.org/#dom-XMLHttpRequest-send-FormData" data-tested-assertations="following::DD[1]" />
 <div id="log"></div>
 <form id="form">
@@ -30,14 +30,19 @@
   function create_formdata () {
     var fd = new FormData();
     for (var i = 0; i < arguments.length; i++) {
       fd.append.apply(fd, arguments[i]);
     };
     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,');
   do_test("formdata from form", new FormData(document.getElementById('form')), 'key=value,\n');
 
 </script>