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

Side by Side Diff: test/unittests/value-serializer-unittest.cc

Issue 2256413002: Blink-compatible deserialization of "version 0" sparse arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/value-serializer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 " x.length = 1000;" 1032 " x.length = 1000;"
1033 " return x;" 1033 " return x;"
1034 "})()", 1034 "})()",
1035 [this](Local<Value> value) { 1035 [this](Local<Value> value) {
1036 ASSERT_TRUE(value->IsArray()); 1036 ASSERT_TRUE(value->IsArray());
1037 ASSERT_EQ(1000, Array::Cast(*value)->Length()); 1037 ASSERT_EQ(1000, Array::Cast(*value)->Length());
1038 EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)")); 1038 EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
1039 }); 1039 });
1040 } 1040 }
1041 1041
1042 TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
1043 // Empty (sparse) array.
1044 DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00},
1045 [this](Local<Value> value) {
1046 ASSERT_TRUE(value->IsArray());
1047 ASSERT_EQ(0, Array::Cast(*value)->Length());
1048 });
1049 // Sparse array with a mixture of elements and properties.
1050 DecodeTestForVersion0(
1051 {0x55, 0x00, 0x53, 0x01, 'a', 0x55, 0x02, 0x55, 0x05, 0x53,
1052 0x03, 'f', 'o', 'o', 0x53, 0x03, 'b', 'a', 'r', 0x53,
1053 0x03, 'b', 'a', 'z', 0x49, 0x0b, 0x40, 0x04, 0x03, 0x00},
1054 [this](Local<Value> value) {
1055 ASSERT_TRUE(value->IsArray());
1056 EXPECT_EQ(3, Array::Cast(*value)->Length());
1057 EXPECT_TRUE(
1058 EvaluateScriptForResultBool("result.toString() === 'a,,5'"));
1059 EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
1060 EXPECT_TRUE(EvaluateScriptForResultBool("result.foo === 'bar'"));
1061 EXPECT_TRUE(EvaluateScriptForResultBool("result.baz === -6"));
1062 });
1063 // Sparse array in a sparse array (sanity check of nesting).
1064 DecodeTestForVersion0(
1065 {0x55, 0x01, 0x55, 0x01, 0x54, 0x40, 0x01, 0x02, 0x40, 0x01, 0x02, 0x00},
1066 [this](Local<Value> value) {
1067 ASSERT_TRUE(value->IsArray());
1068 EXPECT_EQ(2, Array::Cast(*value)->Length());
1069 EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result)"));
1070 EXPECT_TRUE(EvaluateScriptForResultBool("result[1] instanceof Array"));
1071 EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result[1])"));
1072 EXPECT_TRUE(EvaluateScriptForResultBool("result[1][1] === true"));
1073 });
1074 }
1075
1042 } // namespace 1076 } // namespace
1043 } // namespace v8 1077 } // namespace v8
OLDNEW
« no previous file with comments | « src/value-serializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698