[Webkit-unassigned] [Bug 49218] New: WebIDL conversions from string to number and array to number should not generate TypeError

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Nov 8 16:00:28 PST 2010


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

           Summary: WebIDL conversions from string to number and array to
                    number should not generate TypeError
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: gman at google.com
                CC: kbr at google.com


If I you have a WebIDL function defined like this

    void stencilMask(long mask);

According the the WebIDL spec, values passed as the "mask" argument are converted to a number by the spec defined in ECMAScript ToNumber in section 9.

http://www.ecma-international.org/publications/standards/Ecma-262.htm

That spec appears to say that strings are converted to numbers by calling ToNumber on the string which returns a number or NaN and in the case of an integral type, NaN is converted to 0.

That means gl.stencilMask("123") should be the same as gl.stencilMask(123) and gl.stencilMask("bar") should be the same as gl.stencilMask(0);

For objects it says first toString is called on the object, then that string is passed toNumber. Since an array is a type of object that means means that gl.stencilMask([123]) is the same as gl.stencilMask(123);

All of these cases are currently returning TypeError in WebKit.

Please read the WebIDL spec and ECMAScript spec to verify
http://www.w3.org/TR/WebIDL/

Section 4.1.7 says long calls ToInt32
Section 4 says ToInt32 is defined in the EMCAScript spec.
ECMAScript spec
Section 9.5 says ToInt32 calls ToNumber
Seciton 9.3 says ToNumber calls ToString on strings and ToNumber(ToPrimitve()) on objects.
Section 9.1 says ToPrimitive uses the DefaultValue for objects
Section 8.12.8 says default value is derived by calling toString() on the object.

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



More information about the webkit-unassigned mailing list