[JSC] Add [ConstructorParameters=] to all custom constructors
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Feb 2012 23:59:55 +0000 (23:59 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Feb 2012 23:59:55 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78221

Reviewed by Adam Barth.

Source/WebCore:

This patch adds [ConstructorParameters=X] to IDL files that have
custom constructors, where X is the maximum number of arguments
of the constructor. [ConstructorParameters=X] is needed for custom
constructors, because custom constructors do not have a signature
in IDL files and thus CodeGeneratorJS.pm cannot know the number of
constructor arguments.

Test: fast/js/constructor-length.html

* dom/WebKitMutationObserver.idl:
* html/DOMFormData.idl:
* html/canvas/ArrayBuffer.idl:
* html/canvas/DataView.idl:
* html/canvas/Float32Array.idl:
* html/canvas/Float64Array.idl:
* html/canvas/Int16Array.idl:
* html/canvas/Int32Array.idl:
* html/canvas/Int8Array.idl:
* html/canvas/Uint16Array.idl:
* html/canvas/Uint32Array.idl:
* html/canvas/Uint8Array.idl:
* html/canvas/Uint8ClampedArray.idl:
* webaudio/AudioContext.idl:

* bindings/scripts/test/TestTypedArray.idl:

* bindings/scripts/test/JS/JSFloat64Array.cpp: Updated run-bindings-tests results.
(WebCore::JSFloat64ArrayConstructor::finishCreation):

LayoutTests:

The added tests check the length property of the custom constructors.

* fast/js/constructor-length.html:
* platform/mac/fast/js/constructor-length-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109035 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/js/constructor-length.html
LayoutTests/platform/mac/fast/js/constructor-length-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp
Source/WebCore/bindings/scripts/test/TestTypedArray.idl
Source/WebCore/dom/WebKitMutationObserver.idl
Source/WebCore/html/DOMFormData.idl
Source/WebCore/html/canvas/ArrayBuffer.idl
Source/WebCore/html/canvas/DataView.idl
Source/WebCore/html/canvas/Float32Array.idl
Source/WebCore/html/canvas/Float64Array.idl
Source/WebCore/html/canvas/Int16Array.idl
Source/WebCore/html/canvas/Int32Array.idl
Source/WebCore/html/canvas/Int8Array.idl
Source/WebCore/html/canvas/Uint16Array.idl
Source/WebCore/html/canvas/Uint32Array.idl
Source/WebCore/html/canvas/Uint8Array.idl
Source/WebCore/html/canvas/Uint8ClampedArray.idl
Source/WebCore/webaudio/AudioContext.idl

index 4732d7b..fa80c3e 100644 (file)
@@ -1,3 +1,15 @@
+2012-02-27  Kentaro Hara  <haraken@chromium.org>
+
+        [JSC] Add [ConstructorParameters=] to all custom constructors
+        https://bugs.webkit.org/show_bug.cgi?id=78221
+
+        Reviewed by Adam Barth.
+
+        The added tests check the length property of the custom constructors.
+
+        * fast/js/constructor-length.html:
+        * platform/mac/fast/js/constructor-length-expected.txt:
+
 2012-02-27  Adrienne Walker  <enne@google.com>
 
         [chromium] Unreviewed gardening, mark many svg tests as flaky crashers
index 567e7ca..27ba616 100644 (file)
@@ -7,17 +7,26 @@
 <script>
 description("This tests the length property of constructors.");
 
+shouldBe('ArrayBuffer.length', '1');
+shouldBe('AudioContext.length', '0');
 shouldBe('BeforeLoadEvent.length', '2');
 shouldBe('CloseEvent.length', '2');
 shouldBe('CustomEvent.length', '2');
+shouldBe('DOMFormData.length', '0');
 shouldBe('DOMParser.length', '0');
 shouldBe('DOMURL.length', '0');
+shouldBe('DataView.length', '3');
 shouldBe('ErrorEvent.length', '2');
 shouldBe('Event.length', '2');
 shouldBe('EventSource.length', '1');
+shouldBe('Float32Array.length', '1');
+shouldBe('Float64Array.length', '1');
 shouldBe('FileReader.length', '0');
 shouldBe('FileReaderSync.length', '0');
 shouldBe('HashChangeEvent.length', '2');
+shouldBe('Int16Array.length', '1');
+shouldBe('Int32Array.length', '1');
+shouldBe('Int8Array.length', '1');
 shouldBe('Intent.length', '3');
 shouldBe('MediaController.length', '0');
 shouldBe('MediaStream.length', '2');
@@ -33,11 +42,18 @@ shouldBe('SharedWorker.length', '2');
 shouldBe('StorageEvent.length', '2');
 shouldBe('TextTrackCue.length', '6');
 shouldBe('TrackEvent.length', '2');
+shouldBe('Uint16Array.length', '1');
+shouldBe('Uint32Array.length', '1');
+shouldBe('Uint8Array.length', '1');
+shouldBe('Uint8ClampedArray.length', '1');
 shouldBe('WebGLContextEvent.length', '2');
 shouldBe('WebKitAnimationEvent.length', '2');
 shouldBe('WebKitBlobBuilder.length', '0');
 shouldBe('WebKitCSSMatrix.length', '1');
+shouldBe('WebKitMutationObserver.length', '1');
+shouldBe('WebKitPoint.length', '2');
 shouldBe('WebKitTransitionEvent.length', '2');
+shouldBe('WebSocket.length', '1');
 shouldBe('Worker.length', '1');
 shouldBe('XMLHttpRequest.length', '0');
 shouldBe('XMLSerializer.length', '0');
index 4879c57..24d7568 100644 (file)
@@ -3,17 +3,26 @@ This tests the length property of constructors.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS ArrayBuffer.length is 1
+FAIL AudioContext.length should be 0. Threw exception ReferenceError: Can't find variable: AudioContext
 PASS BeforeLoadEvent.length is 2
 PASS CloseEvent.length is 2
 PASS CustomEvent.length is 2
+FAIL DOMFormData.length should be 0. Threw exception ReferenceError: Can't find variable: DOMFormData
 PASS DOMParser.length is 0
 FAIL DOMURL.length should be 0. Threw exception ReferenceError: Can't find variable: DOMURL
+PASS DataView.length is 3
 PASS ErrorEvent.length is 2
 PASS Event.length is 2
 PASS EventSource.length is 1
+PASS Float32Array.length is 1
+PASS Float64Array.length is 1
 PASS FileReader.length is 0
 FAIL FileReaderSync.length should be 0. Threw exception ReferenceError: Can't find variable: FileReaderSync
 PASS HashChangeEvent.length is 2
+PASS Int16Array.length is 1
+PASS Int32Array.length is 1
+PASS Int8Array.length is 1
 FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
 PASS MediaController.length is 0
 FAIL MediaStream.length should be 2. Threw exception ReferenceError: Can't find variable: MediaStream
@@ -29,11 +38,18 @@ PASS SharedWorker.length is 2
 PASS StorageEvent.length is 2
 PASS TextTrackCue.length is 6
 PASS TrackEvent.length is 2
+PASS Uint16Array.length is 1
+PASS Uint32Array.length is 1
+PASS Uint8Array.length is 1
+PASS Uint8ClampedArray.length is 1
 PASS WebGLContextEvent.length is 2
 PASS WebKitAnimationEvent.length is 2
 PASS WebKitBlobBuilder.length is 0
 PASS WebKitCSSMatrix.length is 1
+PASS WebKitMutationObserver.length is 1
+PASS WebKitPoint.length is 2
 PASS WebKitTransitionEvent.length is 2
+PASS WebSocket.length is 1
 PASS Worker.length is 1
 PASS XMLHttpRequest.length is 0
 PASS XMLSerializer.length is 0
index 99fde6a..de9fe9a 100644 (file)
@@ -1,3 +1,39 @@
+2012-02-27  Kentaro Hara  <haraken@chromium.org>
+
+        [JSC] Add [ConstructorParameters=] to all custom constructors
+        https://bugs.webkit.org/show_bug.cgi?id=78221
+
+        Reviewed by Adam Barth.
+
+        This patch adds [ConstructorParameters=X] to IDL files that have
+        custom constructors, where X is the maximum number of arguments
+        of the constructor. [ConstructorParameters=X] is needed for custom
+        constructors, because custom constructors do not have a signature
+        in IDL files and thus CodeGeneratorJS.pm cannot know the number of
+        constructor arguments.
+
+        Test: fast/js/constructor-length.html
+
+        * dom/WebKitMutationObserver.idl:
+        * html/DOMFormData.idl:
+        * html/canvas/ArrayBuffer.idl:
+        * html/canvas/DataView.idl:
+        * html/canvas/Float32Array.idl:
+        * html/canvas/Float64Array.idl:
+        * html/canvas/Int16Array.idl:
+        * html/canvas/Int32Array.idl:
+        * html/canvas/Int8Array.idl:
+        * html/canvas/Uint16Array.idl:
+        * html/canvas/Uint32Array.idl:
+        * html/canvas/Uint8Array.idl:
+        * html/canvas/Uint8ClampedArray.idl:
+        * webaudio/AudioContext.idl:
+
+        * bindings/scripts/test/TestTypedArray.idl:
+
+        * bindings/scripts/test/JS/JSFloat64Array.cpp: Updated run-bindings-tests results.
+        (WebCore::JSFloat64ArrayConstructor::finishCreation):
+
 2012-02-23  Raphael Kubo da Costa  <kubo@profusion.mobi>
 
         [BlackBerry][EFL] Provide dummy RunLoop implementations.
index 67220b7..b9d265f 100644 (file)
@@ -65,6 +65,7 @@ void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObjec
     Base::finishCreation(exec->globalData());
     ASSERT(inherits(&s_info));
     putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
+    putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
 }
 
 bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index cf5306d..e816b38 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=123,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index 2c0e8fa..cb76046 100644 (file)
