Changeset 101118 in webkit


Ignore:
Timestamp:
Nov 23, 2011 9:14:24 PM (12 years ago)
Author:
dslomov@google.com
Message:

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=73054
[V8][Chromium] Add list of transferred ArrayBuffers to SerializedScriptValue::create.

Reviewed by David Levin.

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateParametersCheck):

  • bindings/scripts/test/V8/V8TestObj.cpp:

(WebCore::TestObjInternal::serializedValueCallback):

  • bindings/v8/OptionsObject.cpp:
  • bindings/v8/SerializedScriptValue.cpp:

(WebCore::SerializedScriptValue::create):

  • bindings/v8/SerializedScriptValue.h:
  • bindings/v8/V8Utilities.cpp:

(WebCore::extractTransferables):
(WebCore::getMessagePortArray):

  • bindings/v8/V8Utilities.h:
  • bindings/v8/custom/V8DOMWindowCustom.cpp:

(WebCore::handlePostMessageCallback):

  • bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp:

(WebCore::handlePostMessageCallback):

  • bindings/v8/custom/V8HistoryCustom.cpp:

(WebCore::V8History::pushStateCallback):
(WebCore::V8History::replaceStateCallback):

  • bindings/v8/custom/V8MessageEventCustom.cpp:
  • bindings/v8/custom/V8MessagePortCustom.cpp:

(WebCore::handlePostMessageCallback):

  • bindings/v8/custom/V8MessagePortCustom.h: Removed.
  • bindings/v8/custom/V8WorkerCustom.cpp:

(WebCore::handlePostMessageCallback):

Source/WebKit/chromium: https://bugs.webkit.org/show_bug.cgi?id=73054
[V8][Chromium] Add list of transferred ArrayBuffers to SerializedScriptValue::create.

Reviewed by David Levin.

  • src/WebSerializedScriptValue.cpp:

(WebKit::WebSerializedScriptValue::serialize):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=73054
[V8][Chromium] Add list of transferred ArrayBuffers to SerializedScriptValue::create.
Tests rebaselined to reflect new error message.

Reviewed by David Levin.

  • platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:
  • platform/chromium/fast/events/constructors/message-event-constructor-expected.txt:
