Changeset 61390 in webkit


Ignore:
Timestamp:
Jun 18, 2010 2:31:34 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-06-18 Adam Barth <abarth@webkit.org>

Reviewed by Darin Adler.

Remove unneeded custom code for WebSocket.send
https://bugs.webkit.org/show_bug.cgi?id=38180

We don't appear to require a custom binding here. The old function was
wacky in two ways:

1) It required all of its arguments.

2) If the toString of its argument threw, it would catch the exception

and re-throw a different exception.

I've kept the first behavior but changed the second (and documented it
with a test).

Test: websocket/tests/send-throw.html

  • bindings/js/JSWebSocketCustom.cpp:
  • bindings/v8/custom/V8WebSocketCustom.cpp:
  • websockets/WebSocket.idl:

2010-06-18 Adam Barth <abarth@webkit.org>

Reviewed by Darin Adler.

Remove unneeded custom code for WebSocket.send
https://bugs.webkit.org/show_bug.cgi?id=38180

Test what happens when you pass an object to WebSocket.send that throws
when you convert it to a string.

  • websocket/tests/script-tests/send-throw.js: Added. (endTest): (FIRST_MESSAGE_TO_SEND.toString): (ws.onopen): (ws.onclose): (timeOutCallback):
  • websocket/tests/send-throw-expected.txt: Added.
  • websocket/tests/send-throw.html: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r61387 r61390  
     12010-06-18  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Remove unneeded custom code for WebSocket.send
     6        https://bugs.webkit.org/show_bug.cgi?id=38180
     7
     8        Test what happens when you pass an object to WebSocket.send that throws
     9        when you convert it to a string.
     10
     11        * websocket/tests/script-tests/send-throw.js: Added.
     12        (endTest):
     13        (FIRST_MESSAGE_TO_SEND.toString):
     14        (ws.onopen):
     15        (ws.onclose):
     16        (timeOutCallback):
     17        * websocket/tests/send-throw-expected.txt: Added.
     18        * websocket/tests/send-throw.html: Added.
     19
    1202010-06-18  Nikolas Zimmermann  <nzimmermann@rim.com>
    221
  • trunk/WebCore/ChangeLog

    r61388 r61390  
     12010-06-18  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Remove unneeded custom code for WebSocket.send
     6        https://bugs.webkit.org/show_bug.cgi?id=38180
     7
     8        We don't appear to require a custom binding here.  The old function was
     9        wacky in two ways:
     10
     11        1) It required all of its arguments.
     12
     13        2) If the toString of its argument threw, it would catch the exception
     14           and re-throw a different exception.
     15
     16        I've kept the first behavior but changed the second (and documented it
     17        with a test).
     18
     19        Test: websocket/tests/send-throw.html
     20
     21        * bindings/js/JSWebSocketCustom.cpp:
     22        * bindings/v8/custom/V8WebSocketCustom.cpp:
     23        * websockets/WebSocket.idl:
     24
    1252010-06-15  Dumitru Daniliuc  <dumi@chromium.org>
    226
  • trunk/WebCore/bindings/js/JSWebSocketCustom.cpp

    r61136 r61390  
    4545namespace WebCore {
    4646
    47 // Custom functions
    48 JSValue JSWebSocket::send(ExecState* exec)
    49 {
    50     if (exec->argumentCount() < 1)
    51         return throwError(exec, createSyntaxError(exec, "Not enough arguments"));
    52 
    53     const String& msg = ustringToString(exec->argument(0).toString(exec));
    54     if (exec->hadException())
    55         return throwError(exec, createSyntaxError(exec, "bad message data."));
    56     ExceptionCode ec = 0;
    57     JSValue ret = jsBoolean(impl()->send(msg, ec));
    58     setDOMException(exec, ec);
    59     return ret;
    60 }
    61 
    6247EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecState* exec)
    6348{
  • trunk/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp

    r55798 r61390  
    9494}
    9595
    96 v8::Handle<v8::Value> V8WebSocket::sendCallback(const v8::Arguments& args)
    97 {
    98     INC_STATS("DOM.WebSocket.send()");
    99     WebSocket* webSocket = V8WebSocket::toNative(args.Holder());
    100 
    101     ExceptionCode ec = 0;
    102     bool ret = false;
    103     if (args.Length() < 1)
    104         return throwError("Not enough arguments", V8Proxy::SyntaxError);
    105     else {
    106         String msg = toWebCoreString(args[0]);
    107         ret = webSocket->send(msg, ec);
    108     }
    109     if (ec)
    110         return throwError(ec);
    111     return v8Boolean(ret);
    112 }
    113 
    11496}  // namespace WebCore
    11597
  • trunk/WebCore/websockets/WebSocket.idl

    r61136 r61390  
    5757        attribute EventListener onclose;
    5858
    59         [Custom] boolean send(in DOMString data)
    60           raises(DOMException);
     59        [RequiresAllArguments] boolean send(in DOMString data) raises(DOMException);
    6160        void close();
    6261
Note: See TracChangeset for help on using the changeset viewer.