@@ -31,7 +31,8 @@
 module core {
     interface [
         Conditional=MUTATION_OBSERVERS,
-        CustomConstructor
+        CustomConstructor,
+        ConstructorParameters=1
     ] WebKitMutationObserver {
         [Custom] void observe(in Node target, in MutationObserverOptions options)
             raises(DOMException);
index 4bab556..73eaa66 100644 (file)
@@ -32,6 +32,7 @@ module html {
 
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         JSGenerateToNativeObject,
         JSGenerateToJSObject,
         InterfaceName=FormData
index a631b13..26dd341 100644 (file)
@@ -28,6 +28,7 @@ module html {
     interface [
         JSGenerateIsReachable=Impl,
         CustomConstructor,
+        ConstructorParameters=1,
         JSNoStaticTables
     ] ArrayBuffer {
         readonly attribute int byteLength;
index 27bad0e..3f4dcdf 100755 (executable)
@@ -27,6 +27,7 @@ module html {
 
     interface [
         CustomConstructor,
+        ConstructorParameters=3,
         CustomToJSObject,
         JSNoStaticTables
     ] DataView : ArrayBufferView {
index 5e619a7..55491b1 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index f4c448a..e9d7ef0 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index b7ddc1e..8616846 100644 (file)
@@ -26,6 +26,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index 950437a..3f928fe 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index da0c8f1..0d4fb82 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index 33627bf..72fa9b3 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index 7bb4ca3..b56c0e5 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index fbbafc3..3e4141c 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index fd006e4..6c3587a 100644 (file)
@@ -27,6 +27,7 @@
 module html {
     interface [
         CustomConstructor,
+        ConstructorParameters=1,
         NumericIndexedGetter,
         CustomIndexedSetter,
         JSGenerateToNativeObject,
index ef69355..fabac13 100644 (file)
@@ -28,6 +28,7 @@ module webaudio {
         Conditional=WEB_AUDIO,
         ActiveDOMObject,
         CustomConstructor,
+        ConstructorParameters=0,
         JSCustomMarkFunction,
 #if defined(V8_BINDING) && V8_BINDING
         EventTarget