Bug 170674
Summary: | File API constructor filename ignored | ||
---|---|---|---|
Product: | WebKit | Reporter: | Dániel Stein <daniel.stein> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | achristensen, adam, aestes, annevk, ap, beidson, cdumez, ebrommers, joepeck, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 10 | ||
Hardware: | Unspecified | ||
OS: | iOS 10 |
Dániel Stein
Trying to download a file with a given filename from a blob. Opening a webpage containing the following script shows a file download screen with "Unknown" as the filename instead of the parameter.
```
window.location = URL.createObjectURL(new File(["content"], "filename.txt", {type: "application/octet-stream", lastModified: new Date()}));
```
OS: iOS 10.3.2
Device: iPad mini 3
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/31531994>
ebrommers
Related issue, so I'll add it here instead of creating a new issue.
When you create a File object using a string value (iOS 11.3), that value ends up populating the name property instead of the name passed in.
```
var myFile = new File(["Something wrong here"], "myFileName", {type: "text/plain"});
```
looking at myFile.name in the debugger gives an array value with "Something wrong here" as element[0]; the value for "myFileName" ends up in another attribute "localURL".
ebrommers
(In reply to ebrommers from comment #2)
> Related issue, so I'll add it here instead of creating a new issue.
>
> When you create a File object using a string value (iOS 11.3), that value
> ends up populating the name property instead of the name passed in.
>
>
> ```
> var myFile = new File(["Something wrong here"], "myFileName", {type:
> "text/plain"});
> ```
>
> looking at myFile.name in the debugger gives an array value with "Something
> wrong here" as element[0]; the value for "myFileName" ends up in another
> attribute "localURL".
Update: it looks like passing in a blob instead of a string value does the same thing. Somewhere File.name is getting assigned the value of the first parameter in the constructor (which should be the contents of the file, if I'm reading the spec correctly).
Chris Dumez
> (new File(["Something wrong here"], "myFileName", {type: "text/plain"})).name
< "myFileName"
Seems to work fine here on Safari Tech Preview.
Chris Dumez
(In reply to Chris Dumez from comment #4)
> > (new File(["Something wrong here"], "myFileName", {type: "text/plain"})).name
> < "myFileName"
>
> Seems to work fine here on Safari Tech Preview.
Also works for me on iOS.
ebrommers
> (new File(["Something wrong here"], "myFileName", {type: "text/plain"})).name
< ["Something wrong here"] (1)
iOS 11.3 (15E217) / running on iPhone SE in simulator -- if that makes a difference.
ebrommers
Ooh, interesting -- Plain-ol' Safari on my MacBook Pro (Version 11.1 (13605.1.33.1.4)) returns the correct value.
So... Xcode emulation or iOS Safari weirdness?
Chris Dumez
(In reply to ebrommers from comment #7)
> Ooh, interesting -- Plain-ol' Safari on my MacBook Pro (Version 11.1
> (13605.1.33.1.4)) returns the correct value.
>
> So... Xcode emulation or iOS Safari
I tried both MacOS and iOS device. I did not try iOS simulator. Any behavior difference would be unexpected though.
ebrommers
Thanks, Chris.
Poking around a little further, it looks like this behavior is due to an older JS runtime (I'm developing a Cordova app, and this is in the default UIWebView rather than in the WKWebView). So... probably best to leave this in the "just in case someone else in Cordova-land gets stuck" pile.
Anne van Kesteren
Seems like this is INVALID per above comments.
ebrommers
(In reply to Anne van Kesteren from comment #10)
> Seems like this is INVALID per above comments.
Sounds good. Cordova-based apps now use WKWebView, so this issue no longer applies. Thanks for following up!