Skip to content

#202 - added Javascript constructor for File - #203

Closed
twendelmuth wants to merge 2 commits into
HtmlUnit:masterfrom
twendelmuth:issue_202
Closed

twendelmuth wants to merge 2 commits into
HtmlUnit:masterfrom
twendelmuth:issue_202

Conversation

@twendelmuth

Copy link
Copy Markdown
Contributor

@twendelmuth

Copy link
Copy Markdown
Contributor Author

getFile() seems to be still a problem.
From the call hierachy:

  • Formdata.append uses is. Seems null safe.
  • Formdata.set - seems null safe.
  • URL.createObjectURL uses is - not null safe
  • FileReader.readAsArrayBuffer/readAsDataURL/readAsText - not null safe

}

@JsxConstructor({CHROME, FF, FF68})
public File(NativeArray bytes, String name, NativeObject options) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there is a more appropiate Class for the potential options here. Optional didn't work.

this.lastModified = Long.parseLong(secondsSince1970);
} else {
this.lastModified = System.currentTimeMillis() / 1000;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy with the whole options thing here ... happy to listen to improvements.


@Test
@Alerts({"myfilename", "", "true", "0"})
@NotYetImplemented(IE)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one errors right now but is ignored. It still logs some errors though. Is there an easy way to not even run those tests without having to add a FileTest.properties?

}
}

File(final String pathname) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it might be a better read / easier to understand to have this in a subclass and move the whole java.io.File dependency there.
The option question then would still remain what we'd do with getFile() and how an abstract version of this should look like.
Right now I'm not saving the byte array since it's not really used.

@rbri

rbri commented Aug 8, 2020

Copy link
Copy Markdown
Member

Hi Thorsten,
again many thanks for your contribution, was a great help. Have implemented this now and have hopefully supported your case. As usual i will inform via twitter about new snapshots.

@rbri rbri closed this Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants