[Webkit-unassigned] [Bug 21257] JS bindings should throw when too few arguments are passed

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Oct 1 15:38:47 PDT 2008


https://bugs.webkit.org/show_bug.cgi?id=21257





------- Comment #2 from aa at chromium.org  2008-10-01 15:38 PDT -------
Sam and I talked at length about this at lunch today, but I wanted to repeat
here for the record...

(In reply to comment #1)
> I am not against this change in principle (matching other browsers makes
> sense), but I am curious if there are any known sites where our behavior breaks
> things.

It seems unlikely that there will be many sites broken by WebKit's current
behavior because:

a) It's rare and inadvisable to *rely* on exceptions being thrown
b) Other browsers throw exceptions in these cases, so in common code paths,
WebKit would get the correct argument counts

> The behavior we have matches that of how functions defined in the
> ECMAScript act, and how we perceive most JS developers think about JS functions
> (most don't check that arguments.length is the correct value). 

It's difficult to speak to how most JS developers expect things to work, I can
only talk about my experience with the code I've worked on. From what I've
seen, it's common for even moderately complex JS applications to carefully
check incoming arguments at component boundaries.

It's true that ECMAScript specs the built-in objects to not throw in the case
of obviously wrong arguments. This is really unfortunate and leads to really
strange behavior (setFullYear() will set the instance's date field to NaN if
passed zero arguments!).We can't do anything about ECMAScript built-ins because
that is how they are spec'd, and that is how Firefox works today (IE, otoh,
throws in these cases).

But in the case of all the other host-provided APIs, I think we should attempt
to be as strict as possible without breaking compatibility seriously. Luckily
the other major browsers are already strict in this way, so hopefully the
amount of breakage is small.

At the very least, I hope that we can make all *new* APIs strict.

> If we do make a
> change, we should discuss standardizing the behavior in the WebIDL
> specification, if that has not already been done. 

This seems like a very good idea.


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list