Skip to content

Commit 13a47eb

Browse files
committed
"Not enough arguments" error should be TypeError
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: Canonical link: https://commits.webkit.org/102657@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f6057e6 commit 13a47eb

21 files changed

Lines changed: 97 additions & 13 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
2012-04-27 Kentaro Hara <haraken@chromium.org>
2+
3+
"Not enough arguments" error should be TypeError
4+
https://bugs.webkit.org/show_bug.cgi?id=84628
5+
6+
Reviewed by Darin Adler.
7+
8+
Currently, some custom bindings implement "Not enough arguments"
9+
error as SyntaxError. The Web IDL spec requires that it should be
10+
TypeError: http://www.w3.org/TR/WebIDL/#dfn-overload-resolution-algorithm
11+
Thus, this patch changes SyntaxError to TypeError, and adds test
12+
cases for the exception.
13+
14+
* http/tests/websocket/tests/hixie76/send-empty-expected.txt:
15+
* http/tests/websocket/tests/hixie76/url-parsing.html:
16+
* http/tests/websocket/tests/hybi/send-empty-expected.txt:
17+
* http/tests/websocket/tests/hybi/url-parsing.html:
18+
* http/tests/xmlhttprequest/exceptions-expected.txt:
19+
* http/tests/xmlhttprequest/exceptions.html:
20+
* platform/chromium-linux/http/tests/websocket/tests/hixie76/url-parsing-expected.txt:
21+
* platform/chromium/http/tests/websocket/tests/hybi/url-parsing-expected.txt:
22+
* svg/dom/SVGLength-expected.txt:
23+
* webaudio/audionode-expected.txt:
24+
* webaudio/audionode.html:
25+
126
2012-04-27 Kenneth Russell <kbr@google.com>
227

328
Remove SHADER_COMPILER constant

LayoutTests/http/tests/websocket/tests/hixie76/send-empty-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ WebSocket: Calling send() without arguments should raise SyntaxError.
22

33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

5-
PASS ws.send() threw exception SyntaxError: Not enough arguments.
5+
PASS ws.send() threw exception TypeError: Not enough arguments.
66
PASS closeEvent.wasClean is true
77
PASS receivedMessages.length is 1
88
PASS receivedMessages[0] is "Goodbye"

LayoutTests/http/tests/websocket/tests/hixie76/url-parsing.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
if (window.layoutTestController)
1313
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
1414

15+
// Not enough arguments.
16+
shouldThrow('new WebSocket()');
17+
1518
// Invalid url will fail to be parsed.
1619
shouldThrow('new WebSocket("ws://javascript:a")');
1720

LayoutTests/http/tests/websocket/tests/hybi/send-empty-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ WebSocket: Calling send() without arguments should raise SyntaxError.
22

33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

5-
PASS ws.send() threw exception SyntaxError: Not enough arguments.
5+
PASS ws.send() threw exception TypeError: Not enough arguments.
66
PASS closeEvent.wasClean is true
77
PASS receivedMessages.length is 1
88
PASS receivedMessages[0] is "Goodbye"

LayoutTests/http/tests/websocket/tests/hybi/url-parsing.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
if (window.layoutTestController)
1313
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
1414

15+
// Not enough arguments.
16+
shouldThrow('new WebSocket()');
17+
1518
// Invalid url will fail to be parsed.
1619
shouldThrow('new WebSocket("ws://javascript:a")');
1720

LayoutTests/http/tests/xmlhttprequest/exceptions-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ send()
1212
PASS: req.send(null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
1313
PASS: req.setRequestHeader("Foo", "bar") threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
1414
PASS: req.getResponseHeader() threw exception TypeError: Not enough arguments.
15+
PASS: req.open() threw exception TypeError: Not enough arguments.
16+
PASS: req.open(null) threw exception TypeError: Not enough arguments.

LayoutTests/http/tests/xmlhttprequest/exceptions.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
shouldThrow('req.send(null)');
7474
shouldThrow('req.setRequestHeader("Foo", "bar")');
7575
shouldThrow('req.getResponseHeader()');
76+
77+
shouldThrow('req.open()');
78+
shouldThrow('req.open(null)');
7679

7780
</script>
7881
</body>

LayoutTests/platform/chromium-linux/http/tests/websocket/tests/hixie76/url-parsing-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Test WebSocket URL parsing.
88

99
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
1010

11+
PASS new WebSocket() threw exception TypeError: Not enough arguments.
1112
PASS new WebSocket("ws://javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
1213
PASS new WebSocket("/applet") threw exception Error: SYNTAX_ERR: DOM Exception 12.
1314
PASS new WebSocket("javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Test WebSocket URL parsing.
88

99
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
1010

11+
PASS new WebSocket() threw exception TypeError: Not enough arguments.
1112
PASS new WebSocket("ws://javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
1213
PASS new WebSocket("/applet") threw exception Error: SYNTAX_ERR: DOM Exception 12.
1314
PASS new WebSocket("javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.

LayoutTests/svg/dom/SVGLength-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PASS length.convertToSpecifiedUnits(11) threw exception Error: NOT_SUPPORTED_ERR
2323
PASS length.convertToSpecifiedUnits('aString') threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
2424
PASS length.convertToSpecifiedUnits(length) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
2525
PASS length.convertToSpecifiedUnits(svgElement) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9.
26-
PASS length.convertToSpecifiedUnits() threw exception SyntaxError: Not enough arguments.
26+
PASS length.convertToSpecifiedUnits() threw exception TypeError: Not enough arguments.
2727
PASS length.unitType is SVGLength.SVG_LENGTHTYPE_PX
2828
PASS length.value is 2
2929
PASS length.valueInSpecifiedUnits is 2

0 commit comments

Comments
 (0)