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/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // Check also that the underlying image contents were transferred. | 508 // Check also that the underlying image contents were transferred. |
509 EXPECT_EQ(image, newImage); | 509 EXPECT_EQ(image, newImage); |
510 EXPECT_TRUE(imageBitmap->isNeutered()); | 510 EXPECT_TRUE(imageBitmap->isNeutered()); |
511 } | 511 } |
512 | 512 |
513 TEST(V8ScriptValueSerializerTest, TransferOffscreenCanvas) { | 513 TEST(V8ScriptValueSerializerTest, TransferOffscreenCanvas) { |
514 // More exhaustive tests in LayoutTests/. This is a sanity check. | 514 // More exhaustive tests in LayoutTests/. This is a sanity check. |
515 ScopedEnableV8BasedStructuredClone enable; | 515 ScopedEnableV8BasedStructuredClone enable; |
516 V8TestingScope scope; | 516 V8TestingScope scope; |
517 OffscreenCanvas* canvas = OffscreenCanvas::create(10, 7); | 517 OffscreenCanvas* canvas = OffscreenCanvas::create(10, 7); |
518 canvas->setAssociatedCanvasId(519); | 518 canvas->setPlaceholderCanvasId(519); |
519 v8::Local<v8::Value> wrapper = toV8(canvas, scope.getScriptState()); | 519 v8::Local<v8::Value> wrapper = toV8(canvas, scope.getScriptState()); |
520 Transferables transferables; | 520 Transferables transferables; |
521 transferables.offscreenCanvases.append(canvas); | 521 transferables.offscreenCanvases.append(canvas); |
522 v8::Local<v8::Value> result = | 522 v8::Local<v8::Value> result = |
523 roundTrip(wrapper, scope, nullptr, &transferables); | 523 roundTrip(wrapper, scope, nullptr, &transferables); |
524 ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.isolate())); | 524 ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.isolate())); |
525 OffscreenCanvas* newCanvas = | 525 OffscreenCanvas* newCanvas = |
526 V8OffscreenCanvas::toImpl(result.As<v8::Object>()); | 526 V8OffscreenCanvas::toImpl(result.As<v8::Object>()); |
527 EXPECT_EQ(IntSize(10, 7), newCanvas->size()); | 527 EXPECT_EQ(IntSize(10, 7), newCanvas->size()); |
528 EXPECT_EQ(519, newCanvas->getAssociatedCanvasId()); | 528 EXPECT_EQ(519, newCanvas->placeholderCanvasId()); |
529 EXPECT_TRUE(canvas->isNeutered()); | 529 EXPECT_TRUE(canvas->isNeutered()); |
530 EXPECT_FALSE(newCanvas->isNeutered()); | 530 EXPECT_FALSE(newCanvas->isNeutered()); |
531 } | 531 } |
532 | 532 |
533 TEST(V8ScriptValueSerializerTest, RoundTripBlob) { | 533 TEST(V8ScriptValueSerializerTest, RoundTripBlob) { |
534 ScopedEnableV8BasedStructuredClone enable; | 534 ScopedEnableV8BasedStructuredClone enable; |
535 V8TestingScope scope; | 535 V8TestingScope scope; |
536 const char kHelloWorld[] = "Hello world!"; | 536 const char kHelloWorld[] = "Hello world!"; |
537 Blob* blob = | 537 Blob* blob = |
538 Blob::create(reinterpret_cast<const unsigned char*>(&kHelloWorld), | 538 Blob::create(reinterpret_cast<const unsigned char*>(&kHelloWorld), |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 newProxy->compositorMutableProperties()); | 1076 newProxy->compositorMutableProperties()); |
1077 } | 1077 } |
1078 | 1078 |
1079 // Decode tests aren't included here because they're slightly non-trivial (an | 1079 // Decode tests aren't included here because they're slightly non-trivial (an |
1080 // element with the right ID must actually exist) and this feature is both | 1080 // element with the right ID must actually exist) and this feature is both |
1081 // unshipped and likely to not use this mechanism when it does. | 1081 // unshipped and likely to not use this mechanism when it does. |
1082 // TODO(jbroman): Update this if that turns out not to be the case. | 1082 // TODO(jbroman): Update this if that turns out not to be the case. |
1083 | 1083 |
1084 } // namespace | 1084 } // namespace |
1085 } // namespace blink | 1085 } // namespace blink |
OLD | NEW |