Changeset 186275 in webkit
- Timestamp:
- Jul 3, 2015 8:56:16 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r186266 r186275 1 2015-07-03 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION (r178097): HTMLSelectElement.add(option, undefined) prepends option to the list of options; should append to the end of the list of options 4 https://bugs.webkit.org/show_bug.cgi?id=146566 5 <rdar://problem/21663919> 6 7 Reviewed by Ryosuke Niwa. 8 9 * fast/dom/HTMLSelectElement/add-expected.txt: 10 * fast/dom/HTMLSelectElement/add.html: 11 * fast/dom/HTMLSelectElement/options-collection-add-expected.txt: 12 * fast/dom/HTMLSelectElement/options-collection-add.html: 13 Update tests so that calling add(X, undefined) is expected to append X, 14 not prepend it. 15 16 * http/tests/websocket/tests/hybi/undefined-protocol-expected.txt: Added. 17 * http/tests/websocket/tests/hybi/undefined-protocol.html: Added. 18 Add test coverage for "new WebSocket(url, undefined)" as WebSocket is 19 using constructor overloads with optional parameters. Previously, calling 20 new WebSocket(url, undefined) was equivalent to calling 21 new WebSocket(url, "undefined") even though it is supposed to be 22 equivalent to calling new WebSocket(url). 23 1 24 2015-07-03 Chris Dumez <cdumez@apple.com> 2 25 -
trunk/LayoutTests/fast/dom/HTMLSelectElement/add-expected.txt
r186265 r186275 36 36 PASS testAdd(createOption("Y21"), "foo") is "Y21,0,1,2" 37 37 PASS testAdd(createOption("Y22"), NaN) is "Y22,0,1,2" 38 PASS testAdd(createOption("Y23"), undefined) is " Y23,0,1,2"38 PASS testAdd(createOption("Y23"), undefined) is "0,1,2,Y23" 39 39 PASS testAdd(createOption("Y24"), -2) is "0,1,2,Y24" 40 40 PASS testAdd(createOption("X"), mySelect.options[0]) is "X,0,1,2" -
trunk/LayoutTests/fast/dom/HTMLSelectElement/add.html
r186265 r186275 50 50 shouldBeEqualToString('testAdd(createOption("Y21"), "foo")', "Y21,0,1,2"); 51 51 shouldBeEqualToString('testAdd(createOption("Y22"), NaN)', "Y22,0,1,2"); 52 shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', " Y23,0,1,2");52 shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "0,1,2,Y23"); 53 53 shouldBeEqualToString('testAdd(createOption("Y24"), -2)', "0,1,2,Y24"); 54 54 shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[0])', "X,0,1,2"); -
trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add-expected.txt
r186265 r186275 46 46 PASS testAdd(createOption("Y21"), "foo") is "Y21,0,1,2" 47 47 PASS testAdd(createOption("Y22"), NaN) is "Y22,0,1,2" 48 PASS testAdd(createOption("Y23"), undefined) is " Y23,0,1,2"48 PASS testAdd(createOption("Y23"), undefined) is "0,1,2,Y23" 49 49 PASS testAdd(createOption("Y24"), -2) is "0,1,2,Y24" 50 50 PASS testAdd(createOption("X"), mySelect.options[0]) is "X,0,1,2" -
trunk/LayoutTests/fast/dom/HTMLSelectElement/options-collection-add.html
r186265 r186275 70 70 shouldBeEqualToString('testAdd(createOption("Y21"), "foo")', "Y21,0,1,2"); 71 71 shouldBeEqualToString('testAdd(createOption("Y22"), NaN)', "Y22,0,1,2"); 72 shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', " Y23,0,1,2");72 shouldBeEqualToString('testAdd(createOption("Y23"), undefined)', "0,1,2,Y23"); 73 73 shouldBeEqualToString('testAdd(createOption("Y24"), -2)', "0,1,2,Y24"); 74 74 shouldBeEqualToString('testAdd(createOption("X"), mySelect.options[0])', "X,0,1,2"); -
trunk/Source/WebCore/ChangeLog
r186272 r186275 1 2015-07-03 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION (r178097): HTMLSelectElement.add(option, undefined) prepends option to the list of options; should append to the end of the list of options 4 https://bugs.webkit.org/show_bug.cgi?id=146566 5 <rdar://problem/21663919> 6 7 Reviewed by Ryosuke Niwa. 8 9 HTMLSelectElement.add(X, undefined) is supposed to be equivalent to 10 HTMLSelectElement.add(X) which should *append* X. The same is true 11 for HTMLOptionsCollection.add(X, undefined). 12 13 However, due to a bug in our bindings generator for overloaded 14 operations, the actual behavior was not the expected one. The 15 second overload would be chosen: add(X, index) and undefined would 16 be converted as 0-index, which would *prepend* X. 17 18 This patch fixes the bindings generator so that undefined is allowed 19 for optional parameters of an overload operation, when doing the 20 overload resolution. 21 22 Tests: 23 - fast/dom/HTMLSelectElement/add.html 24 - fast/dom/HTMLSelectElement/options-collection-add.html 25 - http/tests/websocket/tests/hybi/undefined-protocol.html 26 27 * bindings/scripts/CodeGeneratorJS.pm: 28 (GenerateParametersCheckExpression): 29 Allow undefined value for optional parameters when doing the overload 30 resolution. 31 32 * bindings/scripts/test/JS/JSTestObj.cpp: 33 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod): 34 (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1): 35 (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2): 36 (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter): 37 * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: 38 (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors): 39 * bindings/scripts/test/TestObj.idl: 40 Add bindings tests coverage and rebaseline. 41 1 42 2015-07-03 Dan Bernstein <mitz@apple.com> 2 43 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r186265 r186275 1384 1384 push(@andExpression, "(${value}.isNull() || ${value}.isFunction())"); 1385 1385 $usedArguments{$parameterIndex} = 1; 1386 } elsif ($codeGenerator->GetArrayType($type) || $codeGenerator->GetSequenceType($type)) { 1387 # FIXME: Add proper support for T[], T[]?, sequence<T> 1388 if ($parameter->isNullable) { 1389 push(@andExpression, "(${value}.isNull() || (${value}.isObject() && isJSArray(${value})))"); 1386 } elsif (!IsNativeType($type)) { 1387 my $condition = ""; 1388 $condition .= "${value}.isUndefined() || " if $parameter->isOptional; 1389 1390 # FIXME: WebIDL says that undefined is also acceptable for nullable parameters and 1391 # should be converted to null: 1392 # http://heycam.github.io/webidl/#es-nullable-type 1393 $condition .= "${value}.isNull() || " if $parameter->isNullable; 1394 1395 if ($codeGenerator->GetArrayType($type) || $codeGenerator->GetSequenceType($type)) { 1396 # FIXME: Add proper support for T[], T[]?, sequence<T>. 1397 $condition .= "(${value}.isObject() && isJSArray(${value}))"; 1390 1398 } else { 1391 push(@andExpression, "(${value}.isObject() && isJSArray(${value}))"); 1392 } 1393 $usedArguments{$parameterIndex} = 1; 1394 } elsif (!IsNativeType($type)) { 1395 if ($parameter->isNullable) { 1396 push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(JS${type}::info())))"); 1397 } else { 1398 push(@andExpression, "(${value}.isObject() && asObject(${value})->inherits(JS${type}::info()))"); 1399 } 1399 $condition .= "(${value}.isObject() && asObject(${value})->inherits(JS${type}::info()))"; 1400 } 1401 push(@andExpression, "(" . $condition . ")"); 1400 1402 $usedArguments{$parameterIndex} = 1; 1401 1403 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r186265 r186275 130 130 #endif 131 131 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*); 132 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter(JSC::ExecState*); 132 133 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*); 133 134 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*); … … 634 635 #endif 635 636 { "overloadedMethod", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t) (2) }, 637 { "overloadedMethodWithOptionalParameter", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter), (intptr_t) (1) }, 636 638 { "classMethodWithClamp", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t) (2) }, 637 639 { "methodWithUnsignedLongSequence", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence), (intptr_t) (1) }, … … 3956 3958 if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && isJSArray(arg0))))) 3957 3959 return jsTestObjPrototypeFunctionOverloadedMethod7(exec); 3958 if ((argsCount == 1 && ( arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))))3960 if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))))) 3959 3961 return jsTestObjPrototypeFunctionOverloadedMethod8(exec); 3960 if ((argsCount == 1 && ( arg0.isObject() && isJSArray(arg0))))3962 if ((argsCount == 1 && ((arg0.isObject() && isJSArray(arg0))))) 3961 3963 return jsTestObjPrototypeFunctionOverloadedMethod9(exec); 3962 if ((argsCount == 1 && ( arg0.isObject() && isJSArray(arg0))))3964 if ((argsCount == 1 && ((arg0.isObject() && isJSArray(arg0))))) 3963 3965 return jsTestObjPrototypeFunctionOverloadedMethod10(exec); 3964 3966 if (argsCount == 1) … … 3966 3968 if () 3967 3969 return jsTestObjPrototypeFunctionOverloadedMethod12(exec); 3970 if (argsCount < 1) 3971 return throwVMError(exec, createNotEnoughArgumentsError(exec)); 3972 return throwVMTypeError(exec); 3973 } 3974 3975 static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(ExecState* exec) 3976 { 3977 JSValue thisValue = exec->thisValue(); 3978 JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue); 3979 if (UNLIKELY(!castedThis)) 3980 return throwThisTypeError(*exec, "TestObj", "overloadedMethodWithOptionalParameter"); 3981 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 3982 auto& impl = castedThis->impl(); 3983 if (UNLIKELY(exec->argumentCount() < 1)) 3984 return throwVMError(exec, createNotEnoughArgumentsError(exec)); 3985 TestObj* objArg1 = JSTestObj::toWrapped(exec->argument(0)); 3986 if (UNLIKELY(exec->hadException())) 3987 return JSValue::encode(jsUndefined()); 3988 3989 size_t argsCount = exec->argumentCount(); 3990 if (argsCount <= 1) { 3991 impl.overloadedMethodWithOptionalParameter(objArg1); 3992 return JSValue::encode(jsUndefined()); 3993 } 3994 3995 TestObj* objArg2 = JSTestObj::toWrapped(exec->argument(1)); 3996 if (UNLIKELY(exec->hadException())) 3997 return JSValue::encode(jsUndefined()); 3998 impl.overloadedMethodWithOptionalParameter(objArg1, objArg2); 3999 return JSValue::encode(jsUndefined()); 4000 } 4001 4002 static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(ExecState* exec) 4003 { 4004 JSValue thisValue = exec->thisValue(); 4005 JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue); 4006 if (UNLIKELY(!castedThis)) 4007 return throwThisTypeError(*exec, "TestObj", "overloadedMethodWithOptionalParameter"); 4008 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 4009 auto& impl = castedThis->impl(); 4010 if (UNLIKELY(exec->argumentCount() < 1)) 4011 return throwVMError(exec, createNotEnoughArgumentsError(exec)); 4012 TestObj* objArg = JSTestObj::toWrapped(exec->argument(0)); 4013 if (UNLIKELY(exec->hadException())) 4014 return JSValue::encode(jsUndefined()); 4015 4016 size_t argsCount = exec->argumentCount(); 4017 if (argsCount <= 1) { 4018 impl.overloadedMethodWithOptionalParameter(objArg); 4019 return JSValue::encode(jsUndefined()); 4020 } 4021 4022 int longArg = toInt32(exec, exec->argument(1), NormalConversion); 4023 if (UNLIKELY(exec->hadException())) 4024 return JSValue::encode(jsUndefined()); 4025 impl.overloadedMethodWithOptionalParameter(objArg, longArg); 4026 return JSValue::encode(jsUndefined()); 4027 } 4028 4029 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter(ExecState* exec) 4030 { 4031 size_t argsCount = std::min<size_t>(2, exec->argumentCount()); 4032 JSValue arg0(exec->argument(0)); 4033 JSValue arg1(exec->argument(1)); 4034 if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))) && (arg1.isUndefined() || arg1.isNull() || (arg1.isObject() && asObject(arg1)->inherits(JSTestObj::info()))))) 4035 return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(exec); 4036 if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))))) 4037 return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(exec); 3968 4038 if (argsCount < 1) 3969 4039 return throwVMError(exec, createNotEnoughArgumentsError(exec)); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
r186265 r186275 153 153 size_t argsCount = std::min<size_t>(1, exec->argumentCount()); 154 154 JSValue arg0(exec->argument(0)); 155 if ((argsCount == 1 && ( arg0.isObject() && asObject(arg0)->inherits(JSArrayBuffer::info()))))155 if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSArrayBuffer::info()))))) 156 156 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(exec); 157 if ((argsCount == 1 && ( arg0.isObject() && asObject(arg0)->inherits(JSArrayBufferView::info()))))157 if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSArrayBufferView::info()))))) 158 158 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(exec); 159 if ((argsCount == 1 && ( arg0.isObject() && asObject(arg0)->inherits(JSBlob::info()))))159 if ((argsCount == 1 && ((arg0.isObject() && asObject(arg0)->inherits(JSBlob::info()))))) 160 160 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3(exec); 161 161 if (argsCount == 1) -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r186265 r186275 191 191 // FIXME: Implement support for overloaded functions with variadic arguments. 192 192 void overloadedMethod(Blob... blobArgs); 193 194 void overloadedMethodWithOptionalParameter(TestObj? objArg1, optional TestObj? objArg2); 195 void overloadedMethodWithOptionalParameter(TestObj? objArg, optional long longArg); 193 196 #endif 194 197
Note: See TracChangeset
for help on using the changeset viewer.