Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp

Issue 2362463002: Support ImageBitmap transfer with V8-based structured clone. (Closed)
Patch Set: with one quick unit test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp
index ad234245ff25a41ef2891fbeeb12a216b8db1776..a522ba3bf81e1a1f90726864db59002f8a8884b2 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp
@@ -431,5 +431,37 @@ TEST(V8ScriptValueSerializerTest, InvalidImageBitmapDecode)
}
}
+TEST(V8ScriptValueSerializerTest, TransferImageBitmap)
+{
+ // More thorough tests exist in LayoutTests/.
+ ScopedEnableV8BasedStructuredClone enable;
+ V8TestingScope scope;
+
+ sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(10, 7);
+ surface->getCanvas()->clear(SK_ColorRED);
+ sk_sp<SkImage> image = surface->makeImageSnapshot();
+ ImageBitmap* imageBitmap = ImageBitmap::create(StaticBitmapImage::create(image));
+
+ v8::Local<v8::Value> wrapper = toV8(imageBitmap, scope.getScriptState());
+ Transferables transferables;
+ transferables.imageBitmaps.append(imageBitmap);
+ v8::Local<v8::Value> result = roundTrip(wrapper, scope, nullptr, &transferables);
+ ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.isolate()));
+ ImageBitmap* newImageBitmap = V8ImageBitmap::toImpl(result.As<v8::Object>());
+ ASSERT_EQ(IntSize(10, 7), newImageBitmap->size());
+
+ // Check that the pixel at (3, 3) is red.
+ uint8_t pixel[4] = {};
+ sk_sp<SkImage> newImage = newImageBitmap->bitmapImage()->imageForCurrentFrame();
+ ASSERT_TRUE(newImage->readPixels(
+ SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
+ &pixel, 4, 3, 3));
+ ASSERT_THAT(pixel, ::testing::ElementsAre(255, 0, 0, 255));
+
+ // Check also that the underlying image contents were transferred.
+ EXPECT_EQ(image, newImage);
+ EXPECT_TRUE(imageBitmap->isNeutered());
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698