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

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

Issue 2399873002: ValueSerializer: Add more checks before trying to allocate memory for a dense array. (Closed)
Patch Set: signed/unsigned Created 4 years, 2 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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 ASSERT_EQ(2, Array::Cast(*value)->Length()); 970 ASSERT_EQ(2, Array::Cast(*value)->Length());
971 EXPECT_TRUE( 971 EXPECT_TRUE(
972 EvaluateScriptForResultBool("typeof result[0] === 'undefined'")); 972 EvaluateScriptForResultBool("typeof result[0] === 'undefined'"));
973 EXPECT_TRUE( 973 EXPECT_TRUE(
974 EvaluateScriptForResultBool("typeof result[1] === 'undefined'")); 974 EvaluateScriptForResultBool("typeof result[1] === 'undefined'"));
975 EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(0)")); 975 EXPECT_TRUE(EvaluateScriptForResultBool("!result.hasOwnProperty(0)"));
976 EXPECT_TRUE(EvaluateScriptForResultBool("result.hasOwnProperty(1)")); 976 EXPECT_TRUE(EvaluateScriptForResultBool("result.hasOwnProperty(1)"));
977 }); 977 });
978 } 978 }
979 979
980 TEST_F(ValueSerializerTest, DecodeInvalidOverLargeArray) {
981 // So large it couldn't exist in the V8 heap, and its size couldn't fit in a
982 // SMI on 32-bit systems (2^30).
983 InvalidDecodeTest({0xff, 0x09, 0x41, 0x80, 0x80, 0x80, 0x80, 0x04});
984 // Not so large, but there isn't enough data left in the buffer.
985 InvalidDecodeTest({0xff, 0x09, 0x41, 0x01});
986 }
987
980 TEST_F(ValueSerializerTest, RoundTripArrayWithNonEnumerableElement) { 988 TEST_F(ValueSerializerTest, RoundTripArrayWithNonEnumerableElement) {
981 // Even though this array looks like [1,5,3], the 5 should be missing from the 989 // Even though this array looks like [1,5,3], the 5 should be missing from the
982 // perspective of structured clone, which only clones properties that were 990 // perspective of structured clone, which only clones properties that were
983 // enumerable. 991 // enumerable.
984 RoundTripTest( 992 RoundTripTest(
985 "(() => {" 993 "(() => {"
986 " var x = [1,2,3];" 994 " var x = [1,2,3];"
987 " Object.defineProperty(x, '1', {enumerable:false, value:5});" 995 " Object.defineProperty(x, '1', {enumerable:false, value:5});"
988 " return x;" 996 " return x;"
989 "})()", 997 "})()",
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 "({ a: new ExampleHostObject(), get b() { return this.a; }})", 2361 "({ a: new ExampleHostObject(), get b() { return this.a; }})",
2354 [this](Local<Value> value) { 2362 [this](Local<Value> value) {
2355 EXPECT_TRUE(EvaluateScriptForResultBool( 2363 EXPECT_TRUE(EvaluateScriptForResultBool(
2356 "result.a instanceof ExampleHostObject")); 2364 "result.a instanceof ExampleHostObject"));
2357 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b")); 2365 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b"));
2358 }); 2366 });
2359 } 2367 }
2360 2368
2361 } // namespace 2369 } // namespace
2362 } // namespace v8 2370 } // 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