Source/WebCore/ChangeLog

 12012-12-18 Tommy Widenflycht <tommyw@chromium.org>
 2
 3 [JSC] Add support for overloaded constructors
 4 https://bugs.webkit.org/show_bug.cgi?id=103226
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This patch adds the same support for overloaded constructors to JSC as V8.
 9 As proof of implementation soundness WebSockets custom constructor is removed.
 10
 11 Existing tests cover patch. As they should.
 12
 13 * GNUmakefile.list.am:
 14 * Modules/websockets/WebSocket.idl:
 15 * Target.pri:
 16 * UseJSC.cmake:
 17 * WebCore.vcproj/WebCore.vcproj:
 18 * WebCore.xcodeproj/project.pbxproj:
 19 * bindings/js/JSBindingsAllInOne.cpp:
 20 * bindings/js/JSWebSocketCustom.cpp: Removed.
 21 * bindings/scripts/CodeGeneratorJS.pm:
 22 (GenerateConstructorDeclaration):
 23 (GenerateConstructorDefinitions):
 24 (GenerateOverloadedConstructorDefinition):
 25 (GenerateConstructorDefinition):
 26 (GenerateConstructorHelperMethods):
 27 * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
 28 (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1):
 29 (WebCore):
 30 (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2):
 31 (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3):
 32 (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors4):
 33 (WebCore::JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors):
 34 * bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
 35 (JSTestOverloadedConstructorsConstructor):
 36
1372012-12-18 Nate Chapin <japhet@chromium.org>
238
339 REGRESSION (r137607): Cannot download files, stuck in “Preparing to download”

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
24062406 Source/WebCore/bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp \
24072407 Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp \
24082408 Source/WebCore/bindings/js/JSWebKitPointCustom.cpp \
2409  Source/WebCore/bindings/js/JSWebSocketCustom.cpp \
24102409 Source/WebCore/bindings/js/JSWorkerContextBase.cpp \
24112410 Source/WebCore/bindings/js/JSWorkerContextBase.h \
24122411 Source/WebCore/bindings/js/JSWorkerContextCustom.cpp \

Source/WebCore/Modules/websockets/WebSocket.idl

3939 CallWith=ScriptExecutionContext,
4040 EventTarget,
4141 JSNoStaticTables,
42  JSCustomConstructor,
4342 ConstructorParameters=1
4443] interface WebSocket {
4544 readonly attribute DOMString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.

Source/WebCore/Target.pri

@@enable?(WEB_SOCKETS) {
39193919 platform/network/SocketStreamHandleBase.cpp \
39203920 platform/network/qt/SocketStreamHandleQt.cpp
39213921
3922  SOURCES += \
3923  bindings/js/JSWebSocketCustom.cpp
3924 
39253922 enable?(WORKERS) {
39263923 HEADERS += \
39273924 Modules/websockets/WorkerThreadableWebSocketChannel.h

Source/WebCore/UseJSC.cmake

@@if (ENABLE_INDEXED_DATABASE)
206206 )
207207endif ()
208208
209 if (ENABLE_WEB_SOCKETS)
210  list(APPEND WebCore_SOURCES
211  bindings/js/JSWebSocketCustom.cpp
212  )
213 endif ()
214 
215209if (ENABLE_WORKERS)
216210 list(APPEND WebCore_SOURCES
217211 bindings/js/JSDedicatedWorkerContextCustom.cpp

Source/WebCore/WebCore.vcproj/WebCore.vcproj

7135671356 />
7135771357 </FileConfiguration>
7135871358 </File>
71359  <File
71360  RelativePath="..\bindings\js\JSWebSocketCustom.cpp"
71361  >
71362  <FileConfiguration
71363  Name="Debug|Win32"
71364  ExcludedFromBuild="true"
71365  >
71366  <Tool
71367  Name="VCCLCompilerTool"
71368  />
71369  </FileConfiguration>
71370  <FileConfiguration
71371  Name="Release|Win32"
71372  ExcludedFromBuild="true"
71373  >
71374  <Tool
71375  Name="VCCLCompilerTool"
71376  />
71377  </FileConfiguration>
71378  <FileConfiguration
71379  Name="Debug_Cairo_CFLite|Win32"
71380  ExcludedFromBuild="true"
71381  >
71382  <Tool
71383  Name="VCCLCompilerTool"
71384  />
71385  </FileConfiguration>
71386  <FileConfiguration
71387  Name="Release_Cairo_CFLite|Win32"
71388  ExcludedFromBuild="true"
71389  >
71390  <Tool
71391  Name="VCCLCompilerTool"
71392  />
71393  </FileConfiguration>
71394  <FileConfiguration
71395  Name="Debug_All|Win32"
71396  ExcludedFromBuild="true"
71397  >
71398  <Tool
71399  Name="VCCLCompilerTool"
71400  />
71401  </FileConfiguration>
71402  <FileConfiguration
71403  Name="Production|Win32"
71404  ExcludedFromBuild="true"
71405  >
71406  <Tool
71407  Name="VCCLCompilerTool"
71408  />
71409  </FileConfiguration>
71410  </File>
71411  <File
 71359 <File
7141271360 RelativePath="..\bindings\js\JSWorkerContextBase.cpp"
7141371361 >
7141471362 <FileConfiguration

Source/WebCore/WebCore.xcodeproj/project.pbxproj

16121612 5189F01D10B37BD900F3C739 /* JSPopStateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5189F01B10B37BD900F3C739 /* JSPopStateEvent.cpp */; };
16131613 5189F01E10B37BD900F3C739 /* JSPopStateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 5189F01C10B37BD900F3C739 /* JSPopStateEvent.h */; };
16141614 5189F0DE10B46B0E00F3C739 /* PopStateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */; };
1615  518A34C91026C8C9001B6896 /* JSWebSocketCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 518A34C61026C8C9001B6896 /* JSWebSocketCustom.cpp */; };
16161615 51A052331058774F00CC9E95 /* CredentialStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A052311058774F00CC9E95 /* CredentialStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
16171616 51A052341058774F00CC9E95 /* CredentialStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A052321058774F00CC9E95 /* CredentialStorage.cpp */; };
16181617 51A052561058874000CC9E95 /* ProtectionSpaceHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A052551058874000CC9E95 /* ProtectionSpaceHash.h */; settings = {ATTRIBUTES = (Private, ); }; };

