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

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

Issue 2697023002: ValueDeserializer: Only allow valid keys when deserializing object properties. (Closed)
Patch Set: Add a unit test for a simpler version of this case. Created 3 years, 10 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // resolved. 675 // resolved.
676 DecodeTest( 676 DecodeTest(
677 {0xff, 0x09, 0x3f, 0x00, 0x6f, 0x3f, 0x01, 0x53, 0x04, 0x73, 677 {0xff, 0x09, 0x3f, 0x00, 0x6f, 0x3f, 0x01, 0x53, 0x04, 0x73,
678 0x65, 0x6c, 0x66, 0x3f, 0x01, 0x5e, 0x00, 0x7b, 0x01, 0x00}, 678 0x65, 0x6c, 0x66, 0x3f, 0x01, 0x5e, 0x00, 0x7b, 0x01, 0x00},
679 [this](Local<Value> value) { 679 [this](Local<Value> value) {
680 ASSERT_TRUE(value->IsObject()); 680 ASSERT_TRUE(value->IsObject());
681 EXPECT_TRUE(EvaluateScriptForResultBool("result === result.self")); 681 EXPECT_TRUE(EvaluateScriptForResultBool("result === result.self"));
682 }); 682 });
683 } 683 }
684 684
685 TEST_F(ValueSerializerTest, InvalidDecodeObjectWithInvalidKeyType) {
686 // Objects which would need conversion to string shouldn't be present as
687 // object keys. The serializer would have obtained them from the own property
688 // keys list, which should only contain names and indices.
689 InvalidDecodeTest(
690 {0xff, 0x09, 0x6f, 0x61, 0x00, 0x40, 0x00, 0x00, 0x7b, 0x01});
691 }
692
685 TEST_F(ValueSerializerTest, RoundTripOnlyOwnEnumerableStringKeys) { 693 TEST_F(ValueSerializerTest, RoundTripOnlyOwnEnumerableStringKeys) {
686 // Only "own" properties should be serialized, not ones on the prototype. 694 // Only "own" properties should be serialized, not ones on the prototype.
687 RoundTripTest("(() => { var x = {}; x.__proto__ = {a: 4}; return x; })()", 695 RoundTripTest("(() => { var x = {}; x.__proto__ = {a: 4}; return x; })()",
688 [this](Local<Value> value) { 696 [this](Local<Value> value) {
689 EXPECT_TRUE(EvaluateScriptForResultBool("!('a' in result)")); 697 EXPECT_TRUE(EvaluateScriptForResultBool("!('a' in result)"));
690 }); 698 });
691 // Only enumerable properties should be serialized. 699 // Only enumerable properties should be serialized.
692 RoundTripTest( 700 RoundTripTest(
693 "(() => {" 701 "(() => {"
694 " var x = {};" 702 " var x = {};"
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 InvalidDecodeTest(raw); 2691 InvalidDecodeTest(raw);
2684 } 2692 }
2685 2693
2686 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { 2694 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) {
2687 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); 2695 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00});
2688 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); 2696 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f});
2689 } 2697 }
2690 2698
2691 } // namespace 2699 } // namespace
2692 } // namespace v8 2700 } // 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