Skip to content

Commit

Permalink
wpt: add FormData wpts
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored and ronag committed Oct 22, 2022
1 parent 3f9d694 commit 8ee8f01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/fetch/formdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class FormData {
static name = 'FormData'

constructor (form) {
if (arguments.length > 0 && form != null) {
if (form !== undefined) {
webidl.errors.conversionFailed({
prefix: 'FormData constructor',
argument: 'Argument 1',
types: ['null']
types: ['undefined']
})
}

Expand Down Expand Up @@ -297,9 +297,15 @@ function makeEntry (name, value, filename) {
// 2. If filename is given, then set value to a new File object,
// representing the same bytes, whose name attribute is filename.
if (filename !== undefined) {
/** @type {FilePropertyBag} */
const options = {
type: value.type,
lastModified: value.lastModified
}

value = value instanceof File
? new File([value], filename, { type: value.type })
: new FileLike(value, filename, { type: value.type })
? new File([value], filename, options)
: new FileLike(value, filename, options)
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"test:tap": "tap test/*.js test/diagnostics-channel/*.js",
"test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w",
"test:typescript": "tsd",
"test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs)",
"test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs)",
"coverage": "nyc --reporter=text --reporter=html npm run test",
"coverage:ci": "nyc --reporter=lcov npm run test",
"bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
Expand Down

0 comments on commit 8ee8f01

Please sign in to comment.