RESOLVED CONFIGURATION CHANGED 84650
FormData.append() should throw TypeError for not enough arguments
https://bugs.webkit.org/show_bug.cgi?id=84650
Summary FormData.append() should throw TypeError for not enough arguments
Kentaro Hara
Reported 2012-04-23 16:45:05 PDT
FormData.append() should throw TypeError if the number of arguments is less than 2. The spec: http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-append()-method
Attachments
Patch (5.77 KB, patch)
2012-04-23 16:50 PDT, Kentaro Hara
no flags
Patch (5.63 KB, patch)
2012-04-24 10:01 PDT, Kentaro Hara
no flags
patch for landing (5.61 KB, patch)
2012-04-24 10:14 PDT, Kentaro Hara
no flags
test case (311 bytes, text/html)
2012-04-24 11:18 PDT, Kentaro Hara
no flags
rebased patch (5.61 KB, patch)
2012-04-30 11:03 PDT, Kentaro Hara
no flags
rebased patch (5.61 KB, patch)
2012-04-30 11:06 PDT, Kentaro Hara
no flags
rebased patch (5.64 KB, patch)
2012-05-22 03:52 PDT, Kentaro Hara
abarth: review+
rebased patch for landing (6.08 KB, patch)
2012-05-22 17:34 PDT, Kentaro Hara
no flags
Kentaro Hara
Comment 1 2012-04-23 16:50:13 PDT
Kentaro Hara
Comment 2 2012-04-24 09:51:29 PDT
jianli: review?
Jian Li
Comment 3 2012-04-24 09:57:05 PDT
Comment on attachment 138459 [details] Patch The test does not need anything related to setting http server, so it should put under fast/.
Kentaro Hara
Comment 4 2012-04-24 10:01:10 PDT
Kentaro Hara
Comment 5 2012-04-24 10:01:34 PDT
(In reply to comment #3) > (From update of attachment 138459 [details]) > The test does not need anything related to setting http server, so it should put under fast/. Done. Thanks.
Jian Li
Comment 6 2012-04-24 10:06:06 PDT
Comment on attachment 138586 [details] Patch Please make sure the test passes in both JSC and V8.
Kentaro Hara
Comment 7 2012-04-24 10:14:55 PDT
Created attachment 138590 [details] patch for landing
Alexey Proskuryakov
Comment 8 2012-04-24 10:35:59 PDT
Comment on attachment 138590 [details] patch for landing Wait, is spec compliance the only reason to make this change? Raising exceptions where we didn't use to do that is extremely dangerous for web compatibility, and shouldn't be treated lightly. Why do we have this behavior? What do other browsers do? Is there a specific reason why it's unlikely for WebKit specific content to rely on this quirk?
Kentaro Hara
Comment 9 2012-04-24 10:40:12 PDT
(In reply to comment #8) > (From update of attachment 138590 [details]) > Wait, is spec compliance the only reason to make this change? The spec compliance and the fact that almost all "not enough arguments" are throwing TypeError. At least, the current behavior that JSC does not throw any error but V8 throws SyntaxError is a bug. > Raising exceptions where we didn't use to do that is extremely dangerous for web compatibility, and shouldn't be treated lightly. Why do we have this behavior? What do other browsers do? Is there a specific reason why it's unlikely for WebKit specific content to rely on this quirk? Let me confirm other browsers' behavior. jianli: Was there any reason why you implemented SyntaxError in V8 and no error in JSC?
Kentaro Hara
Comment 10 2012-04-24 11:18:44 PDT
Created attachment 138604 [details] test case
Kentaro Hara
Comment 11 2012-04-24 11:20:33 PDT
Opera 11.62: FormData is not defined. Firefox 11.0: FormData.append(): [Exception... "Not enough arguments [nsIDOMFormData.append]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://www.corp.google.com/~haraken/null/typeerror.html :: :: line 12" data: no] I do not have IE now...
Hajime Morrita
Comment 12 2012-04-24 14:05:09 PDT
+1 for ap's comment as a basic standpoint. I think it's OK to change the error type thrown. But switching from non-throw to throw should be careful, especially for long standing APIs. Note that we sometimes selected non-standard behaviors for a compatibility reason in the past. I think this specific change is acceptable considering the Firefox behavior. It would be great if each differences is written down in the ChangeLog. It's a part of our accountability to webdev folks.
Jian Li
Comment 13 2012-04-24 17:30:58 PDT
(In reply to comment #12) > +1 for ap's comment as a basic standpoint. > I think it's OK to change the error type thrown. > But switching from non-throw to throw should be careful, especially for long standing APIs. > Note that we sometimes selected non-standard behaviors for a compatibility reason in the past. > > I think this specific change is acceptable considering the Firefox behavior. > It would be great if each differences is written down in the ChangeLog. > It's a part of our accountability to webdev folks. (In reply to comment #9) > (In reply to comment #8) > > (From update of attachment 138590 [details] [details]) > > Wait, is spec compliance the only reason to make this change? > > The spec compliance and the fact that almost all "not enough arguments" are throwing TypeError. At least, the current behavior that JSC does not throw any error but V8 throws SyntaxError is a bug. > > > Raising exceptions where we didn't use to do that is extremely dangerous for web compatibility, and shouldn't be treated lightly. Why do we have this behavior? What do other browsers do? Is there a specific reason why it's unlikely for WebKit specific content to rely on this quirk? > > Let me confirm other browsers' behavior. > > jianli: Was there any reason why you implemented SyntaxError in V8 and no error in JSC? Per the comment from Sam (https://bugs.webkit.org/show_bug.cgi?id=36024), I changed the JSC implementation to throw no error. We can keep the V8 change if JSC wants to stick with the current behavior for consistency.
Kentaro Hara
Comment 14 2012-04-24 17:55:06 PDT
I got the result of IE. IE 9: FormData is not defined.
Kentaro Hara
Comment 15 2012-04-24 17:57:36 PDT
(In reply to comment #13) > Per the comment from Sam (https://bugs.webkit.org/show_bug.cgi?id=36024), I changed the JSC implementation to throw no error. We can keep the V8 change if JSC wants to stick with the current behavior for consistency. Sam: do you have an opinion to change no error to TypeError? (Leaving aside the compatibility problem, ) the first argument and the second argument of FormData.append() are not optional in the spec: http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-append()-method
Kentaro Hara
Comment 16 2012-04-27 13:33:55 PDT
Sam: Do you have any concern to fix this bug?
Kentaro Hara
Comment 17 2012-04-30 11:03:54 PDT
Created attachment 139480 [details] rebased patch
Kentaro Hara
Comment 18 2012-04-30 11:06:18 PDT
Created attachment 139482 [details] rebased patch
Kentaro Hara
Comment 19 2012-05-22 03:52:25 PDT
Created attachment 143259 [details] rebased patch
Adam Barth
Comment 20 2012-05-22 10:01:16 PDT
Comment on attachment 143259 [details] rebased patch Since Sam wrote that comment in the other bug, we've changed our default behavior to throwing exception when web sites supply too few arguments. Given that we're already throwing in this case in V8 and Firefox throws, this patch seems relatively safe from a web compatibly point of view. You might want to give Sam a chance to comment before landing. (I would also add the information about what other browsers do to the ChangeLog in case we look into the history of this behavior later.)
Kentaro Hara
Comment 21 2012-05-22 17:34:32 PDT
Created attachment 143412 [details] rebased patch for landing
Kentaro Hara
Comment 22 2012-05-22 17:35:12 PDT
Sam: Any comment for landing the patch?
Kentaro Hara
Comment 23 2012-11-26 00:27:56 PST
*** Bug 103221 has been marked as a duplicate of this bug. ***
Kentaro Hara
Comment 24 2012-11-26 00:29:10 PST
Sam: Sorry for revoking the old discussion... any objection to landing this patch?
Sam Weinig
Comment 25 2012-11-26 11:42:29 PST
I'm disappointed that the behavior of WebKit changed to throw on too many arguments. Can you confirm that both JSC and V8 do that for all of WebKit now?
Chris Dumez
Comment 26 2012-11-26 11:46:27 PST
(In reply to comment #25) > I'm disappointed that the behavior of WebKit changed to throw on too many arguments. Can you confirm that both JSC and V8 do that for all of WebKit now? I don't understand. The patch makes it throw on too few arguments (not too many). For this method, WebKit will not throw if too many arguments are provided.
Sam Weinig
Comment 27 2012-11-26 11:49:27 PST
(In reply to comment #26) > (In reply to comment #25) > > I'm disappointed that the behavior of WebKit changed to throw on too many arguments. Can you confirm that both JSC and V8 do that for all of WebKit now? > > I don't understand. The patch makes it throw on too few arguments (not too many). For this method, WebKit will not throw if too many arguments are provided. Sorry, I meant too few.
Adam Barth
Comment 28 2012-11-26 12:14:48 PST
Sam, I'm very confused by your message. 1) This patch does not appear to have landed, so WebKit's behavior has not yet changed. 2) Can you explain why you would be disappointed if we landed this patch? Your comment above isn't very helpful because it just states your conclusion without letting us follow your reasoning.
Sam Weinig
Comment 29 2012-11-26 14:24:02 PST
(In reply to comment #28) > Sam, I'm very confused by your message. > > 1) This patch does not appear to have landed, so WebKit's behavior has not yet changed. > > 2) Can you explain why you would be disappointed if we landed this patch? Your comment above isn't very helpful because it just states your conclusion without letting us follow your reasoning. I apologize for not being clear. I was not disappointed that the patch was landed (as it hasn't) but rather that we had changed our behavior elsewhere to throw more often (something I don't think is a good idea as it is likely to break legacy content, for little gain). I was (am) trying to determine exactly what our current policy for throwing on incorrect number of arguments being provided, as I don't remember the specifics.
Adam Barth
Comment 30 2012-11-26 15:08:16 PST
> I was (am) trying to determine exactly what our current policy for throwing on incorrect number of arguments being provided, as I don't remember the specifics. Our current policy is that new APIs should throw when given too few arguments (as required by the specs) but that we shouldn't change existing APIs to throw if there is a risk of compatibility problems. The way we've done this is to make the code generator default to throwing when too few arguments are supplied and to mark the parameters for APIs where the arguments are optional with the [Optional] attribute.
Kentaro Hara
Comment 31 2012-11-26 15:39:37 PST
Sam: Thanks. As far as I checked a few months ago, FormData.append() was one of a few methods that don't throw TypeError. So we'd like to make the change for consistency if there is no compatibility concern. Given that Firefox and Chrome throw TypeError and that IE and Opera don't support FormData, it would make sense to throw TypeError in JSC.
Ahmad Saleem
Comment 32 2022-09-03 04:36:55 PDT
Updated results from all browsers: *** Safari Technology Preview 152 *** FormData.append(): TypeError: Not enough arguments *** Firefox Nightly 106 *** FormData.append(): TypeError: FormData.append: 0 is not a valid argument count for any overload. *** Chrome Canary 107 *** FormData.append(): TypeError: Failed to execute 'append' on 'FormData': 2 arguments required, but only 0 present. ________ Just wanted to share updated status. Is anything needed here because all of them are giving same error but in different details? Thanks!
Darin Adler
Comment 33 2022-09-03 07:23:20 PDT
That confirms that this is resolved. Likely many years ago.
Note You need to log in before you can comment on or make changes to this bug.