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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/value-serializer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/value-serializer-unittest.cc
diff --git a/test/unittests/value-serializer-unittest.cc b/test/unittests/value-serializer-unittest.cc
index 63b50871ff0b4aba2e16a179a55f7004eedf5507..ad8a50e7ba8e1f964da725c7822e25b24b712271 100644
--- a/test/unittests/value-serializer-unittest.cc
+++ b/test/unittests/value-serializer-unittest.cc
@@ -1039,5 +1039,39 @@ TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) {
});
}
+TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) {
+ // Empty (sparse) array.
+ DecodeTestForVersion0({0x40, 0x00, 0x00, 0x00},
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsArray());
+ ASSERT_EQ(0, Array::Cast(*value)->Length());
+ });
+ // Sparse array with a mixture of elements and properties.
+ DecodeTestForVersion0(
+ {0x55, 0x00, 0x53, 0x01, 'a', 0x55, 0x02, 0x55, 0x05, 0x53,
+ 0x03, 'f', 'o', 'o', 0x53, 0x03, 'b', 'a', 'r', 0x53,
+ 0x03, 'b', 'a', 'z', 0x49, 0x0b, 0x40, 0x04, 0x03, 0x00},
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsArray());
+ EXPECT_EQ(3, Array::Cast(*value)->Length());
+ EXPECT_TRUE(
+ EvaluateScriptForResultBool("result.toString() === 'a,,5'"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("!(1 in result)"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("result.foo === 'bar'"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("result.baz === -6"));
+ });
+ // Sparse array in a sparse array (sanity check of nesting).
+ DecodeTestForVersion0(
+ {0x55, 0x01, 0x55, 0x01, 0x54, 0x40, 0x01, 0x02, 0x40, 0x01, 0x02, 0x00},
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsArray());
+ EXPECT_EQ(2, Array::Cast(*value)->Length());
+ EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result)"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("result[1] instanceof Array"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("!(0 in result[1])"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("result[1][1] === true"));
+ });
+}
+
} // namespace
} // namespace v8
« 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