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

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

Issue 2696133007: ValueSerializer: Add SetTreatArrayBufferViewsAsHostObjects() flag (Closed)
Patch Set: 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 2a57ab38e5092bf0d7f40b0019436f6cbabbd2e5..ab1527330aa3953c70f1ac0171fe9bf8d061acc5 100644
--- a/test/unittests/value-serializer-unittest.cc
+++ b/test/unittests/value-serializer-unittest.cc
@@ -2537,6 +2537,35 @@ TEST_F(ValueSerializerTestWithHostObject, RoundTripSameObject) {
});
}
+class ValueSerializerTestWithHostArrayBufferView
+ : public ValueSerializerTestWithHostObject {
+ protected:
+ void BeforeEncode(ValueSerializer* serializer) override {
+ serializer_ = serializer;
jbroman 2017/02/16 23:10:03 nit: prefer to call the superclass method rather t
Anna Henningsen 2017/02/17 12:22:55 Done.
+ serializer_->SetTreatArrayBufferViewsAsHostObjects(true);
+ }
+};
+
+TEST_F(ValueSerializerTestWithHostArrayBufferView, RoundTripUint8ArrayInput) {
+ EXPECT_CALL(serializer_delegate_, WriteHostObject(isolate(), _))
+ .WillOnce(Invoke([this](Isolate*, Local<Object> object) {
jbroman 2017/02/16 23:10:03 nit: EXPECT_TRUE(object->IsUint8Array()); Maybe a
Anna Henningsen 2017/02/17 12:22:55 Done, except for the second part... I can do that
+ WriteExampleHostObjectTag();
+ return Just(true);
+ }));
+ EXPECT_CALL(deserializer_delegate_, ReadHostObject(isolate()))
+ .WillOnce(Invoke([this](Isolate*) {
+ EXPECT_TRUE(ReadExampleHostObjectTag());
+ return NewHostObject(deserialization_context(), 0, nullptr);
jbroman 2017/02/16 23:10:03 nit: it's a little weird to produce an entirely di
Anna Henningsen 2017/02/17 12:22:55 Done.
+ }));
+ RoundTripTest(
+ "({ a: new Uint8Array([1, 2, 3]), get b() { return this.a; }})",
+ [this](Local<Value> value) {
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "result.a instanceof ExampleHostObject"));
+ EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b"));
+ });
+}
+
// It's expected that WebAssembly has more exhaustive tests elsewhere; this
// mostly checks that the logic to embed it in structured clone serialization
// works correctly.
« 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