-
jsbell@chromium.org authored
https://bugs.webkit.org/show_bug.cgi?id=96798 Reviewed by Kentaro Hara. Source/WebCore: Implement [EnforceRange] attribute for V8 bindings, which specifies throwing behavior on conversions outside int/uint 32/64 ranges and edge cases like NaNs and Infinities. Conversely, conversions without this attribute should *not* throw. Tests: fast/js/webidl-type-mapping.html: fast/dom/non-numeric-values-numeric-parameters.html fast/js/script-tests/select-options-add.html storage/indexeddb/intversion-bad-parameters.html * Modules/indexeddb/IDBCursor.cpp: Remove custom range enforcement for advance() * Modules/indexeddb/IDBCursor.h: Adjust type to match WebIDL. * Modules/indexeddb/IDBCursor.idl: Specify [EnforceRange] and type matches spec WebIDL. * Modules/indexeddb/IDBFactory.cpp: Remove custom range enforcement for open() * Modules/indexeddb/IDBFactory.h: Adjust type to match WebIDL. * Modules/indexeddb/IDBFactory.idl: Specify [EnforceRange] and type matches spec WebIDL. * bindings/scripts/CodeGeneratorJS.pm: (JSValueToNative): Add FIXME to support [EnforceRange] * bindings/scripts/CodeGeneratorV8.pm: (GenerateNormalAttrSetter): Handle [EnforceRange] in attribute setters (GenerateParametersCheck): Handle [EnforceRange] in parameters. (JSValueToNative): Pass EnforceRange to toInt() functions as appropriate. * bindings/scripts/IDLAttributes.txt: * bindings/scripts/test/TestObj.idl: Tests w/ [EnforceRange] * bindings/scripts/test/V8/V8TestObj.cpp: Updated expectations * bindings/scripts/test/V8/V8TestTypedefs.cpp: Updated expectations. * bindings/v8/V8Binding.cpp: Overloads for toInt() variants that handle constraints. (WebCore::toInt32): (WebCore::toUInt32): (WebCore::toInt64): (WebCore::toUInt64): * bindings/v8/V8Binding.h: Ditto, plus helpers for callers not expecting errors. (WebCore::toInt32): (WebCore::toUInt32): (WebCore::toInt64): (WebCore::toUInt64): * bindings/v8/V8BindingMacros.h: Helper macros for type conversions that may throw. * testing/TypeConversions.h: Added new members with EnforceRange constraint. * testing/TypeConversions.idl: Ditto. LayoutTests: Some of the tests for HTMLOptionsCollection.add() assumed it should throw for Infinities and NaNs, but this is not what the DOM+WebIDL specs say. (Firefox doesn't throw so this does not appear to be a web-compat issue.) This updates the tests/expectations so that V8 passes. JSC expectations are FAIL in a few places since it still incorrectly throws on Infinity/NaN -> int32 conversion (existing tests) and does not implement EnforceRange (new tests). Tne non-numeric-values-numeric-parameters test was also broken for NaN testing, reporting incorrect results which hid some of this behavior. * fast/dom/non-numeric-values-numeric-parameters-expected.txt: Failing behavior for JSC. * fast/dom/script-tests/non-numeric-values-numeric-parameters.js: HTMLOptionsCollection.add() should not throw on NaNs/Infinities. * fast/js/script-tests/select-options-add.js: Ditto. * fast/js/select-options-add-expected.txt: Failing behavior for JSC. * fast/js/webidl-type-mapping-expected.txt: Ditto. * fast/js/webidl-type-mapping.html: Added test cases for [EnforceRange] * platform/chromium/fast/dom/non-numeric-values-numeric-parameters-expected.txt: Added - passing behavior for V8. * platform/chromium/fast/js/select-options-add-expected.txt: Ditto. * platform/chromium/fast/js/webidl-type-mapping-expected.txt: Added. * storage/indexeddb/intversion-bad-parameters-expected.txt: Added non-finite test cases. * storage/indexeddb/resources/intversion-bad-parameters.js: Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
131803a3