Bug 84628

Summary: "Not enough arguments" error should be TypeError
Product: WebKit Reporter: Kentaro Hara <haraken>
Component: WebCore JavaScriptAssignee: Kentaro Hara <haraken>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ap, darin, eric.carlson, feature-media-reviews, japhet, sam, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 84074    
Attachments:
Description Flags
Patch
none
Patch
darin: commit-queue-
test cases
none
patch for landing none

Description Kentaro Hara 2012-04-23 13:41:54 PDT
Currently, some custom bindings implement "Not enough arguments" error as SyntaxError. The Web IDL spec requires that it should be TypeError:
http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm
Comment 1 Kentaro Hara 2012-04-23 14:03:50 PDT
Created attachment 138422 [details]
Patch
Comment 2 Darin Adler 2012-04-23 15:22:15 PDT
Comment on attachment 138422 [details]
Patch

Test coverage is insufficient. There are 5 call sites in JS bindings modified, but only three test results changing. We need a test that covers each affected call site.
Comment 3 Kentaro Hara 2012-04-23 16:17:28 PDT
Created attachment 138451 [details]
Patch
Comment 4 Kentaro Hara 2012-04-23 16:18:05 PDT
(In reply to comment #2)
> (From update of attachment 138422 [details])
> Test coverage is insufficient. There are 5 call sites in JS bindings modified, but only three test results changing. We need a test that covers each affected call site.

darin: Thanks. Added test cases.
Comment 5 Kentaro Hara 2012-04-24 10:42:05 PDT
I believe that the current behavior is just due to mis-implementation of custom bindings, but let me confirm other browsers' behaviors.
Comment 6 Alexey Proskuryakov 2012-04-24 10:54:51 PDT
I'm not particularly concerned about this change, because we've been already raising an exception, and sites hardly ever check for specific exception type.

Checking other browsers is worth doing anyway.
Comment 7 Kentaro Hara 2012-04-24 11:21:39 PDT
Created attachment 138606 [details]
test cases
Comment 8 Kentaro Hara 2012-04-24 11:22:31 PDT
Opera 11.62:
WebSocket is not defined.
WebSocket is not defined.
XMLHttpRequest.open(): Error: WRONG_ARGUMENTS_ERR
SVGLength.convertToSpecifiedUnits(): Error: WRONG_ARGUMENTS_ERR

Firefox 11.0:
new WebSocket(): [Exception... "An invalid or illegal string was specified" code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)" location: "http://www.corp.google.com/~haraken/null/typeerror.html Line: 12"]
WebSocket.send(): [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://www.corp.google.com/~haraken/null/typeerror.html :: :: line 23" data: no]
XMLHttpRequest.open(): [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://www.corp.google.com/~haraken/null/typeerror.html :: :: line 34" data: no]
SVGLength.convertToSpecifiedUnits(): [Exception... "Not enough arguments [nsIDOMSVGLength.convertToSpecifiedUnits]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://www.corp.google.com/~haraken/null/typeerror.html :: :: line 46" data: no]
Comment 9 Kentaro Hara 2012-04-27 13:33:30 PDT
darin, ap: review?
Comment 10 Darin Adler 2012-04-27 18:24:15 PDT
Comment on attachment 138451 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=138451&action=review

> LayoutTests/ChangeLog:31
> +2012-04-23  Kentaro Hara  <haraken@chromium.org>
> +
> +
> +        * http/tests/websocket/tests/hixie76/send-empty-expected.txt:
> +        * http/tests/websocket/tests/hybi/send-empty-expected.txt:
> +        * svg/dom/SVGLength-expected.txt:

Extra stray change log here.
Comment 11 Kentaro Hara 2012-04-27 19:28:37 PDT
Created attachment 139324 [details]
patch for landing
Comment 12 WebKit Review Bot 2012-04-27 20:29:45 PDT
Comment on attachment 139324 [details]
patch for landing

Clearing flags on attachment: 139324

Committed r115533: <http://trac.webkit.org/changeset/115533>