Location:
trunk
Files:
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r101114 r101118  
     12011-11-23  Dmitry Lomov  <dslomov@google.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=73054
     4        [V8][Chromium] Add list of transferred ArrayBuffers to SerializedScriptValue::create.
     5        Tests rebaselined to reflect new error message.
     6
     7        Reviewed by David Levin.
     8
     9        * platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:
     10        * platform/chromium/fast/events/constructors/message-event-constructor-expected.txt:
     11
    1122011-11-23  Joshua Bell  <jsbell@chromium.org>
    213
  • trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt

    r98175 r101118  
    11Test that the second argument of window.postMessage is ignored or triggers an error if it is not a message port. You should see PASS message '1' through '7', followed by 'done', with messages 4-7 received below.
    22
    3 PASS: Posting message ('1', 1): threw exception TypeError: MessagePortArray argument must be an object
    4 PASS: Posting message ('1', 1): threw exception TypeError: MessagePortArray argument must be an object
    5 PASS: Posting message ('2', ): threw exception TypeError: MessagePortArray argument must be an object
    6 PASS: Posting message ('2', ): threw exception TypeError: MessagePortArray argument must be an object
    7 PASS: Posting message ('3', [object Object]): threw exception TypeError: MessagePortArray argument has no length attribute
    8 PASS: Posting message ('3', [object Object]): threw exception TypeError: MessagePortArray argument has no length attribute
     3PASS: Posting message ('1', 1): threw exception TypeError: TransferArray argument must be an object
     4PASS: Posting message ('1', 1): threw exception TypeError: TransferArray argument must be an object
     5PASS: Posting message ('2', ): threw exception TypeError: TransferArray argument must be an object
     6PASS: Posting message ('2', ): threw exception TypeError: TransferArray argument must be an object
     7PASS: Posting message ('3', [object Object]): threw exception TypeError: TransferArray argument has no length attribute
     8PASS: Posting message ('3', [object Object]): threw exception TypeError: TransferArray argument has no length attribute
    99PASS: Posting message ('4', [object DOMWindow]) did not throw an exception
    1010PASS: Posting message ('4', [object DOMWindow]) did not throw an exception
  • trunk/LayoutTests/platform/chromium/fast/events/constructors/message-event-constructor-expected.txt

    r97955 r101118  
    8181PASS new MessageEvent('eventType', { ports: undefined }).ports is []
    8282PASS new MessageEvent('eventType', { ports: null }).ports is []
    83 PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: MessagePortArray argument must contain only MessagePorts.
    84 PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: MessagePortArray argument has no length attribute.
    85 PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: MessagePortArray argument has no length attribute.
    86 PASS new MessageEvent('eventType', { ports: false }).ports threw exception TypeError: MessagePortArray argument must be an object.
    87 PASS new MessageEvent('eventType', { ports: true }).ports threw exception TypeError: MessagePortArray argument must be an object.
    88 PASS new MessageEvent('eventType', { ports: '' }).ports threw exception TypeError: MessagePortArray argument must be an object.
    89 PASS new MessageEvent('eventType', { ports: 'chocolate' }).ports threw exception TypeError: MessagePortArray argument must be an object.
    90 PASS new MessageEvent('eventType', { ports: 12345 }).ports threw exception TypeError: MessagePortArray argument must be an object.
    91 PASS new MessageEvent('eventType', { ports: 18446744073709551615 }).ports threw exception TypeError: MessagePortArray argument must be an object.
    92 PASS new MessageEvent('eventType', { ports: NaN }).ports threw exception TypeError: MessagePortArray argument must be an object.
    93 PASS new MessageEvent('eventType', { get ports() { return 123; } }).ports threw exception TypeError: MessagePortArray argument must be an object.
     83PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: TransferArray argument must contain only Transferables.
     84PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: TransferArray argument has no length attribute.
     85PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: TransferArray argument has no length attribute.
     86PASS new MessageEvent('eventType', { ports: false }).ports threw exception TypeError: TransferArray argument must be an object.
     87PASS new MessageEvent('eventType', { ports: true }).ports threw exception TypeError: TransferArray argument must be an object.
     88PASS new MessageEvent('eventType', { ports: '' }).ports threw exception TypeError: TransferArray argument must be an object.
     89PASS new MessageEvent('eventType', { ports: 'chocolate' }).ports threw exception TypeError: TransferArray argument must be an object.
     90PASS new MessageEvent('eventType', { ports: 12345 }).ports threw exception TypeError: TransferArray argument must be an object.
     91PASS new MessageEvent('eventType', { ports: 18446744073709551615 }).ports threw exception TypeError: TransferArray argument must be an object.
     92PASS new MessageEvent('eventType', { ports: NaN }).ports threw exception TypeError: TransferArray argument must be an object.
     93PASS new MessageEvent('eventType', { get ports() { return 123; } }).ports threw exception TypeError: TransferArray argument must be an object.
    9494PASS new MessageEvent('eventType', { get ports() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
    95 PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: MessagePortArray argument has no length attribute.
     95PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: TransferArray argument has no length attribute.
    9696PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).bubbles is true
    9797PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).cancelable is true
  • trunk/Source/WebCore/ChangeLog

    r101117 r101118  
     12011-11-23  Dmitry Lomov  <dslomov@google.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=73054
     4        [V8][Chromium] Add list of transferred ArrayBuffers to SerializedScriptValue::create.
     5
     6        Reviewed by David Levin.
     7
     8        * bindings/scripts/CodeGeneratorV8.pm:
     9        (GenerateParametersCheck):
     10        * bindings/scripts/test/V8/V8TestObj.cpp:
     11        (WebCore::TestObjInternal::serializedValueCallback):
     12       * bindings/v8/OptionsObject.cpp:
     13        * bindings/v8/SerializedScriptValue.cpp:
     14        (WebCore::SerializedScriptValue::create):
     15        * bindings/v8/SerializedScriptValue.h:
     16        * bindings/v8/V8Utilities.cpp:
     17        (WebCore::extractTransferables):
     18        (WebCore::getMessagePortArray):
     19        * bindings/v8/V8Utilities.h:
     20        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     21        (WebCore::handlePostMessageCallback):
     22        * bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp:
     23        (WebCore::handlePostMessageCallback):
     24        * bindings/v8/custom/V8HistoryCustom.cpp:
     25        (WebCore::V8History::pushStateCallback):
     26        (WebCore::V8History::replaceStateCallback):
     27        * bindings/v8/custom/V8MessageEventCustom.cpp:
     28        * bindings/v8/custom/V8MessagePortCustom.cpp:
     29        (WebCore::handlePostMessageCallback):
     30        * bindings/v8/custom/V8MessagePortCustom.h: Removed.
     31        * bindings/v8/custom/V8WorkerCustom.cpp:
     32        (WebCore::handlePostMessageCallback):
     33
    1342011-11-23  Rafael Weinstein  <rafaelw@chromium.org>
    235
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r101102 r101118  
    14731473            AddToImplIncludes("SerializedScriptValue.h");
    14741474            $parameterCheckString .= "    bool ${parameterName}DidThrow = false;\n";
    1475             $parameterCheckString .= "    $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], 0, ${parameterName}DidThrow);\n";
     1475            $parameterCheckString .= "    $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow);\n";
    14761476            $parameterCheckString .= "    if (${parameterName}DidThrow)\n";
    14771477            $parameterCheckString .= "        return v8::Undefined();\n";
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r101102 r101118  
    800800    TestObj* imp = V8TestObj::toNative(args.Holder());
    801801    bool serializedArgDidThrow = false;
    802     RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], 0, serializedArgDidThrow);
     802    RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], 0, 0, serializedArgDidThrow);
    803803    if (serializedArgDidThrow)
    804804        return v8::Undefined();
  • trunk/Source/WebCore/bindings/v8/OptionsObject.cpp

    r99992 r101118  
    3030#include "V8Binding.h"
    3131#include "V8DOMWindow.h"
    32 #include "V8MessagePortCustom.h"
     32#include "V8Utilities.h"
    3333#include <wtf/MathExtras.h>
    3434
  • trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp

    r100239 r101118  
    19891989}
    19901990
    1991 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value, MessagePortArray* messagePorts, bool& didThrow)
     1991PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value,
     1992                                                                MessagePortArray* messagePorts, ArrayBufferArray*,
     1993                                                                bool& didThrow)
    19921994{
    19931995    return adoptRef(new SerializedScriptValue(value, messagePorts, didThrow));
  • trunk/Source/WebCore/bindings/v8/SerializedScriptValue.h

    r99229 r101118  
    3636#include <wtf/Threading.h>
    3737
     38namespace WTF {
     39class ArrayBuffer;
     40}
     41
    3842namespace WebCore {
    3943
     
    4145
    4246typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
     47typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray;
    4348
    4449class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> {
     
    5459    // the caller must not invoke any V8 operations until control returns to
    5560    // V8. When serialization is successful, |didThrow| is false.
    56     static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, MessagePortArray*, bool& didThrow);
     61    static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>,
     62                                                    MessagePortArray*, ArrayBufferArray*,
     63                                                    bool& didThrow);
    5764    static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>);
    5865    static PassRefPtr<SerializedScriptValue> createFromWire(const String& data);
  • trunk/Source/WebCore/bindings/v8/V8Utilities.cpp

    r95901 r101118  
    3232#include "V8Utilities.h"
    3333
    34 #include <v8.h>
    35 
     34#include "ArrayBuffer.h"
    3635#include "Document.h"
     36#include "ExceptionCode.h"
    3737#include "Frame.h"
     38#include "MessagePort.h"
    3839#include "ScriptExecutionContext.h"
    3940#include "ScriptState.h"
     41#include "V8ArrayBuffer.h"
    4042#include "V8Binding.h"
    4143#include "V8BindingState.h"
     44#include "V8MessagePort.h"
    4245#include "V8Proxy.h"
    4346#include "WorkerContext.h"
     
    4649#include <wtf/Assertions.h>
    4750#include "Frame.h"
     51
     52#include <v8.h>
    4853
    4954namespace WebCore {
     
    7580    v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache);
    7681    cacheArray->Set(v8::Integer::New(cacheArray->Length()), value);
     82}
     83
     84bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, ArrayBufferArray& arrayBuffers)
     85{
     86    if (isUndefinedOrNull(value)) {
     87        ports.resize(0);
     88        arrayBuffers.resize(0);
     89        return true;
     90    }
     91
     92    if (!value->IsObject()) {
     93        throwError("TransferArray argument must be an object");
     94        return false;
     95    }
     96    uint32_t length = 0;
     97    v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
     98
     99    if (value->IsArray()) {
     100        v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
     101        length = array->Length();
     102    } else {
     103        // Sequence-type object - get the length attribute
     104        v8::Local<v8::Value> sequenceLength = transferrables->Get(v8::String::New("length"));
     105        if (!sequenceLength->IsNumber()) {
     106            throwError("TransferArray argument has no length attribute");
     107            return false;
     108        }
     109        length = sequenceLength->Uint32Value();
     110    }
     111
     112    // Validate the passed array of transferrables.
     113    for (unsigned int i = 0; i < length; ++i) {
     114        v8::Local<v8::Value> transferrable = transferrables->Get(i);
     115        // Validation of non-null objects, per HTML5 spec 10.3.3.
     116        if (isUndefinedOrNull(transferrable)) {
     117            throwError(DATA_CLONE_ERR);
     118            return false;
     119        }
     120        // Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
     121        if (V8MessagePort::HasInstance(transferrable))
     122            ports.append(V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable)));
     123        else if (V8ArrayBuffer::HasInstance(transferrable))
     124            arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable)));
     125        else {
     126            throwError("TransferArray argument must contain only Transferables");
     127            return false;
     128        }
     129    }
     130    return true;
     131}
     132
     133bool getMessagePortArray(v8::Local<v8::Value> value, MessagePortArray& ports)
     134{
     135    ArrayBufferArray arrayBuffers;
     136    bool result = extractTransferables(value, ports, arrayBuffers);
     137    if (!result)
     138        return false;
     139    if (arrayBuffers.size() > 0) {
     140        throwError("MessagePortArray argument must contain only MessagePorts");
     141        return false;
     142    }
     143    return true;
    77144}
    78145
  • trunk/Source/WebCore/bindings/v8/V8Utilities.h

    r95901 r101118  
    3737#include "OwnHandle.h"
    3838
     39namespace WTF {
     40class ArrayBuffer;
     41}
     42
    3943namespace WebCore {
    4044
     
    4246    class Frame;
    4347    class KURL;
     48    class MessagePort;
    4449    class ScriptExecutionContext;
    4550    class ScriptState;
     
    7580    };
    7681
     82    typedef WTF::Vector<RefPtr<MessagePort>, 1> MessagePortArray;
     83    typedef WTF::Vector<RefPtr<ArrayBuffer>, 1> ArrayBufferArray;
     84
     85    // Helper function which pulls the values out of a JS sequence and into a MessagePortArray.
     86    // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3
     87    // of the HTML5 spec and generates exceptions as appropriate.
     88    // Returns true if the array was filled, or false if the passed value was not of an appropriate type.
     89    bool extractTransferables(v8::Local<v8::Value>, MessagePortArray&, ArrayBufferArray&);
     90    bool getMessagePortArray(v8::Local<v8::Value>, MessagePortArray&);
     91
    7792    // 'FunctionOnly' is assumed for the created callback.
    7893    template <typename V8CallbackType>
  • trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r100740 r101118  
    3232#include "V8DOMWindow.h"
    3333
     34#include "ArrayBuffer.h"
    3435#include "Chrome.h"
    3536#include "ContentSecurityPolicy.h"
     
    4344#include "HTMLDocument.h"
    4445#include "MediaPlayer.h"
     46#include "MessagePort.h"
    4547#include "Page.h"
    4648#include "PlatformScreen.h"
     
    5860#include "V8HiddenPropertyName.h"
    5961#include "V8HTMLCollection.h"
    60 #include "V8MessagePortCustom.h"
    6162#include "V8Node.h"
    6263#include "V8Proxy.h"
     
    298299    //   postMessage(message, targetOrigin);
    299300    MessagePortArray portArray;
     301    ArrayBufferArray arrayBufferArray;
    300302    String targetOrigin;
    301303    {
    302304        v8::TryCatch tryCatch;
    303305        if (args.Length() > 2) {
    304             if (!getMessagePortArray(args[1], portArray))
     306            if (!extractTransferables(args[1], portArray, arrayBufferArray))
    305307                return v8::Undefined();
    306308            targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
     
    314316
    315317    bool didThrow = false;
    316     RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], doTransfer ? &portArray : 0, didThrow);
     318    RefPtr<SerializedScriptValue> message =
     319        SerializedScriptValue::create(args[0],
     320                                      doTransfer ? &portArray : 0,
     321                                      doTransfer ? &arrayBufferArray : 0,
     322                                      didThrow);
    317323    if (didThrow)
    318324        return v8::Undefined();
  • trunk/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp

    r97516 r101118  
    3434#include "V8DedicatedWorkerContext.h"
    3535
     36#include "ArrayBuffer.h"
    3637#include "DedicatedWorkerContext.h"
    3738#include "WorkerContextExecutionProxy.h"
    3839#include "V8Binding.h"
    39 #include "V8MessagePortCustom.h"
    4040#include "V8Proxy.h"
     41#include "V8Utilities.h"
    4142#include "V8WorkerContextEventListener.h"
    4243
     
    4647{
    4748    DedicatedWorkerContext* workerContext = V8DedicatedWorkerContext::toNative(args.Holder());
    48     MessagePortArray portArray;
     49    MessagePortArray ports;
     50    ArrayBufferArray arrayBuffers;
    4951    if (args.Length() > 1) {
    50         if (!getMessagePortArray(args[1], portArray))
     52        if (!extractTransferables(args[1], ports, arrayBuffers))
    5153            return v8::Undefined();
    5254    }
    5355    bool didThrow = false;
    54     RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], doTransfer ? &portArray : 0, didThrow);
     56    RefPtr<SerializedScriptValue> message =
     57        SerializedScriptValue::create(args[0],
     58                                      doTransfer ? &ports : 0,
     59                                      doTransfer ? &arrayBuffers : 0,
     60                                      didThrow);
    5561    if (didThrow)
    5662        return v8::Undefined();
    57      ExceptionCode ec = 0;
    58     workerContext->postMessage(message.release(), &portArray, ec);
     63    ExceptionCode ec = 0;
     64    workerContext->postMessage(message.release(), &ports, ec);
    5965    return throwError(ec);
    6066}
  • trunk/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp

    r97516 r101118  
    4545{
    4646    bool didThrow = false;
    47     RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, didThrow);
     47    RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, 0, didThrow);
    4848    if (didThrow)
    4949        return v8::Undefined();
     
    6969{
    7070    bool didThrow = false;
    71     RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, didThrow);
     71    RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, 0, didThrow);
    7272    if (didThrow)
    7373        return v8::Undefined();
  • trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp

    r98934 r101118  
    4040#include "V8DOMWindow.h"
    4141#include "V8MessagePort.h"
    42 #include "V8MessagePortCustom.h"
    4342#include "V8Proxy.h"
    4443
  • trunk/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp

    r97516 r101118  
    3131#include "config.h"
    3232
     33#include "ArrayBuffer.h"
    3334#include "ExceptionCode.h"
    3435#include "MessagePort.h"
    3536#include "SerializedScriptValue.h"
    3637#include "V8Binding.h"
    37 #include "V8MessagePortCustom.h"
    3838#include "V8MessagePort.h"
    3939#include "V8Proxy.h"
     
    4747    MessagePort* messagePort = V8MessagePort::toNative(args.Holder());
    4848    MessagePortArray portArray;
     49    ArrayBufferArray arrayBufferArray;
    4950    if (args.Length() > 1) {
    50         if (!getMessagePortArray(args[1], portArray))
     51        if (!extractTransferables(args[1], portArray, arrayBufferArray))
    5152            return v8::Undefined();
    5253    }
    5354    bool didThrow = false;
    54     RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], doTransfer ? &portArray : 0, didThrow);
     55    RefPtr<SerializedScriptValue> message =
     56        SerializedScriptValue::create(args[0],
     57                                      doTransfer ? &portArray : 0,
     58                                      doTransfer ? &arrayBufferArray : 0,
     59                                      didThrow);
    5560    if (didThrow)
    5661        return v8::Undefined();
     
    7277}
    7378
    74 bool getMessagePortArray(v8::Local<v8::Value> value, MessagePortArray& portArray)
    75 {
    76     if (isUndefinedOrNull(value)) {
    77         portArray.resize(0);
    78         return true;
    79     }
    80 
    81     if (!value->IsObject()) {
    82         throwError("MessagePortArray argument must be an object");
    83         return false;
    84     }
    85     uint32_t length = 0;
    86     v8::Local<v8::Object> ports = v8::Local<v8::Object>::Cast(value);
    87 
    88     if (value->IsArray()) {
    89         v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
    90         length = array->Length();
    91     } else {
    92         // Sequence-type object - get the length attribute
    93         v8::Local<v8::Value> sequenceLength = ports->Get(v8::String::New("length"));
    94         if (!sequenceLength->IsNumber()) {
    95             throwError("MessagePortArray argument has no length attribute");
    96             return false;
    97         }
    98         length = sequenceLength->Uint32Value();
    99     }
    100 
    101     // Validate the passed array of ports.
    102     for (unsigned int i = 0; i < length; ++i) {
    103         v8::Local<v8::Value> port = ports->Get(i);
    104         // Validation of non-null objects, per HTML5 spec 10.3.3.
    105         if (isUndefinedOrNull(port)) {
    106             throwError(DATA_CLONE_ERR);
    107             return false;
    108         }
    109         // Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
    110         if (!V8MessagePort::HasInstance(port)) {
    111             throwError("MessagePortArray argument must contain only MessagePorts");
    112             return false;
    113         }
    114         portArray.append(V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(port)));
    115     }
    116     return true;
    117 }
    118 
    11979} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp

    r97516 r101118  
    3636#include "Worker.h"
    3737
     38#include "ArrayBuffer.h"
    3839#include "ExceptionCode.h"
    3940#include "Frame.h"
    4041#include "SerializedScriptValue.h"
    4142#include "V8Binding.h"
    42 #include "V8MessagePortCustom.h"
    4343#include "V8Proxy.h"
    4444#include "V8Utilities.h"
     
    5252    INC_STATS("DOM.Worker.postMessage");
    5353    Worker* worker = V8Worker::toNative(args.Holder());
    54     MessagePortArray portArray;
     54    MessagePortArray ports;
     55    ArrayBufferArray arrayBuffers;
    5556    if (args.Length() > 1) {
    56         if (!getMessagePortArray(args[1], portArray))
     57        if (!extractTransferables(args[1], ports, arrayBuffers))
    5758            return v8::Undefined();
    5859    }
    5960    bool didThrow = false;
    60     RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(args[0], doTransfer ? &portArray : 0, didThrow);
     61    RefPtr<SerializedScriptValue> message =
     62        SerializedScriptValue::create(args[0],
     63                                      doTransfer ? &ports : 0,
     64                                      doTransfer ? &arrayBuffers : 0,
     65                                      didThrow);
    6166    if (didThrow)
    6267        return v8::Undefined();
    6368    ExceptionCode ec = 0;
    64     worker->postMessage(message.release(), &portArray, ec);
     69    worker->postMessage(message.release(), &ports, ec);
    6570    return throwError(ec);
    6671}
  • trunk/Source/WebKit/chromium/ChangeLog

    r101115 r101118  
     12011-11-23  Dmitry Lomov  <dslomov@google.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=73054
     4        [V8][Chromium] Add list of transferred ArrayBuffers to SerializedScriptValue::create.
     5
     6        Reviewed by David Levin.
     7
     8        * src/WebSerializedScriptValue.cpp:
     9        (WebKit::WebSerializedScriptValue::serialize):
     10
    1112011-11-23  Ami Fischman  <fischman@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/WebSerializedScriptValue.cpp

    r97516 r101118  
    4848{
    4949    bool didThrow;
    50     WebSerializedScriptValue serializedValue = SerializedScriptValue::create(value, 0, didThrow);
     50    WebSerializedScriptValue serializedValue = SerializedScriptValue::create(value, 0, 0, didThrow);
    5151    if (didThrow)
    5252        return createInvalid();
Note: See TracChangeset for help on using the changeset viewer.