88998898 5189F01B10B37BD900F3C739 /* JSPopStateEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPopStateEvent.cpp; sourceTree = "<group>"; };
89008899 5189F01C10B37BD900F3C739 /* JSPopStateEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPopStateEvent.h; sourceTree = "<group>"; };
89018900 5189F0DD10B46B0E00F3C739 /* PopStateEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PopStateEvent.cpp; sourceTree = "<group>"; };
8902  518A34C61026C8C9001B6896 /* JSWebSocketCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebSocketCustom.cpp; sourceTree = "<group>"; };
89038901 519FE0A10DAD446E00A08F21 /* HTMLAttributeNames.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLAttributeNames.in; sourceTree = "<group>"; };
89048902 519FE0A20DAD446E00A08F21 /* HTMLTagNames.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLTagNames.in; sourceTree = "<group>"; };
89058903 51A052311058774F00CC9E95 /* CredentialStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialStorage.h; sourceTree = "<group>"; };

2072320721 E1AD14C41297354900ACA989 /* JSWebKitCSSKeyframeRuleCustom.cpp */,
2072420722 E1AD14B4129734CA00ACA989 /* JSWebKitCSSKeyframesRuleCustom.cpp */,
2072520723 BC275B7811C5D1C300C9206C /* JSWebKitPointCustom.cpp */,
20726  518A34C61026C8C9001B6896 /* JSWebSocketCustom.cpp */,
2072720724 E18258AB0EF3CD7000933242 /* JSWorkerContextCustom.cpp */,
2072820725 E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */,
2072920726 BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,

2801528012 BC275B7911C5D1C300C9206C /* JSWebKitPointCustom.cpp in Sources */,
2801628013 31C0FF3F0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp in Sources */,
2801728014 5DA5E0FC102B953800088CF9 /* JSWebSocket.cpp in Sources */,
28018  518A34C91026C8C9001B6896 /* JSWebSocketCustom.cpp in Sources */,
2801928015 65DF320509D1CC60000BE325 /* JSWheelEvent.cpp in Sources */,
2802028016 E1C8BE5D0E8BD15A0064CB7D /* JSWorker.cpp in Sources */,
2802128017 E182568F0EF2B02D00933242 /* JSWorkerContext.cpp in Sources */,

Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

