| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h" | 5 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptController.h" | 8 #include "bindings/core/v8/ScriptController.h" |
| 9 #include "bindings/core/v8/ScriptSourceCode.h" | 9 #include "bindings/core/v8/ScriptSourceCode.h" |
| 10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 V8TestingScope& scope, | 56 V8TestingScope& scope, |
| 57 ExceptionState* overrideExceptionState = nullptr, | 57 ExceptionState* overrideExceptionState = nullptr, |
| 58 Transferables* transferables = nullptr, | 58 Transferables* transferables = nullptr, |
| 59 WebBlobInfoArray* blobInfo = nullptr) { | 59 WebBlobInfoArray* blobInfo = nullptr) { |
| 60 RefPtr<ScriptState> scriptState = scope.getScriptState(); | 60 RefPtr<ScriptState> scriptState = scope.getScriptState(); |
| 61 ExceptionState& exceptionState = overrideExceptionState | 61 ExceptionState& exceptionState = overrideExceptionState |
| 62 ? *overrideExceptionState | 62 ? *overrideExceptionState |
| 63 : scope.getExceptionState(); | 63 : scope.getExceptionState(); |
| 64 | 64 |
| 65 // Extract message ports and disentangle them. | 65 // Extract message ports and disentangle them. |
| 66 std::unique_ptr<MessagePortChannelArray> channels; | 66 MessagePortChannelArray channels; |
| 67 if (transferables) { | 67 if (transferables) { |
| 68 channels = MessagePort::disentanglePorts(scope.getExecutionContext(), | 68 channels = MessagePort::disentanglePorts(scope.getExecutionContext(), |
| 69 transferables->messagePorts, | 69 transferables->messagePorts, |
| 70 exceptionState); | 70 exceptionState); |
| 71 if (exceptionState.hadException()) | 71 if (exceptionState.hadException()) |
| 72 return v8::Local<v8::Value>(); | 72 return v8::Local<v8::Value>(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 V8ScriptValueSerializer serializer(scriptState); | 75 V8ScriptValueSerializer serializer(scriptState); |
| 76 serializer.setBlobInfoArray(blobInfo); | 76 serializer.setBlobInfoArray(blobInfo); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ImageData* newImageData = V8ImageData::toImpl(result.As<v8::Object>()); | 232 ImageData* newImageData = V8ImageData::toImpl(result.As<v8::Object>()); |
| 233 EXPECT_EQ(IntSize(2, 1), newImageData->size()); | 233 EXPECT_EQ(IntSize(2, 1), newImageData->size()); |
| 234 EXPECT_EQ(8u, newImageData->data()->length()); | 234 EXPECT_EQ(8u, newImageData->data()->length()); |
| 235 EXPECT_EQ(200, newImageData->data()->data()[0]); | 235 EXPECT_EQ(200, newImageData->data()->data()[0]); |
| 236 } | 236 } |
| 237 | 237 |
| 238 class WebMessagePortChannelImpl final : public WebMessagePortChannel { | 238 class WebMessagePortChannelImpl final : public WebMessagePortChannel { |
| 239 public: | 239 public: |
| 240 // WebMessagePortChannel | 240 // WebMessagePortChannel |
| 241 void setClient(WebMessagePortChannelClient* client) override {} | 241 void setClient(WebMessagePortChannelClient* client) override {} |
| 242 void destroy() override { delete this; } | 242 void postMessage(const WebString&, WebMessagePortChannelArray) { |
| 243 void postMessage(const WebString&, WebMessagePortChannelArray*) { | |
| 244 NOTIMPLEMENTED(); | 243 NOTIMPLEMENTED(); |
| 245 } | 244 } |
| 246 bool tryGetMessage(WebString*, WebMessagePortChannelArray&) { return false; } | 245 bool tryGetMessage(WebString*, WebMessagePortChannelArray&) { return false; } |
| 247 }; | 246 }; |
| 248 | 247 |
| 249 MessagePort* makeMessagePort( | 248 MessagePort* makeMessagePort( |
| 250 ExecutionContext* executionContext, | 249 ExecutionContext* executionContext, |
| 251 WebMessagePortChannel** unownedChannelOut = nullptr) { | 250 WebMessagePortChannel** unownedChannelOut = nullptr) { |
| 252 auto* unownedChannel = new WebMessagePortChannelImpl(); | 251 auto* unownedChannel = new WebMessagePortChannelImpl(); |
| 253 MessagePort* port = MessagePort::create(*executionContext); | 252 MessagePort* port = MessagePort::create(*executionContext); |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 TEST(V8ScriptValueSerializerTest, DecodeHardcodedNullValue) { | 1033 TEST(V8ScriptValueSerializerTest, DecodeHardcodedNullValue) { |
| 1035 V8TestingScope scope; | 1034 V8TestingScope scope; |
| 1036 EXPECT_TRUE(V8ScriptValueDeserializer(scope.getScriptState(), | 1035 EXPECT_TRUE(V8ScriptValueDeserializer(scope.getScriptState(), |
| 1037 SerializedScriptValue::nullValue()) | 1036 SerializedScriptValue::nullValue()) |
| 1038 .deserialize() | 1037 .deserialize() |
| 1039 ->IsNull()); | 1038 ->IsNull()); |
| 1040 } | 1039 } |
| 1041 | 1040 |
| 1042 } // namespace | 1041 } // namespace |
| 1043 } // namespace blink | 1042 } // namespace blink |
| OLD | NEW |