Bug 170674

Summary: File API constructor filename ignored
Product: WebKit Reporter: Dániel Stein <daniel.stein>
Component: JavaScriptCoreAssignee: 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
Reported 2017-04-10 06:00:22 PDT
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
Radar WebKit Bug Importer
Comment 1 2017-04-10 07:17:15 PDT
ebrommers
Comment 2 2018-05-23 14:06:29 PDT
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
Comment 3 2018-05-23 16:32:50 PDT
(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
Comment 4 2018-05-23 16:36:02 PDT
> (new File(["Something wrong here"], "myFileName", {type: "text/plain"})).name < "myFileName" Seems to work fine here on Safari Tech Preview.
Chris Dumez
Comment 5 2018-05-23 16:37:58 PDT
(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
Comment 6 2018-05-24 06:50:31 PDT
> (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
Comment 7 2018-05-24 07:01:15 PDT
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
Comment 8 2018-05-24 07:17:57 PDT
(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
Comment 9 2018-05-24 08:33:26 PDT
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
Comment 10 2023-08-23 01:10:48 PDT
Seems like this is INVALID per above comments.
ebrommers
Comment 11 2023-08-23 07:30:17 PDT
(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!
Note You need to log in before you can comment on or make changes to this bug.