152152#include "JSWebKitCSSKeyframeRuleCustom.cpp"
153153#include "JSWebKitCSSKeyframesRuleCustom.cpp"
154154#include "JSWebKitPointCustom.cpp"
155 #include "JSWebSocketCustom.cpp"
156155#include "JSWorkerContextBase.cpp"
157156#include "JSWorkerContextCustom.cpp"
158157#include "JSWorkerCustom.cpp"

Source/WebCore/bindings/js/JSWebSocketCustom.cpp

1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  * Copyright (C) 2009, 2010 Apple, Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  * * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "config.h"
33 
34 #if ENABLE(WEB_SOCKETS)
35 
36 #include "JSWebSocket.h"
37 
38 #include "ExceptionCode.h"
39 #include "JSArrayBuffer.h"
40 #include "JSArrayBufferView.h"
41 #include "JSBlob.h"
42 #include "JSEventListener.h"
43 #include "KURL.h"
44 #include "WebSocket.h"
45 #include "WebSocketChannel.h"
46 #include <runtime/Error.h>
47 #include <wtf/MathExtras.h>
48 #include <wtf/Vector.h>
49 
50 using namespace JSC;
51 
52 namespace WebCore {
53 
54 EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecState* exec)
55 {
56  JSWebSocketConstructor* jsConstructor = jsCast<JSWebSocketConstructor*>(exec->callee());
57  ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
58  if (!context)
59  return throwVMError(exec, createReferenceError(exec, "WebSocket constructor associated document is unavailable"));
60 
61  if (!exec->argumentCount())
62  return throwVMError(exec, createNotEnoughArgumentsError(exec));
63 
64  String urlString = exec->argument(0).toString(exec)->value(exec);
65  if (exec->hadException())
66  return throwVMError(exec, createSyntaxError(exec, "wrong URL"));
67  RefPtr<WebSocket> webSocket = WebSocket::create(context);
68  ExceptionCode ec = 0;
69  if (exec->argumentCount() < 2)
70  webSocket->connect(urlString, ec);
71  else {
72  JSValue protocolsValue = exec->argument(1);
73  if (isJSArray(protocolsValue)) {
74  Vector<String> protocols;
75  JSArray* protocolsArray = asArray(protocolsValue);
76  for (unsigned i = 0; i < protocolsArray->length(); ++i) {
77  String protocol = protocolsArray->getIndex(exec, i).toString(exec)->value(exec);
78  if (exec->hadException())
79  return JSValue::encode(JSValue());
80  protocols.append(protocol);
81  }
82  webSocket->connect(urlString, protocols, ec);
83  } else {
84  String protocol = protocolsValue.toString(exec)->value(exec);
85  if (exec->hadException())
86  return JSValue::encode(JSValue());
87  webSocket->connect(urlString, protocol, ec);
88  }
89  }
90  setDOMException(exec, ec);
91  return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), WebSocket, webSocket.get()));
92 }
93 
94 } // namespace WebCore
95 
96 #endif

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub GenerateConstructorDeclaration
36723672
36733673 if (IsConstructable($interface) && !$interface->extendedAttributes->{"NamedConstructor"}) {
36743674 push(@$outputArray, " static JSC::EncodedJSValue JSC_HOST_CALL construct${className}(JSC::ExecState*);\n");
 3675
 3676 if (!HasCustomConstructor($interface)) {
 3677 my @constructors = @{$interface->constructors};
 3678 if (@constructors > 1) {
 3679 foreach my $constructor (@constructors) {
 3680 my $overloadedIndex = "" . $constructor->{overloadedIndex};
 3681 push(@$outputArray, " static JSC::EncodedJSValue JSC_HOST_CALL construct${className}${overloadedIndex}(JSC::ExecState*);\n");
 3682 }
 3683 }
 3684 }
 3685
36753686 push(@$outputArray, " static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);\n");
36763687 }
36773688 push(@$outputArray, "};\n\n");

@@sub GenerateConstructorDefinitions
37213732 my $interface = shift;
37223733 my $generatingNamedConstructor = shift;
37233734
3724  # FIXME: Add support for overloaded constructors to JS as well.
3725  # For now mimic the old behaviour by only generating code for the last "Constructor" attribute.
3726  my $function = @{$interface->constructors}[-1];
 3735 if (IsConstructable($interface)) {
 3736 my @constructors = @{$interface->constructors};
 3737 if (@constructors > 1) {
 3738 foreach my $constructor (@constructors) {
 3739 GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $constructor);
 3740 }
 3741 GenerateOverloadedConstructorDefinition($outputArray, $className, $interface);
 3742 } elsif (@constructors == 1) {
 3743 GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $constructors[0]);
 3744 } else {
 3745 GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor);
 3746 }
 3747 }
