"Not enough arguments" error should be TypeError
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Apr 2012 03:30:28 +0000 (03:30 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Apr 2012 03:30:28 +0000 (03:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84628

Reviewed by Darin Adler.

Source/WebCore:

Currently, some custom bindings implement "Not enough arguments"
error as SyntaxError. The Web IDL spec requires that it should be
TypeError: http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm
Thus, this patch changes SyntaxError to TypeError.

Tests: http/tests/websocket/tests/hixie76/url-parsing.html:
       http/tests/websocket/tests/hybi/url-parsing.html:
       http/tests/xmlhttprequest/exceptions.html:
       svg/dom/SVGLength.html:
       webaudio/audionode.html:

* bindings/js/JSAudioContextCustom.cpp:
(WebCore::JSAudioContextConstructor::constructJSAudioContext):
* bindings/js/JSSVGLengthCustom.cpp:
(WebCore::JSSVGLength::convertToSpecifiedUnits):
* bindings/js/JSWebSocketCustom.cpp:
(WebCore::JSWebSocketConstructor::constructJSWebSocket):
(WebCore::JSWebSocket::send):
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::open):
* bindings/v8/custom/V8AudioContextCustom.cpp:
(WebCore::V8AudioContext::constructorCallback):
* bindings/v8/custom/V8SVGLengthCustom.cpp:
(WebCore::V8SVGLength::convertToSpecifiedUnitsCallback):
* bindings/v8/custom/V8WebSocketCustom.cpp:
(WebCore::V8WebSocket::constructorCallback):
(WebCore::V8WebSocket::sendCallback):
* bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
(WebCore::V8XMLHttpRequest::openCallback):

LayoutTests:

Currently, some custom bindings implement "Not enough arguments"
error as SyntaxError. The Web IDL spec requires that it should be
TypeError: http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm
Thus, this patch changes SyntaxError to TypeError, and adds test
cases for the exception.

* http/tests/websocket/tests/hixie76/send-empty-expected.txt:
* http/tests/websocket/tests/hixie76/url-parsing.html:
* http/tests/websocket/tests/hybi/send-empty-expected.txt:
* http/tests/websocket/tests/hybi/url-parsing.html:
* http/tests/xmlhttprequest/exceptions-expected.txt:
* http/tests/xmlhttprequest/exceptions.html:
* platform/chromium-linux/http/tests/websocket/tests/hixie76/url-parsing-expected.txt:
* platform/chromium/http/tests/websocket/tests/hybi/url-parsing-expected.txt:
* svg/dom/SVGLength-expected.txt:
* webaudio/audionode-expected.txt:
* webaudio/audionode.html:

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/hixie76/send-empty-expected.txt
LayoutTests/http/tests/websocket/tests/hixie76/url-parsing.html
LayoutTests/http/tests/websocket/tests/hybi/send-empty-expected.txt
LayoutTests/http/tests/websocket/tests/hybi/url-parsing.html
LayoutTests/http/tests/xmlhttprequest/exceptions-expected.txt
LayoutTests/http/tests/xmlhttprequest/exceptions.html
LayoutTests/platform/chromium-linux/http/tests/websocket/tests/hixie76/url-parsing-expected.txt
LayoutTests/platform/chromium/http/tests/websocket/tests/hybi/url-parsing-expected.txt
LayoutTests/svg/dom/SVGLength-expected.txt
LayoutTests/webaudio/audionode-expected.txt
LayoutTests/webaudio/audionode.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSAudioContextCustom.cpp
Source/WebCore/bindings/js/JSSVGLengthCustom.cpp
Source/WebCore/bindings/js/JSWebSocketCustom.cpp
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp
Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp
Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp
Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp

index 5d06d49..410ba17 100644 (file)
@@ -1,3 +1,28 @@
+2012-04-27  Kentaro Hara  <haraken@chromium.org>
+
+        "Not enough arguments" error should be TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=84628
+
+        Reviewed by Darin Adler.
+
+        Currently, some custom bindings implement "Not enough arguments"
+        error as SyntaxError. The Web IDL spec requires that it should be
+        TypeError: http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm
+        Thus, this patch changes SyntaxError to TypeError, and adds test
+        cases for the exception.
+
+        * http/tests/websocket/tests/hixie76/send-empty-expected.txt:
+        * http/tests/websocket/tests/hixie76/url-parsing.html:
+        * http/tests/websocket/tests/hybi/send-empty-expected.txt:
+        * http/tests/websocket/tests/hybi/url-parsing.html:
+        * http/tests/xmlhttprequest/exceptions-expected.txt:
+        * http/tests/xmlhttprequest/exceptions.html:
+        * platform/chromium-linux/http/tests/websocket/tests/hixie76/url-parsing-expected.txt:
+        * platform/chromium/http/tests/websocket/tests/hybi/url-parsing-expected.txt:
+        * svg/dom/SVGLength-expected.txt:
+        * webaudio/audionode-expected.txt:
+        * webaudio/audionode.html:
+
 2012-04-27  Kenneth Russell  <kbr@google.com>
 
         Remove SHADER_COMPILER constant
index 0c70f1f..ef0cb94 100644 (file)
@@ -2,7 +2,7 @@ WebSocket: Calling send() without arguments should raise SyntaxError.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
-PASS ws.send() threw exception SyntaxError: Not enough arguments.
+PASS ws.send() threw exception TypeError: Not enough arguments.
 PASS closeEvent.wasClean is true
 PASS receivedMessages.length is 1
 PASS receivedMessages[0] is "Goodbye"
index c2c1af8..86a5797 100644 (file)
@@ -12,6 +12,9 @@ description("Test WebSocket URL parsing.");
 if (window.layoutTestController)
     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
 
+// Not enough arguments.
+shouldThrow('new WebSocket()');
+
 // Invalid url will fail to be parsed.
 shouldThrow('new WebSocket("ws://javascript:a")');
 
index 0c70f1f..ef0cb94 100644 (file)
@@ -2,7 +2,7 @@ WebSocket: Calling send() without arguments should raise SyntaxError.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
-PASS ws.send() threw exception SyntaxError: Not enough arguments.
+PASS ws.send() threw exception TypeError: Not enough arguments.
 PASS closeEvent.wasClean is true
 PASS receivedMessages.length is 1
 PASS receivedMessages[0] is "Goodbye"
index 5eb38e9..3805edd 100644 (file)
@@ -12,6 +12,9 @@ description("Test WebSocket URL parsing.");
 if (window.layoutTestController)
     layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
 
+// Not enough arguments.
+shouldThrow('new WebSocket()');
+
 // Invalid url will fail to be parsed.
 shouldThrow('new WebSocket("ws://javascript:a")');
 
index fb34614..1ff33d9 100644 (file)
@@ -12,3 +12,5 @@ send()
 PASS: req.send(null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 PASS: req.setRequestHeader("Foo", "bar") threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 PASS: req.getResponseHeader() threw exception TypeError: Not enough arguments.
+PASS: req.open() threw exception TypeError: Not enough arguments.
+PASS: req.open(null) threw exception TypeError: Not enough arguments.
index 47c85f5..1065b5e 100644 (file)
@@ -73,6 +73,9 @@
     shouldThrow('req.send(null)');
     shouldThrow('req.setRequestHeader("Foo", "bar")');
     shouldThrow('req.getResponseHeader()');
+
+    shouldThrow('req.open()');
+    shouldThrow('req.open(null)');
    
 </script>
 </body>
index 62dd534..9195eae 100644 (file)
@@ -8,6 +8,7 @@ Test WebSocket URL parsing.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
+PASS new WebSocket() threw exception TypeError: Not enough arguments.
 PASS new WebSocket("ws://javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("/applet") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
index bb887cd..dc26831 100644 (file)
@@ -8,6 +8,7 @@ Test WebSocket URL parsing.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
+PASS new WebSocket() threw exception TypeError: Not enough arguments.
 PASS new WebSocket("ws://javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("/applet") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
index 45826cc..7baeadd 100644 (file)
@@ -23,7 +23,7 @@ PASS length.convertToSpecifiedUnits(11) threw exception Error: NOT_SUPPORTED_ERR
 PASS length.convertToSpecifiedUnits('aString') threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS length.convertToSpecifiedUnits(length) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
 PASS length.convertToSpecifiedUnits(svgElement) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
-PASS length.convertToSpecifiedUnits() threw exception SyntaxError: Not enough arguments.
+PASS length.convertToSpecifiedUnits() threw exception TypeError: Not enough arguments.
 PASS length.unitType is SVGLength.SVG_LENGTHTYPE_PX
 PASS length.value is 2
 PASS length.valueInSpecifiedUnits is 2
index ca32162..352d6af 100644 (file)
@@ -12,6 +12,7 @@ PASS connect() exception thrown for illegal output index.
 PASS connect() exception thrown for illegal input index.
 PASS audioNode.connect(context.destination) succeeded.
 PASS exception thrown when connecting to other context's node.
+PASS exception thrown when creating audio context with not enough arguments.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 4e84ad1..ee77d21 100644 (file)
@@ -82,6 +82,14 @@ function runTest() {
         testPassed("exception thrown when connecting to other context's node.");
     }
 
+    // Create a new context with not enough arguments
+    try {
+        context2 = new webkitAudioContext(0, 0);
+        testFailed("exception should be thrown when creating audio context with not enough arguments.");
+    } catch(e) {
+        testPassed("exception thrown when creating audio context with not enough arguments.");
+    }
+
     finishJSTest();
 }
 
index e2790b0..e5a9918 100644 (file)
@@ -1,3 +1,40 @@
+2012-04-27  Kentaro Hara  <haraken@chromium.org>
+
+        "Not enough arguments" error should be TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=84628
+
+        Reviewed by Darin Adler.
+
+        Currently, some custom bindings implement "Not enough arguments"
+        error as SyntaxError. The Web IDL spec requires that it should be
+        TypeError: http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm
+        Thus, this patch changes SyntaxError to TypeError.
+
+        Tests: http/tests/websocket/tests/hixie76/url-parsing.html:
+               http/tests/websocket/tests/hybi/url-parsing.html:
+               http/tests/xmlhttprequest/exceptions.html:
+               svg/dom/SVGLength.html:
+               webaudio/audionode.html:
+
+        * bindings/js/JSAudioContextCustom.cpp:
+        (WebCore::JSAudioContextConstructor::constructJSAudioContext):
+        * bindings/js/JSSVGLengthCustom.cpp:
+        (WebCore::JSSVGLength::convertToSpecifiedUnits):
+        * bindings/js/JSWebSocketCustom.cpp:
+        (WebCore::JSWebSocketConstructor::constructJSWebSocket):
+        (WebCore::JSWebSocket::send):
+        * bindings/js/JSXMLHttpRequestCustom.cpp:
+        (WebCore::JSXMLHttpRequest::open):
+        * bindings/v8/custom/V8AudioContextCustom.cpp:
+        (WebCore::V8AudioContext::constructorCallback):
+        * bindings/v8/custom/V8SVGLengthCustom.cpp:
+        (WebCore::V8SVGLength::convertToSpecifiedUnitsCallback):
+        * bindings/v8/custom/V8WebSocketCustom.cpp:
+        (WebCore::V8WebSocket::constructorCallback):
+        (WebCore::V8WebSocket::sendCallback):
+        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
+        (WebCore::V8XMLHttpRequest::openCallback):
+
 2012-04-27  Kenneth Russell  <kbr@google.com>
 
         Remove SHADER_COMPILER constant
index 9f5e26e..ea8fcde 100644 (file)
@@ -80,7 +80,7 @@ EncodedJSValue JSC_HOST_CALL JSAudioContextConstructor::constructJSAudioContext(
         // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
         // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
         if (exec->argumentCount() < 3)
-            return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
+            return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
 
         int32_t numberOfChannels = exec->argument(0).toInt32(exec);
         int32_t numberOfFrames = exec->argument(1).toInt32(exec);
index 7057b21..6f70bd0 100644 (file)
@@ -81,7 +81,7 @@ JSValue JSSVGLength::convertToSpecifiedUnits(ExecState* exec)
     SVGLength& podImp = impl()->propertyReference();
 
     if (exec->argumentCount() < 1)
-        return throwError(exec, createSyntaxError(exec, "Not enough arguments"));
+        return throwError(exec, createTypeError(exec, "Not enough arguments"));
 
     unsigned short unitType = exec->argument(0).toUInt32(exec);
     if (exec->hadException())
index 71ad57a..52a69b5 100644 (file)
@@ -58,7 +58,7 @@ EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecSt
         return throwVMError(exec, createReferenceError(exec, "WebSocket constructor associated document is unavailable"));
 
     if (!exec->argumentCount())
-        return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
+        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
 
     String urlString = ustringToString(exec->argument(0).toString(exec)->value(exec));
     if (exec->hadException())
@@ -93,7 +93,7 @@ EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecSt
 JSValue JSWebSocket::send(ExecState* exec)
 {
     if (!exec->argumentCount())
-        return throwError(exec, createSyntaxError(exec, "Not enough arguments"));
+        return throwError(exec, createTypeError(exec, "Not enough arguments"));
 
     JSValue message = exec->argument(0);
     ExceptionCode ec = 0;
index 4cdf68c..7feb342 100644 (file)
@@ -83,7 +83,7 @@ void JSXMLHttpRequest::visitChildren(JSCell* cell, SlotVisitor& visitor)
 JSValue JSXMLHttpRequest::open(ExecState* exec)
 {
     if (exec->argumentCount() < 2)
-        return throwError(exec, createSyntaxError(exec, "Not enough arguments"));
+        return throwError(exec, createTypeError(exec, "Not enough arguments"));
 
     const KURL& url = impl()->scriptExecutionContext()->completeURL(ustringToString(exec->argument(1).toString(exec)->value(exec)));
     String method = ustringToString(exec->argument(0).toString(exec)->value(exec));
index 4d41923..8fb0951 100644 (file)
@@ -71,7 +71,7 @@ v8::Handle<v8::Value> V8AudioContext::constructorCallback(const v8::Arguments& a
         // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
         // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
         if (args.Length() < 3)
-            return throwError("Not enough arguments", V8Proxy::SyntaxError);
+            return throwError("Not enough arguments", V8Proxy::TypeError);
 
         bool ok = false;
 
index 2f5909a..fc544cd 100644 (file)
@@ -90,7 +90,7 @@ v8::Handle<v8::Value> V8SVGLength::convertToSpecifiedUnitsCallback(const v8::Arg
     }
 
     if (args.Length() < 1)
-        return throwError("Not enough arguments", V8Proxy::SyntaxError);
+        return throwError("Not enough arguments", V8Proxy::TypeError);
 
     SVGLength& imp = wrapper->propertyReference();
     ExceptionCode ec = 0;
index 5c1661e..5611637 100644 (file)
@@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8WebSocket::constructorCallback(const v8::Arguments& args
         return args.Holder();
 
     if (args.Length() == 0)
-        return throwError("Not enough arguments", V8Proxy::SyntaxError);
+        return throwError("Not enough arguments", V8Proxy::TypeError);
 
     v8::TryCatch tryCatch;
     v8::Handle<v8::String> urlstring = args[0]->ToString();
@@ -117,7 +117,7 @@ v8::Handle<v8::Value> V8WebSocket::sendCallback(const v8::Arguments& args)
     INC_STATS("DOM.WebSocket.send()");
 
     if (!args.Length())
-        return throwError("Not enough arguments", V8Proxy::SyntaxError);
+        return throwError("Not enough arguments", V8Proxy::TypeError);
 
     WebSocket* webSocket = V8WebSocket::toNative(args.Holder());
     v8::Handle<v8::Value> message = args[0];
index 2eb1b53..36a217a 100644 (file)
@@ -121,7 +121,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args)
     // open(method, url, async, user, passwd)
 
     if (args.Length() < 2)
-        return throwError("Not enough arguments", V8Proxy::SyntaxError);
+        return throwError("Not enough arguments", V8Proxy::TypeError);
 
     XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());