Bug 44202 - Implement strict type checking in js bindings for WebGL functions
Summary: Implement strict type checking in js bindings for WebGL functions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Zhenyao Mo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-18 13:53 PDT by Zhenyao Mo
Modified: 2010-08-19 11:59 PDT (History)
4 users (show)

See Also:


Attachments
patch (77.38 KB, patch)
2010-08-18 14:21 PDT, Zhenyao Mo
no flags Details | Formatted Diff | Diff
revised patch: responding to kbr's review (76.44 KB, patch)
2010-08-18 20:02 PDT, Zhenyao Mo
zmo: commit-queue-
Details | Formatted Diff | Diff
revised patch: tiny fix (76.07 KB, patch)
2010-08-18 20:05 PDT, Zhenyao Mo
zmo: commit-queue-
Details | Formatted Diff | Diff
revised patch: fixing the error in the comment (76.06 KB, patch)
2010-08-19 10:41 PDT, Zhenyao Mo
kbr: review+
zmo: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenyao Mo 2010-08-18 13:53:47 PDT
An exception will be thrown in case of type mismatch for Wrapper types and DomString, the same behavior as for overloaded functions.
Comment 1 Zhenyao Mo 2010-08-18 14:21:59 PDT
Created attachment 64769 [details]
patch

Tested both in Safari and Chromium.
Comment 2 Zhenyao Mo 2010-08-18 14:25:00 PDT
Forget to mention: all the current demos run fine after this change.  The test has been added in khronos already and was copied over using kbr's script.
Comment 3 Kenneth Russell 2010-08-18 17:51:41 PDT
Comment on attachment 64769 [details]
patch

Good work overall. A few minor issues.

WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp:171
 +          setDOMException(exec, TYPE_MISMATCH_ERR);
In the JSC custom bindings and in CodeGeneratorJS.pm I think you should use "return throwVMTypeError(exec)", which is used for the overloaded method handling's fall-through case. The code generator is used to generate bindings to objects which aren't strictly part of the DOM (like the TypedArrays, for example), so I think it is more appropriate to throw an exception that is not DOM-specific.


WebCore/bindings/scripts/CodeGeneratorJS.pm:1967
 +                              # an TYPE_MISMATCH_ERR is thrown instead of casting to null.
See above about using throwVMTypeError instead.


WebCore/bindings/scripts/CodeGeneratorV8.pm:1249
 +              # an TYPE_MISMATCH_ERR is thrown instead of casting to null.
I think this should use V8Proxy::throwTypeError to match the behavior of the overloaded function generation.


WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:231
 +          return throwError(TYPE_MISMATCH_ERR);
I think the V8 custom bindings should use V8Proxy::throwTypeError per above.
Comment 4 Zhenyao Mo 2010-08-18 20:02:56 PDT
Created attachment 64804 [details]
revised patch: responding to kbr's review

Changed from TYPE_MIS_MATCH to TypeError.

Again, tested in Safari and Chromium.
Comment 5 Zhenyao Mo 2010-08-18 20:05:22 PDT
Created attachment 64805 [details]
revised patch: tiny fix

remove a change in shader file that shouldn't be in this patch
Comment 6 Andreas Kling 2010-08-18 20:19:57 PDT
Comment on attachment 64805 [details]
revised patch: tiny fix

>WebCore/bindings/scripts/CodeGeneratorV8.pm:1249
> +              # an TYPE_MISMATCH_ERR is thrown instead of casting to null.
Incorrect comment. It throws TypeError, not TYPE_MISMATCH_ERR.
Comment 7 Zhenyao Mo 2010-08-19 10:41:53 PDT
Created attachment 64871 [details]
revised patch: fixing the error in the comment
Comment 8 Kenneth Russell 2010-08-19 11:38:25 PDT
Comment on attachment 64871 [details]
revised patch: fixing the error in the comment

Looks fine. Minor grammatical comments, not strictly necessary to fix.

WebCore/bindings/scripts/CodeGeneratorJS.pm:1967
 +                              # an TypeError is thrown instead of casting to null.
an -> a

WebCore/bindings/scripts/CodeGeneratorV8.pm:1249
 +              # an TypeError is thrown instead of casting to null.
an -> a
Comment 9 Zhenyao Mo 2010-08-19 11:50:17 PDT
(In reply to comment #8)
> (From update of attachment 64871 [details])
> Looks fine. Minor grammatical comments, not strictly necessary to fix.
> 
> WebCore/bindings/scripts/CodeGeneratorJS.pm:1967
>  +                              # an TypeError is thrown instead of casting to null.
> an -> a
> 
> WebCore/bindings/scripts/CodeGeneratorV8.pm:1249
>  +              # an TypeError is thrown instead of casting to null.
> an -> a

I'll fix it on the landing patch.
Comment 10 Zhenyao Mo 2010-08-19 11:59:44 PDT
Committed r65689: <http://trac.webkit.org/changeset/65689>