An EventSource constructor should throw TypeError, when the number of arguments is not enough.

https://bugs.webkit.org/show_bug.cgi?id=66454

Patch by Kentaro Hara <haraken@google.com> on 2011-08-18
Reviewed by Adam Barth.

The spec is here: http://www.w3.org/TR/WebIDL/#es-operations.

Source/WebCore:

Test: fast/eventsource/eventsource-constructor.html

* bindings/js/JSEventSourceCustom.cpp:
(WebCore::JSEventSourceConstructor::constructJSEventSource): Changed SyntaxError to TypeError.
* bindings/v8/custom/V8EventSourceConstructor.cpp:
(WebCore::V8EventSource::constructorCallback): Changed SyntaxError to TypeError.

LayoutTests:

* fast/eventsource/eventsource-constructor-expected.txt: Changed SyntaxError to TypeError.

git-svn-id: svn://svn.chromium.org/blink/trunk@93340 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 052f2a01
2011-08-18 Kentaro Hara <haraken@google.com>
An EventSource constructor should throw TypeError, when the number of arguments is not enough.
https://bugs.webkit.org/show_bug.cgi?id=66454
Reviewed by Adam Barth.
The spec is here: http://www.w3.org/TR/WebIDL/#es-operations.
* fast/eventsource/eventsource-constructor-expected.txt: Changed SyntaxError to TypeError.
2011-08-18 Kentaro Hara <haraken@google.com> 2011-08-18 Kentaro Hara <haraken@google.com>
A SharedWorker constructor should throw TypeError, when the number of arguments is not enough. A SharedWorker constructor should throw TypeError, when the number of arguments is not enough.
Test EventSource constructor functionality. Should print a series of PASS messages followed by DONE. Test EventSource constructor functionality. Should print a series of PASS messages followed by DONE.
PASS: missing argument to EventSource constructor resulted in an exception (SyntaxError: Not enough arguments) PASS: missing argument to EventSource constructor resulted in an exception (TypeError: Not enough arguments)
PASS: passing an empty string to the EventSource constructor resulted in an exception (Error: SYNTAX_ERR: DOM Exception 12) PASS: passing an empty string to the EventSource constructor resulted in an exception (Error: SYNTAX_ERR: DOM Exception 12)
PASS: passing an invalid URL to the EventSource constructor resulted in an exception (Error: SYNTAX_ERR: DOM Exception 12) PASS: passing an invalid URL to the EventSource constructor resulted in an exception (Error: SYNTAX_ERR: DOM Exception 12)
DONE DONE
......
2011-08-18 Kentaro Hara <haraken@google.com>
An EventSource constructor should throw TypeError, when the number of arguments is not enough.
https://bugs.webkit.org/show_bug.cgi?id=66454
Reviewed by Adam Barth.
The spec is here: http://www.w3.org/TR/WebIDL/#es-operations.
Test: fast/eventsource/eventsource-constructor.html
* bindings/js/JSEventSourceCustom.cpp:
(WebCore::JSEventSourceConstructor::constructJSEventSource): Changed SyntaxError to TypeError.
* bindings/v8/custom/V8EventSourceConstructor.cpp:
(WebCore::V8EventSource::constructorCallback): Changed SyntaxError to TypeError.
2011-08-18 Kentaro Hara <haraken@google.com> 2011-08-18 Kentaro Hara <haraken@google.com>
A SharedWorker constructor should throw TypeError, when the number of arguments is not enough. A SharedWorker constructor should throw TypeError, when the number of arguments is not enough.
...@@ -47,7 +47,7 @@ namespace WebCore { ...@@ -47,7 +47,7 @@ namespace WebCore {
EncodedJSValue JSC_HOST_CALL JSEventSourceConstructor::constructJSEventSource(ExecState* exec) EncodedJSValue JSC_HOST_CALL JSEventSourceConstructor::constructJSEventSource(ExecState* exec)
{ {
if (exec->argumentCount() < 1) if (exec->argumentCount() < 1)
return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
UString url = exec->argument(0).toString(exec); UString url = exec->argument(0).toString(exec);
if (exec->hadException()) if (exec->hadException())
......
...@@ -56,7 +56,7 @@ v8::Handle<v8::Value> V8EventSource::constructorCallback(const v8::Arguments& ar ...@@ -56,7 +56,7 @@ v8::Handle<v8::Value> V8EventSource::constructorCallback(const v8::Arguments& ar
if (!context) if (!context)
return throwError("EventSource constructor's associated context is not available", V8Proxy::ReferenceError); return throwError("EventSource constructor's associated context is not available", V8Proxy::ReferenceError);
if (args.Length() != 1) if (args.Length() != 1)
return throwError("Not enough arguments", V8Proxy::SyntaxError); return throwError("Not enough arguments", V8Proxy::TypeError);
ExceptionCode ec = 0; ExceptionCode ec = 0;
String url = toWebCoreString(args[0]); String url = toWebCoreString(args[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment