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" |
11 #include "bindings/core/v8/V8Blob.h" | 11 #include "bindings/core/v8/V8Blob.h" |
12 #include "bindings/core/v8/V8CompositorProxy.h" | 12 #include "bindings/core/v8/V8CompositorProxy.h" |
13 #include "bindings/core/v8/V8DOMException.h" | 13 #include "bindings/core/v8/V8DOMException.h" |
| 14 #include "bindings/core/v8/V8DOMMatrix.h" |
| 15 #include "bindings/core/v8/V8DOMMatrixReadOnly.h" |
| 16 #include "bindings/core/v8/V8DOMPoint.h" |
| 17 #include "bindings/core/v8/V8DOMPointInit.h" |
| 18 #include "bindings/core/v8/V8DOMPointReadOnly.h" |
| 19 #include "bindings/core/v8/V8DOMQuad.h" |
| 20 #include "bindings/core/v8/V8DOMRect.h" |
| 21 #include "bindings/core/v8/V8DOMRectReadOnly.h" |
14 #include "bindings/core/v8/V8File.h" | 22 #include "bindings/core/v8/V8File.h" |
15 #include "bindings/core/v8/V8FileList.h" | 23 #include "bindings/core/v8/V8FileList.h" |
16 #include "bindings/core/v8/V8ImageBitmap.h" | 24 #include "bindings/core/v8/V8ImageBitmap.h" |
17 #include "bindings/core/v8/V8ImageData.h" | 25 #include "bindings/core/v8/V8ImageData.h" |
18 #include "bindings/core/v8/V8MessagePort.h" | 26 #include "bindings/core/v8/V8MessagePort.h" |
19 #include "bindings/core/v8/V8OffscreenCanvas.h" | 27 #include "bindings/core/v8/V8OffscreenCanvas.h" |
20 #include "bindings/core/v8/V8StringResource.h" | 28 #include "bindings/core/v8/V8StringResource.h" |
21 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h" | 29 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h" |
22 #include "core/dom/CompositorProxy.h" | 30 #include "core/dom/CompositorProxy.h" |
23 #include "core/dom/MessagePort.h" | 31 #include "core/dom/MessagePort.h" |
24 #include "core/fileapi/Blob.h" | 32 #include "core/fileapi/Blob.h" |
25 #include "core/fileapi/File.h" | 33 #include "core/fileapi/File.h" |
26 #include "core/fileapi/FileList.h" | 34 #include "core/fileapi/FileList.h" |
27 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 36 #include "core/geometry/DOMMatrix.h" |
| 37 #include "core/geometry/DOMMatrixReadOnly.h" |
| 38 #include "core/geometry/DOMPoint.h" |
| 39 #include "core/geometry/DOMPointReadOnly.h" |
| 40 #include "core/geometry/DOMQuad.h" |
| 41 #include "core/geometry/DOMRect.h" |
| 42 #include "core/geometry/DOMRectReadOnly.h" |
28 #include "core/html/ImageData.h" | 43 #include "core/html/ImageData.h" |
29 #include "core/offscreencanvas/OffscreenCanvas.h" | 44 #include "core/offscreencanvas/OffscreenCanvas.h" |
30 #include "platform/RuntimeEnabledFeatures.h" | 45 #include "platform/RuntimeEnabledFeatures.h" |
31 #include "platform/graphics/CompositorMutableProperties.h" | 46 #include "platform/graphics/CompositorMutableProperties.h" |
32 #include "platform/graphics/StaticBitmapImage.h" | 47 #include "platform/graphics/StaticBitmapImage.h" |
33 #include "platform/wtf/CurrentTime.h" | 48 #include "platform/wtf/CurrentTime.h" |
34 #include "platform/wtf/DateMath.h" | 49 #include "platform/wtf/DateMath.h" |
35 #include "public/platform/WebBlobInfo.h" | 50 #include "public/platform/WebBlobInfo.h" |
36 #include "public/platform/WebMessagePortChannel.h" | 51 #include "public/platform/WebMessagePortChannel.h" |
37 #include "public/platform/WebMessagePortChannelClient.h" | 52 #include "public/platform/WebMessagePortChannelClient.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 Transferables transferables; | 216 Transferables transferables; |
202 transferables.array_buffers.push_back(array_buffer); | 217 transferables.array_buffers.push_back(array_buffer); |
203 | 218 |
204 RoundTrip(object, scope, &exception_state, &transferables); | 219 RoundTrip(object, scope, &exception_state, &transferables); |
205 ASSERT_TRUE(exception_state.HadException()); | 220 ASSERT_TRUE(exception_state.HadException()); |
206 EXPECT_FALSE(HadDOMException("DataCloneError", scope.GetScriptState(), | 221 EXPECT_FALSE(HadDOMException("DataCloneError", scope.GetScriptState(), |
207 exception_state)); | 222 exception_state)); |
208 EXPECT_FALSE(array_buffer->IsNeutered()); | 223 EXPECT_FALSE(array_buffer->IsNeutered()); |
209 } | 224 } |
210 | 225 |
| 226 TEST(V8ScriptValueSerializerTest, RoundTripDOMPoint) { |
| 227 // DOMPoint objects should serialize and deserialize correctly. |
| 228 V8TestingScope scope; |
| 229 DOMPoint* point = DOMPoint::Create(1, 2, 3, 4); |
| 230 v8::Local<v8::Value> wrapper = |
| 231 ToV8(point, scope.GetContext()->Global(), scope.GetIsolate()); |
| 232 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 233 ASSERT_TRUE(V8DOMPoint::hasInstance(result, scope.GetIsolate())); |
| 234 DOMPoint* new_point = V8DOMPoint::toImpl(result.As<v8::Object>()); |
| 235 EXPECT_NE(point, new_point); |
| 236 EXPECT_EQ(point->x(), new_point->x()); |
| 237 EXPECT_EQ(point->y(), new_point->y()); |
| 238 EXPECT_EQ(point->z(), new_point->z()); |
| 239 EXPECT_EQ(point->w(), new_point->w()); |
| 240 } |
| 241 |
| 242 TEST(V8ScriptValueSerializerTest, RoundTripDOMPointReadOnly) { |
| 243 // DOMPointReadOnly objects should serialize and deserialize correctly. |
| 244 V8TestingScope scope; |
| 245 DOMPointReadOnly* point = DOMPointReadOnly::Create(1, 2, 3, 4); |
| 246 v8::Local<v8::Value> wrapper = |
| 247 ToV8(point, scope.GetContext()->Global(), scope.GetIsolate()); |
| 248 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 249 ASSERT_TRUE(V8DOMPointReadOnly::hasInstance(result, scope.GetIsolate())); |
| 250 EXPECT_FALSE(V8DOMPoint::hasInstance(result, scope.GetIsolate())); |
| 251 DOMPointReadOnly* new_point = |
| 252 V8DOMPointReadOnly::toImpl(result.As<v8::Object>()); |
| 253 EXPECT_NE(point, new_point); |
| 254 EXPECT_EQ(point->x(), new_point->x()); |
| 255 EXPECT_EQ(point->y(), new_point->y()); |
| 256 EXPECT_EQ(point->z(), new_point->z()); |
| 257 EXPECT_EQ(point->w(), new_point->w()); |
| 258 } |
| 259 |
| 260 TEST(V8ScriptValueSerializerTest, RoundTripDOMRect) { |
| 261 // DOMRect objects should serialize and deserialize correctly. |
| 262 V8TestingScope scope; |
| 263 DOMRect* rect = DOMRect::Create(1, 2, 3, 4); |
| 264 v8::Local<v8::Value> wrapper = |
| 265 ToV8(rect, scope.GetContext()->Global(), scope.GetIsolate()); |
| 266 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 267 ASSERT_TRUE(V8DOMRect::hasInstance(result, scope.GetIsolate())); |
| 268 DOMRect* new_rect = V8DOMRect::toImpl(result.As<v8::Object>()); |
| 269 EXPECT_NE(rect, new_rect); |
| 270 EXPECT_EQ(rect->x(), new_rect->x()); |
| 271 EXPECT_EQ(rect->y(), new_rect->y()); |
| 272 EXPECT_EQ(rect->width(), new_rect->width()); |
| 273 EXPECT_EQ(rect->height(), new_rect->height()); |
| 274 } |
| 275 |
| 276 TEST(V8ScriptValueSerializerTest, RoundTripDOMRectReadOnly) { |
| 277 // DOMRectReadOnly objects should serialize and deserialize correctly. |
| 278 V8TestingScope scope; |
| 279 DOMRectReadOnly* rect = DOMRectReadOnly::Create(1, 2, 3, 4); |
| 280 v8::Local<v8::Value> wrapper = |
| 281 ToV8(rect, scope.GetContext()->Global(), scope.GetIsolate()); |
| 282 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 283 ASSERT_TRUE(V8DOMRectReadOnly::hasInstance(result, scope.GetIsolate())); |
| 284 EXPECT_FALSE(V8DOMRect::hasInstance(result, scope.GetIsolate())); |
| 285 DOMRectReadOnly* new_rect = |
| 286 V8DOMRectReadOnly::toImpl(result.As<v8::Object>()); |
| 287 EXPECT_NE(rect, new_rect); |
| 288 EXPECT_EQ(rect->x(), new_rect->x()); |
| 289 EXPECT_EQ(rect->y(), new_rect->y()); |
| 290 EXPECT_EQ(rect->width(), new_rect->width()); |
| 291 EXPECT_EQ(rect->height(), new_rect->height()); |
| 292 } |
| 293 |
| 294 TEST(V8ScriptValueSerializerTest, RoundTripDOMQuad) { |
| 295 // DOMQuad objects should serialize and deserialize correctly. |
| 296 V8TestingScope scope; |
| 297 DOMPointInit pi1; |
| 298 pi1.setX(1); |
| 299 pi1.setY(5); |
| 300 pi1.setZ(9); |
| 301 pi1.setW(13); |
| 302 DOMPointInit pi2; |
| 303 pi2.setX(2); |
| 304 pi2.setY(6); |
| 305 pi2.setZ(10); |
| 306 pi2.setW(14); |
| 307 DOMPointInit pi3; |
| 308 pi3.setX(3); |
| 309 pi3.setY(7); |
| 310 pi3.setZ(11); |
| 311 pi3.setW(15); |
| 312 DOMPointInit pi4; |
| 313 pi4.setX(4); |
| 314 pi4.setY(8); |
| 315 pi4.setZ(12); |
| 316 pi4.setW(16); |
| 317 DOMQuad* quad = DOMQuad::Create(pi1, pi2, pi3, pi4); |
| 318 v8::Local<v8::Value> wrapper = |
| 319 ToV8(quad, scope.GetContext()->Global(), scope.GetIsolate()); |
| 320 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 321 ASSERT_TRUE(V8DOMQuad::hasInstance(result, scope.GetIsolate())); |
| 322 DOMQuad* new_quad = V8DOMQuad::toImpl(result.As<v8::Object>()); |
| 323 EXPECT_NE(quad, new_quad); |
| 324 EXPECT_NE(quad->p1(), new_quad->p1()); |
| 325 EXPECT_NE(quad->p2(), new_quad->p2()); |
| 326 EXPECT_NE(quad->p3(), new_quad->p3()); |
| 327 EXPECT_NE(quad->p4(), new_quad->p4()); |
| 328 EXPECT_EQ(quad->p1()->x(), new_quad->p1()->x()); |
| 329 EXPECT_EQ(quad->p1()->y(), new_quad->p1()->y()); |
| 330 EXPECT_EQ(quad->p1()->z(), new_quad->p1()->z()); |
| 331 EXPECT_EQ(quad->p1()->w(), new_quad->p1()->w()); |
| 332 EXPECT_EQ(quad->p2()->x(), new_quad->p2()->x()); |
| 333 EXPECT_EQ(quad->p2()->y(), new_quad->p2()->y()); |
| 334 EXPECT_EQ(quad->p2()->z(), new_quad->p2()->z()); |
| 335 EXPECT_EQ(quad->p2()->w(), new_quad->p2()->w()); |
| 336 EXPECT_EQ(quad->p3()->x(), new_quad->p3()->x()); |
| 337 EXPECT_EQ(quad->p3()->y(), new_quad->p3()->y()); |
| 338 EXPECT_EQ(quad->p3()->z(), new_quad->p3()->z()); |
| 339 EXPECT_EQ(quad->p3()->w(), new_quad->p3()->w()); |
| 340 EXPECT_EQ(quad->p4()->x(), new_quad->p4()->x()); |
| 341 EXPECT_EQ(quad->p4()->y(), new_quad->p4()->y()); |
| 342 EXPECT_EQ(quad->p4()->z(), new_quad->p4()->z()); |
| 343 EXPECT_EQ(quad->p4()->w(), new_quad->p4()->w()); |
| 344 } |
| 345 |
| 346 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrix2D) { |
| 347 // DOMMatrix objects should serialize and deserialize correctly. |
| 348 V8TestingScope scope; |
| 349 DOMMatrixInit init; |
| 350 init.setIs2D(true); |
| 351 init.setA(1.0); |
| 352 init.setB(2.0); |
| 353 init.setC(3.0); |
| 354 init.setD(4.0); |
| 355 init.setE(5.0); |
| 356 init.setF(6.0); |
| 357 DOMMatrix* matrix = DOMMatrix::fromMatrix(init, scope.GetExceptionState()); |
| 358 EXPECT_TRUE(matrix->is2D()); |
| 359 v8::Local<v8::Value> wrapper = |
| 360 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); |
| 361 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 362 ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate())); |
| 363 DOMMatrix* new_matrix = V8DOMMatrix::toImpl(result.As<v8::Object>()); |
| 364 EXPECT_NE(matrix, new_matrix); |
| 365 EXPECT_TRUE(new_matrix->is2D()); |
| 366 EXPECT_EQ(matrix->a(), new_matrix->a()); |
| 367 EXPECT_EQ(matrix->b(), new_matrix->b()); |
| 368 EXPECT_EQ(matrix->c(), new_matrix->c()); |
| 369 EXPECT_EQ(matrix->d(), new_matrix->d()); |
| 370 EXPECT_EQ(matrix->e(), new_matrix->e()); |
| 371 EXPECT_EQ(matrix->f(), new_matrix->f()); |
| 372 } |
| 373 |
| 374 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrixReadOnly2D) { |
| 375 // DOMMatrix objects should serialize and deserialize correctly. |
| 376 V8TestingScope scope; |
| 377 DOMMatrixInit init; |
| 378 init.setIs2D(true); |
| 379 init.setA(1.0); |
| 380 init.setB(2.0); |
| 381 init.setC(3.0); |
| 382 init.setD(4.0); |
| 383 init.setE(5.0); |
| 384 init.setF(6.0); |
| 385 DOMMatrixReadOnly* matrix = |
| 386 DOMMatrixReadOnly::fromMatrix(init, scope.GetExceptionState()); |
| 387 EXPECT_TRUE(matrix->is2D()); |
| 388 v8::Local<v8::Value> wrapper = |
| 389 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); |
| 390 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 391 ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate())); |
| 392 EXPECT_FALSE(V8DOMMatrix::hasInstance(result, scope.GetIsolate())); |
| 393 DOMMatrixReadOnly* new_matrix = |
| 394 V8DOMMatrixReadOnly::toImpl(result.As<v8::Object>()); |
| 395 EXPECT_NE(matrix, new_matrix); |
| 396 EXPECT_TRUE(new_matrix->is2D()); |
| 397 EXPECT_EQ(matrix->a(), new_matrix->a()); |
| 398 EXPECT_EQ(matrix->b(), new_matrix->b()); |
| 399 EXPECT_EQ(matrix->c(), new_matrix->c()); |
| 400 EXPECT_EQ(matrix->d(), new_matrix->d()); |
| 401 EXPECT_EQ(matrix->e(), new_matrix->e()); |
| 402 EXPECT_EQ(matrix->f(), new_matrix->f()); |
| 403 } |
| 404 |
| 405 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrix) { |
| 406 // DOMMatrix objects should serialize and deserialize correctly. |
| 407 V8TestingScope scope; |
| 408 DOMMatrixInit init; |
| 409 init.setIs2D(false); |
| 410 init.setM11(1.1); |
| 411 init.setM12(1.2); |
| 412 init.setM13(1.3); |
| 413 init.setM14(1.4); |
| 414 init.setM21(2.1); |
| 415 init.setM22(2.2); |
| 416 init.setM23(2.3); |
| 417 init.setM24(2.4); |
| 418 init.setM31(3.1); |
| 419 init.setM32(3.2); |
| 420 init.setM33(3.3); |
| 421 init.setM34(3.4); |
| 422 init.setM41(4.1); |
| 423 init.setM42(4.2); |
| 424 init.setM43(4.3); |
| 425 init.setM44(4.4); |
| 426 DOMMatrix* matrix = DOMMatrix::fromMatrix(init, scope.GetExceptionState()); |
| 427 EXPECT_FALSE(matrix->is2D()); |
| 428 v8::Local<v8::Value> wrapper = |
| 429 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); |
| 430 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 431 ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate())); |
| 432 DOMMatrix* new_matrix = V8DOMMatrix::toImpl(result.As<v8::Object>()); |
| 433 EXPECT_NE(matrix, new_matrix); |
| 434 EXPECT_FALSE(new_matrix->is2D()); |
| 435 EXPECT_EQ(matrix->m11(), new_matrix->m11()); |
| 436 EXPECT_EQ(matrix->m12(), new_matrix->m12()); |
| 437 EXPECT_EQ(matrix->m13(), new_matrix->m13()); |
| 438 EXPECT_EQ(matrix->m14(), new_matrix->m14()); |
| 439 EXPECT_EQ(matrix->m21(), new_matrix->m21()); |
| 440 EXPECT_EQ(matrix->m22(), new_matrix->m22()); |
| 441 EXPECT_EQ(matrix->m23(), new_matrix->m23()); |
| 442 EXPECT_EQ(matrix->m24(), new_matrix->m24()); |
| 443 EXPECT_EQ(matrix->m31(), new_matrix->m31()); |
| 444 EXPECT_EQ(matrix->m32(), new_matrix->m32()); |
| 445 EXPECT_EQ(matrix->m33(), new_matrix->m33()); |
| 446 EXPECT_EQ(matrix->m34(), new_matrix->m34()); |
| 447 EXPECT_EQ(matrix->m41(), new_matrix->m41()); |
| 448 EXPECT_EQ(matrix->m42(), new_matrix->m42()); |
| 449 EXPECT_EQ(matrix->m43(), new_matrix->m43()); |
| 450 EXPECT_EQ(matrix->m44(), new_matrix->m44()); |
| 451 } |
| 452 |
| 453 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrixReadOnly) { |
| 454 // DOMMatrixReadOnly objects should serialize and deserialize correctly. |
| 455 V8TestingScope scope; |
| 456 DOMMatrixInit init; |
| 457 init.setIs2D(false); |
| 458 init.setM11(1.1); |
| 459 init.setM12(1.2); |
| 460 init.setM13(1.3); |
| 461 init.setM14(1.4); |
| 462 init.setM21(2.1); |
| 463 init.setM22(2.2); |
| 464 init.setM23(2.3); |
| 465 init.setM24(2.4); |
| 466 init.setM31(3.1); |
| 467 init.setM32(3.2); |
| 468 init.setM33(3.3); |
| 469 init.setM34(3.4); |
| 470 init.setM41(4.1); |
| 471 init.setM42(4.2); |
| 472 init.setM43(4.3); |
| 473 init.setM44(4.4); |
| 474 DOMMatrixReadOnly* matrix = |
| 475 DOMMatrixReadOnly::fromMatrix(init, scope.GetExceptionState()); |
| 476 EXPECT_FALSE(matrix->is2D()); |
| 477 v8::Local<v8::Value> wrapper = |
| 478 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); |
| 479 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 480 ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate())); |
| 481 EXPECT_FALSE(V8DOMMatrix::hasInstance(result, scope.GetIsolate())); |
| 482 DOMMatrixReadOnly* new_matrix = |
| 483 V8DOMMatrixReadOnly::toImpl(result.As<v8::Object>()); |
| 484 EXPECT_NE(matrix, new_matrix); |
| 485 EXPECT_FALSE(new_matrix->is2D()); |
| 486 EXPECT_EQ(matrix->m11(), new_matrix->m11()); |
| 487 EXPECT_EQ(matrix->m12(), new_matrix->m12()); |
| 488 EXPECT_EQ(matrix->m13(), new_matrix->m13()); |
| 489 EXPECT_EQ(matrix->m14(), new_matrix->m14()); |
| 490 EXPECT_EQ(matrix->m21(), new_matrix->m21()); |
| 491 EXPECT_EQ(matrix->m22(), new_matrix->m22()); |
| 492 EXPECT_EQ(matrix->m23(), new_matrix->m23()); |
| 493 EXPECT_EQ(matrix->m24(), new_matrix->m24()); |
| 494 EXPECT_EQ(matrix->m31(), new_matrix->m31()); |
| 495 EXPECT_EQ(matrix->m32(), new_matrix->m32()); |
| 496 EXPECT_EQ(matrix->m33(), new_matrix->m33()); |
| 497 EXPECT_EQ(matrix->m34(), new_matrix->m34()); |
| 498 EXPECT_EQ(matrix->m41(), new_matrix->m41()); |
| 499 EXPECT_EQ(matrix->m42(), new_matrix->m42()); |
| 500 EXPECT_EQ(matrix->m43(), new_matrix->m43()); |
| 501 EXPECT_EQ(matrix->m44(), new_matrix->m44()); |
| 502 } |
| 503 |
211 TEST(V8ScriptValueSerializerTest, RoundTripImageData) { | 504 TEST(V8ScriptValueSerializerTest, RoundTripImageData) { |
212 // ImageData objects should serialize and deserialize correctly. | 505 // ImageData objects should serialize and deserialize correctly. |
213 V8TestingScope scope; | 506 V8TestingScope scope; |
214 ImageData* image_data = ImageData::Create(2, 1, ASSERT_NO_EXCEPTION); | 507 ImageData* image_data = ImageData::Create(2, 1, ASSERT_NO_EXCEPTION); |
215 image_data->data()->Data()[0] = 200; | 508 image_data->data()->Data()[0] = 200; |
216 v8::Local<v8::Value> wrapper = | 509 v8::Local<v8::Value> wrapper = |
217 ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate()); | 510 ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate()); |
218 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | 511 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
219 ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate())); | 512 ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate())); |
220 ImageData* new_image_data = V8ImageData::toImpl(result.As<v8::Object>()); | 513 ImageData* new_image_data = V8ImageData::toImpl(result.As<v8::Object>()); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 RoundTrip(wrapper, scope, nullptr, &transferables); | 815 RoundTrip(wrapper, scope, nullptr, &transferables); |
523 ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate())); | 816 ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate())); |
524 OffscreenCanvas* new_canvas = | 817 OffscreenCanvas* new_canvas = |
525 V8OffscreenCanvas::toImpl(result.As<v8::Object>()); | 818 V8OffscreenCanvas::toImpl(result.As<v8::Object>()); |
526 EXPECT_EQ(IntSize(10, 7), new_canvas->Size()); | 819 EXPECT_EQ(IntSize(10, 7), new_canvas->Size()); |
527 EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId()); | 820 EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId()); |
528 EXPECT_TRUE(canvas->IsNeutered()); | 821 EXPECT_TRUE(canvas->IsNeutered()); |
529 EXPECT_FALSE(new_canvas->IsNeutered()); | 822 EXPECT_FALSE(new_canvas->IsNeutered()); |
530 } | 823 } |
531 | 824 |
| 825 // TEST(V8ScriptValueSerializerTest, TransferDOMPoint) { |
| 826 // V8TestingScope scope; |
| 827 // DOMPoint* point = DOMPoint::Create(1, 2, 3, 4); |
| 828 // v8::Local<v8::Value> wrapper = ToV8(point, scope.GetScriptState()); |
| 829 // Transferables transferables; |
| 830 // transferables.offscreen_canvases.push_back(canvas); |
| 831 // v8::Local<v8::Value> result = |
| 832 // RoundTrip(wrapper, scope, nullptr, &transferables); |
| 833 // ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate())); |
| 834 // OffscreenCanvas* new_canvas = |
| 835 // V8OffscreenCanvas::toImpl(result.As<v8::Object>()); |
| 836 // EXPECT_EQ(IntSize(10, 7), new_canvas->Size()); |
| 837 // EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId()); |
| 838 // EXPECT_TRUE(canvas->IsNeutered()); |
| 839 // EXPECT_FALSE(new_canvas->IsNeutered()); |
| 840 // } |
| 841 |
532 TEST(V8ScriptValueSerializerTest, RoundTripBlob) { | 842 TEST(V8ScriptValueSerializerTest, RoundTripBlob) { |
533 V8TestingScope scope; | 843 V8TestingScope scope; |
534 const char kHelloWorld[] = "Hello world!"; | 844 const char kHelloWorld[] = "Hello world!"; |
535 Blob* blob = | 845 Blob* blob = |
536 Blob::Create(reinterpret_cast<const unsigned char*>(&kHelloWorld), | 846 Blob::Create(reinterpret_cast<const unsigned char*>(&kHelloWorld), |
537 sizeof(kHelloWorld), "text/plain"); | 847 sizeof(kHelloWorld), "text/plain"); |
538 String uuid = blob->Uuid(); | 848 String uuid = blob->Uuid(); |
539 EXPECT_FALSE(uuid.IsEmpty()); | 849 EXPECT_FALSE(uuid.IsEmpty()); |
540 v8::Local<v8::Value> wrapper = ToV8(blob, scope.GetScriptState()); | 850 v8::Local<v8::Value> wrapper = ToV8(blob, scope.GetScriptState()); |
541 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | 851 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 RefPtr<SerializedScriptValue> input = | 1411 RefPtr<SerializedScriptValue> input = |
1102 SerializedValue({0xff, 0x80, 0x09, 0xff, 0x09, 0x54}); | 1412 SerializedValue({0xff, 0x80, 0x09, 0xff, 0x09, 0x54}); |
1103 EXPECT_TRUE( | 1413 EXPECT_TRUE( |
1104 V8ScriptValueDeserializer(scope.GetScriptState(), std::move(input)) | 1414 V8ScriptValueDeserializer(scope.GetScriptState(), std::move(input)) |
1105 .Deserialize() | 1415 .Deserialize() |
1106 ->IsTrue()); | 1416 ->IsTrue()); |
1107 } | 1417 } |
1108 | 1418 |
1109 } // namespace | 1419 } // namespace |
1110 } // namespace blink | 1420 } // namespace blink |
OLD | NEW |