| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "src/value-serializer.h" | 5 #include "src/value-serializer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "include/v8.h" | 10 #include "include/v8.h" |
| (...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 {0xff, 0x09, 0x42, 0x02, 0x00, 0x00, 0x56, 0x42, 0x03, 0x01}); | 1977 {0xff, 0x09, 0x42, 0x02, 0x00, 0x00, 0x56, 0x42, 0x03, 0x01}); |
| 1978 // Byte offset in range, offset + length out of range. | 1978 // Byte offset in range, offset + length out of range. |
| 1979 InvalidDecodeTest( | 1979 InvalidDecodeTest( |
| 1980 {0xff, 0x09, 0x42, 0x02, 0x00, 0x00, 0x56, 0x42, 0x01, 0x03}); | 1980 {0xff, 0x09, 0x42, 0x02, 0x00, 0x00, 0x56, 0x42, 0x01, 0x03}); |
| 1981 // Byte offset not divisible by element size. | 1981 // Byte offset not divisible by element size. |
| 1982 InvalidDecodeTest( | 1982 InvalidDecodeTest( |
| 1983 {0xff, 0x09, 0x42, 0x04, 0x00, 0x00, 0x00, 0x00, 0x56, 0x77, 0x01, 0x02}); | 1983 {0xff, 0x09, 0x42, 0x04, 0x00, 0x00, 0x00, 0x00, 0x56, 0x77, 0x01, 0x02}); |
| 1984 // Byte length not divisible by element size. | 1984 // Byte length not divisible by element size. |
| 1985 InvalidDecodeTest( | 1985 InvalidDecodeTest( |
| 1986 {0xff, 0x09, 0x42, 0x04, 0x00, 0x00, 0x00, 0x00, 0x56, 0x77, 0x02, 0x01}); | 1986 {0xff, 0x09, 0x42, 0x04, 0x00, 0x00, 0x00, 0x00, 0x56, 0x77, 0x02, 0x01}); |
| 1987 // Invalid view type (0xff). |
| 1988 InvalidDecodeTest( |
| 1989 {0xff, 0x09, 0x42, 0x02, 0x00, 0x00, 0x56, 0xff, 0x01, 0x01}); |
| 1987 } | 1990 } |
| 1988 | 1991 |
| 1989 TEST_F(ValueSerializerTest, RoundTripDataView) { | 1992 TEST_F(ValueSerializerTest, RoundTripDataView) { |
| 1990 RoundTripTest("new DataView(new ArrayBuffer(4), 1, 2)", | 1993 RoundTripTest("new DataView(new ArrayBuffer(4), 1, 2)", |
| 1991 [this](Local<Value> value) { | 1994 [this](Local<Value> value) { |
| 1992 ASSERT_TRUE(value->IsDataView()); | 1995 ASSERT_TRUE(value->IsDataView()); |
| 1993 EXPECT_EQ(1, DataView::Cast(*value)->ByteOffset()); | 1996 EXPECT_EQ(1, DataView::Cast(*value)->ByteOffset()); |
| 1994 EXPECT_EQ(2, DataView::Cast(*value)->ByteLength()); | 1997 EXPECT_EQ(2, DataView::Cast(*value)->ByteLength()); |
| 1995 EXPECT_EQ(4, DataView::Cast(*value)->Buffer()->ByteLength()); | 1998 EXPECT_EQ(4, DataView::Cast(*value)->Buffer()->ByteLength()); |
| 1996 EXPECT_TRUE(EvaluateScriptForResultBool( | 1999 EXPECT_TRUE(EvaluateScriptForResultBool( |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 "({ a: new ExampleHostObject(), get b() { return this.a; }})", | 2356 "({ a: new ExampleHostObject(), get b() { return this.a; }})", |
| 2354 [this](Local<Value> value) { | 2357 [this](Local<Value> value) { |
| 2355 EXPECT_TRUE(EvaluateScriptForResultBool( | 2358 EXPECT_TRUE(EvaluateScriptForResultBool( |
| 2356 "result.a instanceof ExampleHostObject")); | 2359 "result.a instanceof ExampleHostObject")); |
| 2357 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b")); | 2360 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b")); |
| 2358 }); | 2361 }); |
| 2359 } | 2362 } |
| 2360 | 2363 |
| 2361 } // namespace | 2364 } // namespace |
| 2362 } // namespace v8 | 2365 } // namespace v8 |
| OLD | NEW |