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

Unified Diff: test/unittests/value-serializer-unittest.cc

Issue 2709023003: ValueSerializer: Add an explicit tag for host objects. (Closed)
Patch Set: correct version number 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 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 1a5fbe3e3c39f6c4184e915fd58b7a2cbb9024d4..cd2afa09f12559fb24e77bcfde59785089ed1a50 100644
--- a/test/unittests/value-serializer-unittest.cc
+++ b/test/unittests/value-serializer-unittest.cc
@@ -2370,8 +2370,9 @@ class ValueSerializerTestWithHostObject : public ValueSerializerTest {
friend class DeserializerDelegate;
};
-// This is a tag that's not used in V8.
-const uint8_t ValueSerializerTestWithHostObject::kExampleHostObjectTag = '+';
+// This is a tag that is used in V8. Using this ensures that we have separate
+// tag namespaces.
+const uint8_t ValueSerializerTestWithHostObject::kExampleHostObjectTag = 'T';
TEST_F(ValueSerializerTestWithHostObject, RoundTripUint32) {
// The host can serialize data as uint32_t.
@@ -2544,6 +2545,19 @@ TEST_F(ValueSerializerTestWithHostObject, RoundTripSameObject) {
});
}
+TEST_F(ValueSerializerTestWithHostObject, DecodeSimpleHostObject) {
+ EXPECT_CALL(deserializer_delegate_, ReadHostObject(isolate()))
+ .WillRepeatedly(Invoke([this](Isolate*) {
+ EXPECT_TRUE(ReadExampleHostObjectTag());
+ return NewHostObject(deserialization_context(), 0, nullptr);
+ }));
+ DecodeTest(
+ {0xff, 0x0d, 0x5c, kExampleHostObjectTag}, [this](Local<Value> value) {
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "Object.getPrototypeOf(result) === ExampleHostObject.prototype"));
+ });
+}
+
class ValueSerializerTestWithHostArrayBufferView
: public ValueSerializerTestWithHostObject {
protected:
« 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