Diff
Modified: trunk/LayoutTests/ChangeLog (94356 => 94357)
--- trunk/LayoutTests/ChangeLog 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/LayoutTests/ChangeLog 2011-09-01 23:06:49 UTC (rev 94357)
@@ -1,3 +1,17 @@
+2011-09-01 Kentaro Hara <[email protected]>
+
+ TypeError should be thrown when a constructor is called as a normal function.
+ https://bugs.webkit.org/show_bug.cgi?id=67381
+
+ Reviewed by Darin Adler.
+
+ The spec is here: http://www.w3.org/TR/WebIDL/#es-interface-call
+ For example, "Image()" or "XMLHttpRequest()" should throw TypeError.
+
+ * fast/dom/call-a-constructor-as-a-function-expected.txt: Added. The test result for JSC.
+ * fast/dom/call-a-constructor-as-a-function.html: Added. Checks if TypeError is thrown.
+ * platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt: Added. The test result for V8.
+
2011-09-01 Sam Weinig <[email protected]>
Add missing Event constructors to DOMWindow.idl
Added: trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function-expected.txt (0 => 94357)
--- trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function-expected.txt 2011-09-01 23:06:49 UTC (rev 94357)
@@ -0,0 +1,32 @@
+This tests if TypeError is thrown or not when we call a constructor as a normal function.
+
+PASS ArrayBuffer() threw exception TypeError: '[object ArrayBufferConstructor]' is not a function (evaluating 'ArrayBuffer()').
+SKIP AudioContext is not implemented.
+PASS FormData() threw exception TypeError: '[object FormDataConstructor]' is not a function (evaluating 'FormData()').
+PASS DataView() threw exception TypeError: '[object DataViewConstructor]' is not a function (evaluating 'DataView()').
+PASS EventSource() threw exception TypeError: '[object EventSourceConstructor]' is not a function (evaluating 'EventSource()').
+PASS FileReader() threw exception TypeError: '[object FileReaderConstructor]' is not a function (evaluating 'FileReader()').
+PASS Float32Array() threw exception TypeError: '[object Float32ArrayConstructor]' is not a function (evaluating 'Float32Array()').
+PASS Float64Array() threw exception TypeError: '[object Float64ArrayConstructor]' is not a function (evaluating 'Float64Array()').
+PASS Audio() threw exception TypeError: '[object AudioConstructor]' is not a function (evaluating 'Audio()').
+PASS Image() threw exception TypeError: '[object ImageConstructor]' is not a function (evaluating 'Image()').
+PASS Option() threw exception TypeError: '[object OptionConstructor]' is not a function (evaluating 'Option()').
+PASS Int16Array() threw exception TypeError: '[object Int16ArrayConstructor]' is not a function (evaluating 'Int16Array()').
+PASS Int32Array() threw exception TypeError: '[object Int32ArrayConstructor]' is not a function (evaluating 'Int32Array()').
+PASS Int8Array() threw exception TypeError: '[object Int8ArrayConstructor]' is not a function (evaluating 'Int8Array()').
+PASS MessageChannel() threw exception TypeError: '[object MessageChannelConstructor]' is not a function (evaluating 'MessageChannel()').
+SKIP PeerConnection is not implemented.
+PASS SharedWorker() threw exception TypeError: '[object SharedWorkerConstructor]' is not a function (evaluating 'SharedWorker()').
+PASS Uint16Array() threw exception TypeError: '[object Uint16ArrayConstructor]' is not a function (evaluating 'Uint16Array()').
+PASS Uint32Array() threw exception TypeError: '[object Uint32ArrayConstructor]' is not a function (evaluating 'Uint32Array()').
+PASS Uint8Array() threw exception TypeError: '[object Uint8ArrayConstructor]' is not a function (evaluating 'Uint8Array()').
+PASS WebKitCSSMatrix() threw exception TypeError: '[object WebKitCSSMatrixConstructor]' is not a function (evaluating 'WebKitCSSMatrix()').
+PASS WebKitPoint() threw exception TypeError: '[object WebKitPointConstructor]' is not a function (evaluating 'WebKitPoint()').
+PASS WebSocket() threw exception TypeError: '[object WebSocketConstructor]' is not a function (evaluating 'WebSocket()').
+PASS Worker() threw exception TypeError: '[object WorkerConstructor]' is not a function (evaluating 'Worker()').
+PASS XMLHttpRequest() threw exception TypeError: '[object XMLHttpRequestConstructor]' is not a function (evaluating 'XMLHttpRequest()').
+PASS XSLTProcessor() threw exception TypeError: '[object XSLTProcessorConstructor]' is not a function (evaluating 'XSLTProcessor()').
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function.html (0 => 94357)
--- trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function.html (rev 0)
+++ trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function.html 2011-09-01 23:06:49 UTC (rev 94357)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="console">
+<p>
+This tests if TypeError is thrown or not when we call a constructor as a normal function.
+</p>
+</div>
+<script>
+var test_constructors = ["ArrayBuffer", "AudioContext", "FormData", "DataView", "EventSource", "FileReader", "Float32Array", "Float64Array", "Audio", "Image", "Option", "Int16Array", "Int32Array", "Int8Array", "MessageChannel", "PeerConnection", "SharedWorker", "Uint16Array", "Uint32Array", "Uint8Array", "WebKitCSSMatrix", "WebKitPoint", "WebSocket", "Worker", "XMLHttpRequest", "XSLTProcessor"];
+
+test_constructors.forEach(function (constructor) {
+ if (eval("window." + constructor))
+ shouldThrow(constructor + "()");
+ else
+ debug("SKIP " + constructor + " is not implemented.");
+});
+
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt (0 => 94357)
--- trunk/LayoutTests/platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/dom/call-a-constructor-as-a-function-expected.txt 2011-09-01 23:06:49 UTC (rev 94357)
@@ -0,0 +1,32 @@
+This tests if TypeError is thrown or not when we call a constructor as a normal function.
+
+PASS ArrayBuffer() threw exception TypeError: DOM object constructor cannot be called as a function..
+SKIP AudioContext is not implemented.
+PASS FormData() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS DataView() threw exception TypeError: DOM object constructor cannot be called as a function.
+PASS EventSource() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS FileReader() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Float32Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Float64Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Audio() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Image() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Option() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Int16Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Int32Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Int8Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS MessageChannel() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS PeerConnection() threw exception TypeError: DOM object constructor cannot be called as a function..
+SKIP SharedWorker is not implemented.
+PASS Uint16Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Uint32Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS Uint8Array() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS WebKitCSSMatrix() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS WebKitPoint() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS WebSocket() threw exception TypeError: DOM object custructor cannot be called as a function..
+PASS Worker() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS XMLHttpRequest() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS XSLTProcessor() threw exception TypeError: DOM object constructor cannot be called as a function..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Modified: trunk/Source/WebCore/ChangeLog (94356 => 94357)
--- trunk/Source/WebCore/ChangeLog 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/ChangeLog 2011-09-01 23:06:49 UTC (rev 94357)
@@ -1,3 +1,42 @@
+2011-09-01 Kentaro Hara <[email protected]>
+
+ TypeError should be thrown when a constructor is called as a normal function.
+ https://bugs.webkit.org/show_bug.cgi?id=67381
+
+ Reviewed by Darin Adler.
+
+ The spec is here: http://www.w3.org/TR/WebIDL/#es-interface-call
+ For example, "Image()" or "XMLHttpRequest()" should throw TypeError.
+
+ Test: fast/dom/call-a-constructor-as-a-function.html
+
+ * bindings/v8/custom/V8ArrayBufferCustom.cpp:
+ (WebCore::V8ArrayBuffer::constructorCallback): Throws TypeError if args.IsConstructCall() is false.
+ * bindings/v8/custom/V8ArrayBufferViewCustom.h:
+ (WebCore::constructWebGLArray): Ditto.
+ * bindings/v8/custom/V8AudioContextCustom.cpp:
+ (WebCore::V8AudioContext::constructorCallback): Ditto.
+ * bindings/v8/custom/V8DOMFormDataCustom.cpp:
+ (WebCore::V8DOMFormData::constructorCallback): Ditto.
+ * bindings/v8/custom/V8HTMLAudioElementConstructor.cpp:
+ (WebCore::v8HTMLAudioElementConstructorCallback): Ditto.
+ * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+ (WebCore::v8HTMLImageElementConstructorCallback): Ditto.
+ * bindings/v8/custom/V8HTMLOptionElementConstructor.cpp:
+ (WebCore::v8HTMLOptionElementConstructorCallback): Ditto.
+ * bindings/v8/custom/V8MessageChannelConstructor.cpp:
+ (WebCore::V8MessageChannel::constructorCallback): Ditto.
+ * bindings/v8/custom/V8SharedWorkerCustom.cpp:
+ (WebCore::V8SharedWorker::constructorCallback): Ditto.
+ * bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp:
+ (WebCore::V8WebKitCSSMatrix::constructorCallback): Ditto.
+ * bindings/v8/custom/V8WebKitPointConstructor.cpp:
+ (WebCore::V8WebKitPoint::constructorCallback): Ditto.
+ * bindings/v8/custom/V8WebSocketCustom.cpp:
+ (WebCore::V8WebSocket::constructorCallback): Ditto.
+ * bindings/v8/custom/V8WorkerCustom.cpp:
+ (WebCore::V8Worker::constructorCallback): Ditto.
+
2011-08-31 Adrienne Walker <[email protected]>
[chromium] TextureManager overestimates the size of non-RGBA texture formats
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -43,7 +43,7 @@
INC_STATS("DOM.ArrayBuffer.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::SyntaxError);
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
// If we return a previously constructed ArrayBuffer,
// e.g. from the call to ArrayBufferView.buffer, this code is called
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2011-09-01 23:06:49 UTC (rev 94357)
@@ -81,7 +81,7 @@
v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType)
{
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
int argLen = args.Length();
if (!argLen) {
Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -44,7 +44,7 @@
INC_STATS("DOM.AudioContext.Contructor");
if (!args.IsConstructCall())
- return throwError("AudioContext constructor cannot be called as a function.");
+ return throwError("AudioContext constructor cannot be called as a function.", V8Proxy::TypeError);
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -45,7 +45,7 @@
INC_STATS("DOM.FormData.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::SyntaxError);
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
HTMLFormElement* form = 0;
if (args.Length() > 0 && V8HTMLFormElement::HasInstance(args[0]))
Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -51,7 +51,7 @@
INC_STATS("DOM.HTMLAudioElement.Contructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -51,7 +51,7 @@
INC_STATS("DOM.HTMLImageElement.Contructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -51,7 +51,7 @@
INC_STATS("DOM.HTMLOptionElement.Contructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -51,7 +51,7 @@
// FIXME: The logic here is almost exact duplicate of V8::constructDOMObject.
// Consider refactoring to reduce duplication.
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
// Get the ScriptExecutionContext (WorkerContext or Document)
ScriptExecutionContext* context = getScriptExecutionContext();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -49,7 +49,7 @@
INC_STATS(L"DOM.SharedWorker.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
if (!args.Length())
return throwError("Not enough arguments", V8Proxy::TypeError);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -49,7 +49,7 @@
INC_STATS("DOM.WebKitCSSMatrix.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
// FIXME: The logic here is almost exact duplicate of V8::constructDOMObject.
// Consider refactoring to reduce duplication.
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -45,7 +45,7 @@
INC_STATS("DOM.WebKitPoint.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
float x = 0;
float y = 0;
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -51,7 +51,7 @@
INC_STATS("DOM.WebSocket.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object custructor cannot be called as a function.");
+ return throwError("DOM object custructor cannot be called as a function.", V8Proxy::TypeError);
if (args.Length() == 0)
return throwError("Not enough arguments", V8Proxy::SyntaxError);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp (94356 => 94357)
--- trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp 2011-09-01 23:03:58 UTC (rev 94356)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp 2011-09-01 23:06:49 UTC (rev 94357)
@@ -52,7 +52,7 @@
INC_STATS(L"DOM.Worker.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.");
+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
if (!args.Length())
return throwError("Not enough arguments", V8Proxy::TypeError);