Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Issue 38063003: Improve TypeError messages from failed array conversions. (Closed)

Created:
7 years, 2 months ago by sof
Modified:
7 years, 1 month ago
Reviewers:
Mike West
CC:
blink-reviews, Nils Barth (inactive), kojih, jsbell+bindings_chromium.org, abarth-chromium, marja+watch_chromium.org, adamk+blink_chromium.org, haraken, Nate Chapin, Inactive, jochen (gone - plz use gerrit), do-not-use
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Improve TypeError messages from failed array conversions. Should the conversion of a value into a native array fail due to it not having a sequence type, throw the expected TypeError but with a message that better explains what failed. Address this by extending the two v8 bindings helpers WebCore::toNativeArray() and WebCore::toRefPtrNativeArray() with an extra argument to indicate either the property name that's being converted to an array, or its argument index position (1-indexed.) (Or 0, if it is a setter with an array/sequence type.) In the case of toRefPtrNativeArray(), either a property name or an argument index might supplied; toNativeArray() only needs to support the argument indexed form. The code generator has been extended to supply the extra argument when calling upon these two array conversion helpers. So, if the array conversion fails due to the value not being array (or array-like), the TypeError's message is now generated by a pair of ExceptionMessages helper methods: static String notASequenceTypeArgumentOrValue(int argumentIndexOrValue); static String notASequenceTypeProperty(const String& propertyName); which handles the argument/setter value and property case, respectively. The output will be of the form {X} is not an array, nor does it have indexed properties. where X is one of "'{ThePropertyName}' property" "Value" "Argument {First,Second,Third,<N>th}" R= BUG=308730 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=160593

Patch Set 1 #

Total comments: 11

Patch Set 2 : Improve TypeError messages from failed array conversions. #

Total comments: 2

Patch Set 3 : Improve TypeError messages from failed array conversions. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+215 lines, -93 lines) Patch
M LayoutTests/crypto/generateKey-expected.txt View 1 chunk +2 lines, -2 lines 0 comments Download
M LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html View 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/fast/canvas/canvas-lineDash-input-sequence-expected.txt View 1 chunk +8 lines, -8 lines 0 comments Download
M LayoutTests/fast/events/constructors/message-event-constructor-expected.txt View 1 chunk +11 lines, -11 lines 0 comments Download
A LayoutTests/fast/events/init-message-event.html View 1 chunk +24 lines, -0 lines 0 comments Download
A LayoutTests/fast/events/init-message-event-expected.txt View 1 chunk +12 lines, -0 lines 0 comments Download
M Source/bindings/scripts/code_generator_v8.pm View 1 9 chunks +16 lines, -9 lines 0 comments Download
M Source/bindings/scripts/unstable/v8_types.py View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/bindings/tests/results/V8TestObject.cpp View 9 chunks +9 lines, -9 lines 0 comments Download
M Source/bindings/tests/results/V8TestObjectPython.cpp View 3 chunks +3 lines, -3 lines 0 comments Download
M Source/bindings/tests/results/V8TestTypedefs.cpp View 5 chunks +5 lines, -5 lines 0 comments Download
M Source/bindings/v8/Dictionary.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/v8/ExceptionMessages.h View 1 1 chunk +5 lines, -1 line 0 comments Download
M Source/bindings/v8/ExceptionMessages.cpp View 1 2 1 chunk +27 lines, -2 lines 0 comments Download
M Source/bindings/v8/V8Binding.h View 1 7 chunks +53 lines, -25 lines 0 comments Download
M Source/bindings/v8/V8Utilities.h View 1 1 chunk +3 lines, -1 line 0 comments Download
M Source/bindings/v8/V8Utilities.cpp View 1 3 chunks +20 lines, -4 lines 0 comments Download
M Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp View 1 1 chunk +3 lines, -2 lines 0 comments Download
M Source/bindings/v8/custom/V8MessageEventCustom.cpp View 1 1 chunk +3 lines, -2 lines 0 comments Download
M Source/bindings/v8/custom/V8MessagePortCustom.cpp View 1 1 chunk +3 lines, -2 lines 0 comments Download
M Source/bindings/v8/custom/V8WindowCustom.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/v8/custom/V8WorkerCustom.cpp View 1 1 chunk +3 lines, -2 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
sof
Following up on a suggestion made in review #30673002, embellishing other TypeErrors stemming from failed ...
7 years, 2 months ago (2013-10-23 22:18:29 UTC) #1
Mike West
Thank you for following up on this! I like better error messages! This CL is ...
7 years, 2 months ago (2013-10-24 07:08:54 UTC) #2
sof
https://codereview.chromium.org/38063003/diff/1/Source/bindings/scripts/code_generator_v8.pm File Source/bindings/scripts/code_generator_v8.pm (right): https://codereview.chromium.org/38063003/diff/1/Source/bindings/scripts/code_generator_v8.pm#newcode1911 Source/bindings/scripts/code_generator_v8.pm:1911: $code .= JSValueToNativeStatement($attribute->type, $attribute->extendedAttributes, 0, "jsValue", "cppValue", " ", ...
7 years, 1 month ago (2013-10-24 21:16:41 UTC) #3
Mike West
LGTM, thanks for going another round! https://codereview.chromium.org/38063003/diff/90001/Source/bindings/v8/ExceptionMessages.cpp File Source/bindings/v8/ExceptionMessages.cpp (right): https://codereview.chromium.org/38063003/diff/90001/Source/bindings/v8/ExceptionMessages.cpp#newcode78 Source/bindings/v8/ExceptionMessages.cpp:78: kind = "Value"; ...
7 years, 1 month ago (2013-10-25 07:15:12 UTC) #4
sof
https://codereview.chromium.org/38063003/diff/90001/Source/bindings/v8/ExceptionMessages.cpp File Source/bindings/v8/ExceptionMessages.cpp (right): https://codereview.chromium.org/38063003/diff/90001/Source/bindings/v8/ExceptionMessages.cpp#newcode78 Source/bindings/v8/ExceptionMessages.cpp:78: kind = "Value"; On 2013/10/25 07:15:13, Mike West wrote: ...
7 years, 1 month ago (2013-10-25 07:18:37 UTC) #5
Mike West
No worries. You don't need to wait for another review from me; just make that ...
7 years, 1 month ago (2013-10-25 07:23:52 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sigbjornf@opera.com/38063003/270001
7 years, 1 month ago (2013-10-25 15:38:04 UTC) #7
commit-bot: I haz the power
7 years, 1 month ago (2013-10-25 16:54:26 UTC) #8
Message was sent while issue was closed.
Change committed as 160593

Powered by Google App Engine
This is Rietveld 408576698