Chromium Code Reviews| 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 DOMPointReadOnly* new_point = | |
| 251 V8DOMPointReadOnly::toImpl(result.As<v8::Object>()); | |
|
jbroman
2017/05/15 17:02:55
Suggest also checking that the result isn't a DOMP
fserb
2017/05/15 17:52:17
good catch. :)
| |
| 252 EXPECT_NE(point, new_point); | |
| 253 EXPECT_EQ(point->x(), new_point->x()); | |
| 254 EXPECT_EQ(point->y(), new_point->y()); | |
| 255 EXPECT_EQ(point->z(), new_point->z()); | |
| 256 EXPECT_EQ(point->w(), new_point->w()); | |
| 257 } | |
| 258 | |
| 259 TEST(V8ScriptValueSerializerTest, RoundTripDOMRect) { | |
| 260 // DOMRect objects should serialize and deserialize correctly. | |
| 261 V8TestingScope scope; | |
| 262 DOMRect* rect = DOMRect::Create(1, 2, 3, 4); | |
| 263 v8::Local<v8::Value> wrapper = | |
| 264 ToV8(rect, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 265 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 266 ASSERT_TRUE(V8DOMRect::hasInstance(result, scope.GetIsolate())); | |
| 267 DOMRect* new_rect = V8DOMRect::toImpl(result.As<v8::Object>()); | |
| 268 EXPECT_NE(rect, new_rect); | |
| 269 EXPECT_EQ(rect->x(), new_rect->x()); | |
| 270 EXPECT_EQ(rect->y(), new_rect->y()); | |
| 271 EXPECT_EQ(rect->width(), new_rect->width()); | |
| 272 EXPECT_EQ(rect->height(), new_rect->height()); | |
| 273 } | |
| 274 | |
| 275 TEST(V8ScriptValueSerializerTest, RoundTripDOMRectReadOnly) { | |
| 276 // DOMRectReadOnly objects should serialize and deserialize correctly. | |
| 277 V8TestingScope scope; | |
| 278 DOMRectReadOnly* rect = DOMRectReadOnly::Create(1, 2, 3, 4); | |
| 279 v8::Local<v8::Value> wrapper = | |
| 280 ToV8(rect, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 281 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 282 ASSERT_TRUE(V8DOMRectReadOnly::hasInstance(result, scope.GetIsolate())); | |
| 283 DOMRectReadOnly* new_rect = V8DOMRect::toImpl(result.As<v8::Object>()); | |
| 284 EXPECT_NE(rect, new_rect); | |
| 285 EXPECT_EQ(rect->x(), new_rect->x()); | |
| 286 EXPECT_EQ(rect->y(), new_rect->y()); | |
| 287 EXPECT_EQ(rect->width(), new_rect->width()); | |
| 288 EXPECT_EQ(rect->height(), new_rect->height()); | |
| 289 } | |
| 290 | |
| 291 TEST(V8ScriptValueSerializerTest, RoundTripDOMQuad) { | |
| 292 // DOMQuad objects should serialize and deserialize correctly. | |
| 293 V8TestingScope scope; | |
| 294 DOMPointInit pi1; | |
| 295 pi1.setX(1); | |
| 296 pi1.setY(5); | |
| 297 pi1.setZ(9); | |
| 298 pi1.setW(13); | |
| 299 DOMPointInit pi2; | |
| 300 pi2.setX(2); | |
| 301 pi2.setY(6); | |
| 302 pi2.setZ(10); | |
| 303 pi2.setW(14); | |
| 304 DOMPointInit pi3; | |
| 305 pi3.setX(3); | |
| 306 pi3.setY(7); | |
| 307 pi3.setZ(11); | |
| 308 pi3.setW(15); | |
| 309 DOMPointInit pi4; | |
| 310 pi4.setX(4); | |
| 311 pi4.setY(8); | |
| 312 pi4.setZ(12); | |
| 313 pi4.setW(16); | |
| 314 DOMQuad* quad = DOMQuad::Create(pi1, pi2, pi3, pi4); | |
| 315 v8::Local<v8::Value> wrapper = | |
| 316 ToV8(quad, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 317 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 318 ASSERT_TRUE(V8DOMQuad::hasInstance(result, scope.GetIsolate())); | |
| 319 DOMQuad* new_quad = V8DOMQuad::toImpl(result.As<v8::Object>()); | |
| 320 EXPECT_NE(quad, new_quad); | |
| 321 EXPECT_NE(quad->p1(), new_quad->p1()); | |
| 322 EXPECT_NE(quad->p2(), new_quad->p2()); | |
| 323 EXPECT_NE(quad->p3(), new_quad->p3()); | |
| 324 EXPECT_NE(quad->p4(), new_quad->p4()); | |
| 325 EXPECT_EQ(quad->p1()->x(), new_quad->p1()->x()); | |
| 326 EXPECT_EQ(quad->p1()->y(), new_quad->p1()->y()); | |
| 327 EXPECT_EQ(quad->p1()->z(), new_quad->p1()->z()); | |
| 328 EXPECT_EQ(quad->p1()->w(), new_quad->p1()->w()); | |
| 329 EXPECT_EQ(quad->p2()->x(), new_quad->p2()->x()); | |
| 330 EXPECT_EQ(quad->p2()->y(), new_quad->p2()->y()); | |
| 331 EXPECT_EQ(quad->p2()->z(), new_quad->p2()->z()); | |
| 332 EXPECT_EQ(quad->p2()->w(), new_quad->p2()->w()); | |
| 333 EXPECT_EQ(quad->p3()->x(), new_quad->p3()->x()); | |
| 334 EXPECT_EQ(quad->p3()->y(), new_quad->p3()->y()); | |
| 335 EXPECT_EQ(quad->p3()->z(), new_quad->p3()->z()); | |
| 336 EXPECT_EQ(quad->p3()->w(), new_quad->p3()->w()); | |
| 337 EXPECT_EQ(quad->p4()->x(), new_quad->p4()->x()); | |
| 338 EXPECT_EQ(quad->p4()->y(), new_quad->p4()->y()); | |
| 339 EXPECT_EQ(quad->p4()->z(), new_quad->p4()->z()); | |
| 340 EXPECT_EQ(quad->p4()->w(), new_quad->p4()->w()); | |
| 341 } | |
| 342 | |
| 343 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrix2D) { | |
| 344 // DOMMatrix objects should serialize and deserialize correctly. | |
| 345 V8TestingScope scope; | |
| 346 DOMMatrixInit init; | |
| 347 init.setIs2D(true); | |
| 348 init.setA(1.0); | |
| 349 init.setB(2.0); | |
| 350 init.setC(3.0); | |
| 351 init.setD(4.0); | |
| 352 init.setE(5.0); | |
| 353 init.setF(6.0); | |
| 354 DOMMatrix* matrix = DOMMatrix::fromMatrix(init, scope.GetExceptionState()); | |
| 355 EXPECT_TRUE(matrix->is2D()); | |
| 356 v8::Local<v8::Value> wrapper = | |
| 357 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 358 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 359 ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate())); | |
| 360 DOMMatrix* new_matrix = V8DOMMatrix::toImpl(result.As<v8::Object>()); | |
| 361 EXPECT_NE(matrix, new_matrix); | |
| 362 EXPECT_TRUE(new_matrix->is2D()); | |
| 363 EXPECT_EQ(matrix->a(), new_matrix->a()); | |
| 364 EXPECT_EQ(matrix->b(), new_matrix->b()); | |
| 365 EXPECT_EQ(matrix->c(), new_matrix->c()); | |
| 366 EXPECT_EQ(matrix->d(), new_matrix->d()); | |
| 367 EXPECT_EQ(matrix->e(), new_matrix->e()); | |
| 368 EXPECT_EQ(matrix->f(), new_matrix->f()); | |
| 369 } | |
| 370 | |
| 371 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrixReadOnly2D) { | |
| 372 // DOMMatrix objects should serialize and deserialize correctly. | |
| 373 V8TestingScope scope; | |
| 374 DOMMatrixInit init; | |
| 375 init.setIs2D(true); | |
| 376 init.setA(1.0); | |
| 377 init.setB(2.0); | |
| 378 init.setC(3.0); | |
| 379 init.setD(4.0); | |
| 380 init.setE(5.0); | |
| 381 init.setF(6.0); | |
| 382 DOMMatrixReadOnly* matrix = | |
| 383 DOMMatrixReadOnly::fromMatrix(init, scope.GetExceptionState()); | |
| 384 EXPECT_TRUE(matrix->is2D()); | |
| 385 v8::Local<v8::Value> wrapper = | |
| 386 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 387 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 388 ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate())); | |
| 389 DOMMatrixReadOnly* new_matrix = | |
| 390 V8DOMMatrixReadOnly::toImpl(result.As<v8::Object>()); | |
| 391 EXPECT_NE(matrix, new_matrix); | |
| 392 EXPECT_TRUE(new_matrix->is2D()); | |
| 393 EXPECT_EQ(matrix->a(), new_matrix->a()); | |
| 394 EXPECT_EQ(matrix->b(), new_matrix->b()); | |
| 395 EXPECT_EQ(matrix->c(), new_matrix->c()); | |
| 396 EXPECT_EQ(matrix->d(), new_matrix->d()); | |
| 397 EXPECT_EQ(matrix->e(), new_matrix->e()); | |
| 398 EXPECT_EQ(matrix->f(), new_matrix->f()); | |
| 399 } | |
| 400 | |
| 401 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrix) { | |
| 402 // DOMMatrix objects should serialize and deserialize correctly. | |
| 403 V8TestingScope scope; | |
| 404 DOMMatrixInit init; | |
| 405 init.setIs2D(false); | |
| 406 init.setM11(1.1); | |
| 407 init.setM12(1.2); | |
| 408 init.setM13(1.3); | |
| 409 init.setM14(1.4); | |
| 410 init.setM21(2.1); | |
| 411 init.setM22(2.2); | |
| 412 init.setM23(2.3); | |
| 413 init.setM24(2.4); | |
| 414 init.setM31(3.1); | |
| 415 init.setM32(3.2); | |
| 416 init.setM33(3.3); | |
| 417 init.setM34(3.4); | |
| 418 init.setM41(4.1); | |
| 419 init.setM42(4.2); | |
| 420 init.setM43(4.3); | |
| 421 init.setM44(4.4); | |
| 422 DOMMatrix* matrix = DOMMatrix::fromMatrix(init, scope.GetExceptionState()); | |
| 423 EXPECT_FALSE(matrix->is2D()); | |
| 424 v8::Local<v8::Value> wrapper = | |
| 425 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 426 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 427 ASSERT_TRUE(V8DOMMatrix::hasInstance(result, scope.GetIsolate())); | |
| 428 DOMMatrix* new_matrix = V8DOMMatrix::toImpl(result.As<v8::Object>()); | |
| 429 EXPECT_NE(matrix, new_matrix); | |
| 430 EXPECT_FALSE(new_matrix->is2D()); | |
| 431 EXPECT_EQ(matrix->m11(), new_matrix->m11()); | |
| 432 EXPECT_EQ(matrix->m12(), new_matrix->m12()); | |
| 433 EXPECT_EQ(matrix->m13(), new_matrix->m13()); | |
| 434 EXPECT_EQ(matrix->m14(), new_matrix->m14()); | |
| 435 EXPECT_EQ(matrix->m21(), new_matrix->m21()); | |
| 436 EXPECT_EQ(matrix->m22(), new_matrix->m22()); | |
| 437 EXPECT_EQ(matrix->m23(), new_matrix->m23()); | |
| 438 EXPECT_EQ(matrix->m24(), new_matrix->m24()); | |
| 439 EXPECT_EQ(matrix->m31(), new_matrix->m31()); | |
| 440 EXPECT_EQ(matrix->m32(), new_matrix->m32()); | |
| 441 EXPECT_EQ(matrix->m33(), new_matrix->m33()); | |
| 442 EXPECT_EQ(matrix->m34(), new_matrix->m34()); | |
| 443 EXPECT_EQ(matrix->m41(), new_matrix->m41()); | |
| 444 EXPECT_EQ(matrix->m42(), new_matrix->m42()); | |
| 445 EXPECT_EQ(matrix->m43(), new_matrix->m43()); | |
| 446 EXPECT_EQ(matrix->m44(), new_matrix->m44()); | |
| 447 } | |
| 448 | |
| 449 TEST(V8ScriptValueSerializerTest, RoundTripDOMMatrixReadOnly) { | |
| 450 // DOMMatrixReadOnly objects should serialize and deserialize correctly. | |
| 451 V8TestingScope scope; | |
| 452 DOMMatrixInit init; | |
| 453 init.setIs2D(false); | |
| 454 init.setM11(1.1); | |
| 455 init.setM12(1.2); | |
| 456 init.setM13(1.3); | |
| 457 init.setM14(1.4); | |
| 458 init.setM21(2.1); | |
| 459 init.setM22(2.2); | |
| 460 init.setM23(2.3); | |
| 461 init.setM24(2.4); | |
| 462 init.setM31(3.1); | |
| 463 init.setM32(3.2); | |
| 464 init.setM33(3.3); | |
| 465 init.setM34(3.4); | |
| 466 init.setM41(4.1); | |
| 467 init.setM42(4.2); | |
| 468 init.setM43(4.3); | |
| 469 init.setM44(4.4); | |
| 470 DOMMatrixReadOnly* matrix = | |
| 471 DOMMatrixReadOnly::fromMatrix(init, scope.GetExceptionState()); | |
| 472 EXPECT_FALSE(matrix->is2D()); | |
| 473 v8::Local<v8::Value> wrapper = | |
| 474 ToV8(matrix, scope.GetContext()->Global(), scope.GetIsolate()); | |
| 475 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | |
| 476 ASSERT_TRUE(V8DOMMatrixReadOnly::hasInstance(result, scope.GetIsolate())); | |
| 477 DOMMatrixReadOnly* new_matrix = | |
| 478 V8DOMMatrixReadOnly::toImpl(result.As<v8::Object>()); | |
| 479 EXPECT_NE(matrix, new_matrix); | |
| 480 EXPECT_FALSE(new_matrix->is2D()); | |
| 481 EXPECT_EQ(matrix->m11(), new_matrix->m11()); | |
| 482 EXPECT_EQ(matrix->m12(), new_matrix->m12()); | |
| 483 EXPECT_EQ(matrix->m13(), new_matrix->m13()); | |
| 484 EXPECT_EQ(matrix->m14(), new_matrix->m14()); | |
| 485 EXPECT_EQ(matrix->m21(), new_matrix->m21()); | |
| 486 EXPECT_EQ(matrix->m22(), new_matrix->m22()); | |
| 487 EXPECT_EQ(matrix->m23(), new_matrix->m23()); | |
| 488 EXPECT_EQ(matrix->m24(), new_matrix->m24()); | |
| 489 EXPECT_EQ(matrix->m31(), new_matrix->m31()); | |
| 490 EXPECT_EQ(matrix->m32(), new_matrix->m32()); | |
| 491 EXPECT_EQ(matrix->m33(), new_matrix->m33()); | |
| 492 EXPECT_EQ(matrix->m34(), new_matrix->m34()); | |
| 493 EXPECT_EQ(matrix->m41(), new_matrix->m41()); | |
| 494 EXPECT_EQ(matrix->m42(), new_matrix->m42()); | |
| 495 EXPECT_EQ(matrix->m43(), new_matrix->m43()); | |
| 496 EXPECT_EQ(matrix->m44(), new_matrix->m44()); | |
| 497 } | |
| 498 | |
|
jbroman
2017/05/15 17:02:55
Please also add decode tests to ensure that if we
| |
| 211 TEST(V8ScriptValueSerializerTest, RoundTripImageData) { | 499 TEST(V8ScriptValueSerializerTest, RoundTripImageData) { |
| 212 // ImageData objects should serialize and deserialize correctly. | 500 // ImageData objects should serialize and deserialize correctly. |
| 213 V8TestingScope scope; | 501 V8TestingScope scope; |
| 214 ImageData* image_data = ImageData::Create(2, 1, ASSERT_NO_EXCEPTION); | 502 ImageData* image_data = ImageData::Create(2, 1, ASSERT_NO_EXCEPTION); |
| 215 image_data->data()->Data()[0] = 200; | 503 image_data->data()->Data()[0] = 200; |
| 216 v8::Local<v8::Value> wrapper = | 504 v8::Local<v8::Value> wrapper = |
| 217 ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate()); | 505 ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate()); |
| 218 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | 506 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); |
| 219 ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate())); | 507 ASSERT_TRUE(V8ImageData::hasInstance(result, scope.GetIsolate())); |
| 220 ImageData* new_image_data = V8ImageData::toImpl(result.As<v8::Object>()); | 508 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); | 810 RoundTrip(wrapper, scope, nullptr, &transferables); |
| 523 ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate())); | 811 ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate())); |
| 524 OffscreenCanvas* new_canvas = | 812 OffscreenCanvas* new_canvas = |
| 525 V8OffscreenCanvas::toImpl(result.As<v8::Object>()); | 813 V8OffscreenCanvas::toImpl(result.As<v8::Object>()); |
| 526 EXPECT_EQ(IntSize(10, 7), new_canvas->Size()); | 814 EXPECT_EQ(IntSize(10, 7), new_canvas->Size()); |
| 527 EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId()); | 815 EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId()); |
| 528 EXPECT_TRUE(canvas->IsNeutered()); | 816 EXPECT_TRUE(canvas->IsNeutered()); |
| 529 EXPECT_FALSE(new_canvas->IsNeutered()); | 817 EXPECT_FALSE(new_canvas->IsNeutered()); |
| 530 } | 818 } |
| 531 | 819 |
| 820 // TEST(V8ScriptValueSerializerTest, TransferDOMPoint) { | |
|
jbroman
2017/05/15 17:02:55
Delete this?
| |
| 821 // V8TestingScope scope; | |
| 822 // DOMPoint* point = DOMPoint::Create(1, 2, 3, 4); | |
| 823 // v8::Local<v8::Value> wrapper = ToV8(point, scope.GetScriptState()); | |
| 824 // Transferables transferables; | |
| 825 // transferables.offscreen_canvases.push_back(canvas); | |
| 826 // v8::Local<v8::Value> result = | |
| 827 // RoundTrip(wrapper, scope, nullptr, &transferables); | |
| 828 // ASSERT_TRUE(V8OffscreenCanvas::hasInstance(result, scope.GetIsolate())); | |
| 829 // OffscreenCanvas* new_canvas = | |
| 830 // V8OffscreenCanvas::toImpl(result.As<v8::Object>()); | |
| 831 // EXPECT_EQ(IntSize(10, 7), new_canvas->Size()); | |
| 832 // EXPECT_EQ(519u, new_canvas->PlaceholderCanvasId()); | |
| 833 // EXPECT_TRUE(canvas->IsNeutered()); | |
| 834 // EXPECT_FALSE(new_canvas->IsNeutered()); | |
| 835 // } | |
| 836 | |
| 532 TEST(V8ScriptValueSerializerTest, RoundTripBlob) { | 837 TEST(V8ScriptValueSerializerTest, RoundTripBlob) { |
| 533 V8TestingScope scope; | 838 V8TestingScope scope; |
| 534 const char kHelloWorld[] = "Hello world!"; | 839 const char kHelloWorld[] = "Hello world!"; |
| 535 Blob* blob = | 840 Blob* blob = |
| 536 Blob::Create(reinterpret_cast<const unsigned char*>(&kHelloWorld), | 841 Blob::Create(reinterpret_cast<const unsigned char*>(&kHelloWorld), |
| 537 sizeof(kHelloWorld), "text/plain"); | 842 sizeof(kHelloWorld), "text/plain"); |
| 538 String uuid = blob->Uuid(); | 843 String uuid = blob->Uuid(); |
| 539 EXPECT_FALSE(uuid.IsEmpty()); | 844 EXPECT_FALSE(uuid.IsEmpty()); |
| 540 v8::Local<v8::Value> wrapper = ToV8(blob, scope.GetScriptState()); | 845 v8::Local<v8::Value> wrapper = ToV8(blob, scope.GetScriptState()); |
| 541 v8::Local<v8::Value> result = RoundTrip(wrapper, scope); | 846 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 = | 1406 RefPtr<SerializedScriptValue> input = |
| 1102 SerializedValue({0xff, 0x80, 0x09, 0xff, 0x09, 0x54}); | 1407 SerializedValue({0xff, 0x80, 0x09, 0xff, 0x09, 0x54}); |
| 1103 EXPECT_TRUE( | 1408 EXPECT_TRUE( |
| 1104 V8ScriptValueDeserializer(scope.GetScriptState(), std::move(input)) | 1409 V8ScriptValueDeserializer(scope.GetScriptState(), std::move(input)) |
| 1105 .Deserialize() | 1410 .Deserialize() |
| 1106 ->IsTrue()); | 1411 ->IsTrue()); |
| 1107 } | 1412 } |
| 1108 | 1413 |
| 1109 } // namespace | 1414 } // namespace |
| 1110 } // namespace blink | 1415 } // namespace blink |
| OLD | NEW |