37273748
3728  GenerateConstructorDefinition($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $function);
3729  GenerateConstructorHelperMethods($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor, $function);
 3749 GenerateConstructorHelperMethods($outputArray, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $interface, $generatingNamedConstructor);
 3750}
 3751
 3752sub GenerateOverloadedConstructorDefinition
 3753{
 3754 my $outputArray = shift;
 3755 my $className = shift;
 3756 my $interface = shift;
 3757
 3758 my $functionName = "${className}Constructor::construct${className}";
 3759 push(@$outputArray, <<END);
 3760EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)
 3761{
 3762 size_t argsCount = exec->argumentCount();
 3763END
 3764
 3765 my %fetchedArguments = ();
 3766 my $leastNumMandatoryParams = 255;
 3767
 3768 my @constructors = @{$interface->constructors};
 3769 foreach my $overload (@constructors) {
 3770 my ($numMandatoryParams, $parametersCheck, @neededArguments) = GenerateFunctionParametersCheck($overload);
 3771 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams < $leastNumMandatoryParams);
 3772
 3773 foreach my $parameterIndex (@neededArguments) {
 3774 next if exists $fetchedArguments{$parameterIndex};
 3775 push(@$outputArray, " JSValue arg$parameterIndex(exec->argument($parameterIndex));\n");
 3776 $fetchedArguments{$parameterIndex} = 1;
 3777 }
 3778
 3779 push(@$outputArray, " if ($parametersCheck)\n");
 3780 push(@$outputArray, " return ${functionName}$overload->{overloadedIndex}(exec);\n");
 3781 }
 3782
 3783 if ($leastNumMandatoryParams >= 1) {
 3784 push(@$outputArray, " if (argsCount < $leastNumMandatoryParams)\n");
 3785 push(@$outputArray, " return throwVMError(exec, createNotEnoughArgumentsError(exec));\n");
 3786 }
 3787 push(@$outputArray, <<END);
 3788 return throwVMTypeError(exec);
 3789}
 3790
 3791END
37303792}
37313793
37323794sub GenerateConstructorDefinition

@@END
38323894 push(@$outputArray, "}\n\n");
38333895 }
38343896 } elsif (!HasCustomConstructor($interface) && (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor)) {
3835  push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
 3897 my $overloadedIndexString = "";
 3898 if ($function->{overloadedIndex} && $function->{overloadedIndex} > 0) {
 3899 $overloadedIndexString .= $function->{overloadedIndex};
 3900 }
 3901
 3902 push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}${overloadedIndexString}(ExecState* exec)\n");
38363903 push(@$outputArray, "{\n");
38373904 push(@$outputArray, " ${constructorClassName}* castedThis = jsCast<${constructorClassName}*>(exec->callee());\n");
38383905

@@sub GenerateConstructorHelperMethods
39023969 my $visibleInterfaceName = shift;
39033970 my $interface = shift;
39043971 my $generatingNamedConstructor = shift;
3905  my $function = shift;
39063972
39073973 my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
39083974 my $numberOfConstructorParameters = $interface->extendedAttributes->{"ConstructorParameters"};

@@sub GenerateConstructorHelperMethods
39103976 if ($codeGenerator->IsConstructorTemplate($interface, "Event")) {
39113977 $numberOfConstructorParameters = 2;
39123978 } elsif ($interface->extendedAttributes->{"Constructor"}) {
3913  $numberOfConstructorParameters = @{$function->parameters};
 3979 my @constructors = @{$interface->constructors};
 3980 $numberOfConstructorParameters = 1024;
 3981 foreach my $constructor (@constructors) {
 3982 my $currNumberOfParameters = @{$constructor->parameters};
 3983 if ($currNumberOfParameters < $numberOfConstructorParameters) {
 3984 $numberOfConstructorParameters = $currNumberOfParameters;
 3985 }
 3986 }
39143987 }
39153988 }
39163989

Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp

2222#include "JSTestOverloadedConstructors.h"
2323
2424#include "ExceptionCode.h"
 25#include "JSArrayBuffer.h"
 26#include "JSArrayBufferView.h"
 27#include "JSBlob.h"
2528#include "JSDOMBinding.h"
2629#include "TestOverloadedConstructors.h"
2730#include <runtime/Error.h>

