diff --git a/core/core.js b/core/core.js index 9a969e411..969e935e9 100644 --- a/core/core.js +++ b/core/core.js @@ -1,6 +1,5 @@ "use strict"; - require("encoding-indexes"); require("encoding"); diff --git a/src/Serialize.cpp b/src/Serialize.cpp index 33d8c01dd..3b70c87c5 100644 --- a/src/Serialize.cpp +++ b/src/Serialize.cpp @@ -82,9 +82,9 @@ bool Serialize::storeInternal(Task* task, std::vector& buffer, v8::Handle< buffer.insert(buffer.end(), *utf8, *utf8 + utf8.length()); } else if (value->IsUint8Array()) { writeInt32(buffer, kUint8Array); - v8::Handle array = v8::Handle::Cast(value); - char* data = reinterpret_cast(array->GetContents().Data()); - size_t length = array->GetContents().ByteLength(); + v8::Handle array = v8::Handle::Cast(value); + char* data = reinterpret_cast(array->Buffer()->GetContents().Data()); + size_t length = array->Buffer()->GetContents().ByteLength(); writeInt32(buffer, length); buffer.insert(buffer.end(), data, data + length); } else if (value->IsArray()) { diff --git a/src/Socket.h b/src/Socket.h index f7dc37d19..fdb627bcc 100644 --- a/src/Socket.h +++ b/src/Socket.h @@ -1,6 +1,7 @@ #ifndef INCLUDED_Socket #define INCLUDED_Socket +#include #include #include #include diff --git a/src/Task.cpp b/src/Task.cpp index cd678d176..2dad3f92d 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -676,9 +676,20 @@ void Task::onReceivePacket(int packetType, const char* begin, size_t length, voi tryCatch.SetVerbose(true); v8::Handle value = Serialize::load(to, from, std::vector(begin + sizeof(promiseid_t), begin + length)); v8::Handle object = v8::Handle::Cast(value); - v8::Handle source = v8::Handle::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "source"))); + v8::Handle source = v8::Handle::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "source"))); + v8::Handle stringSource; + if (source->IsArrayBufferView()) { + v8::Handle array = v8::Handle::Cast(source); + stringSource = v8::String::NewFromUtf8( + to->_isolate, + reinterpret_cast(array->Buffer()->GetContents().Data()), + v8::String::kNormalString, + array->Buffer()->GetContents().ByteLength()); + } else if (source->IsString()) { + stringSource = v8::Handle::Cast(source); + } v8::Handle name = v8::Handle::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "name"))); - to->executeSource(source, name); + to->executeSource(stringSource, name); if (tryCatch.HasCaught()) { sendPromiseReject(to, from, promise, Serialize::store(to, tryCatch)); }