@@static const HashTableValue JSTestOverloadedConstructorsConstructorTableValues[]
4851};
4952
5053static const HashTable JSTestOverloadedConstructorsConstructorTable = { 1, 0, JSTestOverloadedConstructorsConstructorTableValues, 0 };
51 EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors(ExecState* exec)
 54EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(ExecState* exec)
 55{
 56 JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
 57 if (exec->argumentCount() < 1)
 58 return throwVMError(exec, createNotEnoughArgumentsError(exec));
 59 ArrayBuffer* arrayBuffer(toArrayBuffer(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
 60 if (exec->hadException())
 61 return JSValue::encode(jsUndefined());
 62 RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(arrayBuffer);
 63 return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
 64}
 65
 66EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(ExecState* exec)
 67{
 68 JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
 69 if (exec->argumentCount() < 1)
 70 return throwVMError(exec, createNotEnoughArgumentsError(exec));
 71 ArrayBufferView* arrayBufferView(toArrayBufferView(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
 72 if (exec->hadException())
 73 return JSValue::encode(jsUndefined());
 74 RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(arrayBufferView);
 75 return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
 76}
 77
 78EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3(ExecState* exec)
 79{
 80 JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
 81 if (exec->argumentCount() < 1)
 82 return throwVMError(exec, createNotEnoughArgumentsError(exec));
 83 Blob* blob(toBlob(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
 84 if (exec->hadException())
 85 return JSValue::encode(jsUndefined());
 86 RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(blob);
 87 return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
 88}
 89
 90EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors4(ExecState* exec)
5291{
5392 JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
5493 if (exec->argumentCount() < 1)

@@EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJ
6099 return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
61100}
62101
 102EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors(ExecState* exec)
 103{
 104 size_t argsCount = exec->argumentCount();
 105 JSValue arg0(exec->argument(0));
 106 if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSArrayBuffer::s_info))))
 107 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(exec);
 108 if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSArrayBufferView::s_info))))
 109 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(exec);
 110 if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSBlob::s_info))))
 111 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3(exec);
 112 if (argsCount == 1)
 113 return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors4(exec);
 114 if (argsCount < 1)
 115 return throwVMError(exec, createNotEnoughArgumentsError(exec));
 116 return throwVMTypeError(exec);
 117}
 118
63119const ClassInfo JSTestOverloadedConstructorsConstructor::s_info = { "TestOverloadedConstructorsConstructor", &Base::s_info, &JSTestOverloadedConstructorsConstructorTable, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsConstructor) };
64120
65121JSTestOverloadedConstructorsConstructor::JSTestOverloadedConstructorsConstructor(Structure* structure, JSDOMGlobalObject* globalObject)

Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.h

@@public:
132132protected:
133133 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
134134 static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestOverloadedConstructors(JSC::ExecState*);
 135 static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestOverloadedConstructors1(JSC::ExecState*);
 136 static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestOverloadedConstructors2(JSC::ExecState*);
 137 static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestOverloadedConstructors3(JSC::ExecState*);
 138 static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestOverloadedConstructors4(JSC::ExecState*);
135139 static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
136140};
137141

LayoutTests/ChangeLog

 12012-12-18 Tommy Widenflycht <tommyw@chromium.org>
 2
 3 [JSC] Add support for overloaded constructors
 4 https://bugs.webkit.org/show_bug.cgi?id=103226
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * http/tests/websocket/tests/hybi/url-parsing-expected.txt:
 9
1102012-12-18 Ilya Tikhonovsky <loislo@chromium.org>
211
312 Unreviewed rebaseline new test introdiced at r138003

LayoutTests/http/tests/websocket/tests/hybi/url-parsing-expected.txt

1 CONSOLE MESSAGE: Invalid url for WebSocket null
 1CONSOLE MESSAGE: Wrong url scheme for WebSocket http://127.0.0.1:8000/websocket/tests/hybi/null
22CONSOLE MESSAGE: Invalid url for WebSocket ws://javascript:a
3 CONSOLE MESSAGE: Invalid url for WebSocket /applet
 3CONSOLE MESSAGE: Wrong url scheme for WebSocket http://127.0.0.1:8000/applet
44CONSOLE MESSAGE: Wrong url scheme for WebSocket javascript:a
55CONSOLE MESSAGE: WebSocket port 25 blocked
66CONSOLE MESSAGE: URL has fragment component ws://127.0.0.1/path#