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

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

Issue 2762163002: Revert of [wasm] Transferrable modules (Closed)
Patch Set: Created 3 years, 9 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 | « test/cctest/wasm/test-run-wasm-module.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 } 68 }
69 69
70 const Local<Context>& serialization_context() { 70 const Local<Context>& serialization_context() {
71 return serialization_context_; 71 return serialization_context_;
72 } 72 }
73 const Local<Context>& deserialization_context() { 73 const Local<Context>& deserialization_context() {
74 return deserialization_context_; 74 return deserialization_context_;
75 } 75 }
76 76
77 bool ExpectInlineWasm() const { return expect_inline_wasm_; }
78 void SetExpectInlineWasm(bool value) { expect_inline_wasm_ = value; }
79
80 // Overridden in more specific fixtures. 77 // Overridden in more specific fixtures.
81 virtual ValueSerializer::Delegate* GetSerializerDelegate() { return nullptr; } 78 virtual ValueSerializer::Delegate* GetSerializerDelegate() { return nullptr; }
82 virtual void BeforeEncode(ValueSerializer*) {} 79 virtual void BeforeEncode(ValueSerializer*) {}
83 virtual void AfterEncode() {} 80 virtual void AfterEncode() {}
84 virtual ValueDeserializer::Delegate* GetDeserializerDelegate() { 81 virtual ValueDeserializer::Delegate* GetDeserializerDelegate() {
85 return nullptr; 82 return nullptr;
86 } 83 }
87 virtual void BeforeDecode(ValueDeserializer*) {} 84 virtual void BeforeDecode(ValueDeserializer*) {}
88 85
89 template <typename InputFunctor, typename OutputFunctor> 86 template <typename InputFunctor, typename OutputFunctor>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 template <typename OutputFunctor> 165 template <typename OutputFunctor>
169 void DecodeTest(const std::vector<uint8_t>& data, 166 void DecodeTest(const std::vector<uint8_t>& data,
170 const OutputFunctor& output_functor) { 167 const OutputFunctor& output_functor) {
171 Local<Context> context = deserialization_context(); 168 Local<Context> context = deserialization_context();
172 Context::Scope scope(context); 169 Context::Scope scope(context);
173 TryCatch try_catch(isolate()); 170 TryCatch try_catch(isolate());
174 ValueDeserializer deserializer(isolate(), &data[0], 171 ValueDeserializer deserializer(isolate(), &data[0],
175 static_cast<int>(data.size()), 172 static_cast<int>(data.size()),
176 GetDeserializerDelegate()); 173 GetDeserializerDelegate());
177 deserializer.SetSupportsLegacyWireFormat(true); 174 deserializer.SetSupportsLegacyWireFormat(true);
178 deserializer.SetExpectInlineWasm(ExpectInlineWasm());
179 BeforeDecode(&deserializer); 175 BeforeDecode(&deserializer);
180 ASSERT_TRUE(deserializer.ReadHeader(context).FromMaybe(false)); 176 ASSERT_TRUE(deserializer.ReadHeader(context).FromMaybe(false));
181 Local<Value> result; 177 Local<Value> result;
182 ASSERT_TRUE(deserializer.ReadValue(context).ToLocal(&result)); 178 ASSERT_TRUE(deserializer.ReadValue(context).ToLocal(&result));
183 ASSERT_FALSE(result.IsEmpty()); 179 ASSERT_FALSE(result.IsEmpty());
184 ASSERT_FALSE(try_catch.HasCaught()); 180 ASSERT_FALSE(try_catch.HasCaught());
185 ASSERT_TRUE( 181 ASSERT_TRUE(
186 context->Global() 182 context->Global()
187 ->CreateDataProperty(context, StringFromUtf8("result"), result) 183 ->CreateDataProperty(context, StringFromUtf8("result"), result)
188 .FromMaybe(false)); 184 .FromMaybe(false));
189 output_functor(result); 185 output_functor(result);
190 ASSERT_FALSE(try_catch.HasCaught()); 186 ASSERT_FALSE(try_catch.HasCaught());
191 } 187 }
192 188
193 template <typename OutputFunctor> 189 template <typename OutputFunctor>
194 void DecodeTestForVersion0(const std::vector<uint8_t>& data, 190 void DecodeTestForVersion0(const std::vector<uint8_t>& data,
195 const OutputFunctor& output_functor) { 191 const OutputFunctor& output_functor) {
196 Local<Context> context = deserialization_context(); 192 Local<Context> context = deserialization_context();
197 Context::Scope scope(context); 193 Context::Scope scope(context);
198 TryCatch try_catch(isolate()); 194 TryCatch try_catch(isolate());
199 ValueDeserializer deserializer(isolate(), &data[0], 195 ValueDeserializer deserializer(isolate(), &data[0],
200 static_cast<int>(data.size()), 196 static_cast<int>(data.size()),
201 GetDeserializerDelegate()); 197 GetDeserializerDelegate());
202 deserializer.SetSupportsLegacyWireFormat(true); 198 deserializer.SetSupportsLegacyWireFormat(true);
203 deserializer.SetExpectInlineWasm(ExpectInlineWasm());
204 BeforeDecode(&deserializer); 199 BeforeDecode(&deserializer);
205 ASSERT_TRUE(deserializer.ReadHeader(context).FromMaybe(false)); 200 ASSERT_TRUE(deserializer.ReadHeader(context).FromMaybe(false));
206 ASSERT_EQ(0u, deserializer.GetWireFormatVersion()); 201 ASSERT_EQ(0u, deserializer.GetWireFormatVersion());
207 Local<Value> result; 202 Local<Value> result;
208 ASSERT_TRUE(deserializer.ReadValue(context).ToLocal(&result)); 203 ASSERT_TRUE(deserializer.ReadValue(context).ToLocal(&result));
209 ASSERT_FALSE(result.IsEmpty()); 204 ASSERT_FALSE(result.IsEmpty());
210 ASSERT_FALSE(try_catch.HasCaught()); 205 ASSERT_FALSE(try_catch.HasCaught());
211 ASSERT_TRUE( 206 ASSERT_TRUE(
212 context->Global() 207 context->Global()
213 ->CreateDataProperty(context, StringFromUtf8("result"), result) 208 ->CreateDataProperty(context, StringFromUtf8("result"), result)
214 .FromMaybe(false)); 209 .FromMaybe(false));
215 output_functor(result); 210 output_functor(result);
216 ASSERT_FALSE(try_catch.HasCaught()); 211 ASSERT_FALSE(try_catch.HasCaught());
217 } 212 }
218 213
219 void InvalidDecodeTest(const std::vector<uint8_t>& data) { 214 void InvalidDecodeTest(const std::vector<uint8_t>& data) {
220 Local<Context> context = deserialization_context(); 215 Local<Context> context = deserialization_context();
221 Context::Scope scope(context); 216 Context::Scope scope(context);
222 TryCatch try_catch(isolate()); 217 TryCatch try_catch(isolate());
223 ValueDeserializer deserializer(isolate(), &data[0], 218 ValueDeserializer deserializer(isolate(), &data[0],
224 static_cast<int>(data.size()), 219 static_cast<int>(data.size()),
225 GetDeserializerDelegate()); 220 GetDeserializerDelegate());
226 deserializer.SetSupportsLegacyWireFormat(true); 221 deserializer.SetSupportsLegacyWireFormat(true);
227 deserializer.SetExpectInlineWasm(ExpectInlineWasm());
228 BeforeDecode(&deserializer); 222 BeforeDecode(&deserializer);
229 Maybe<bool> header_result = deserializer.ReadHeader(context); 223 Maybe<bool> header_result = deserializer.ReadHeader(context);
230 if (header_result.IsNothing()) { 224 if (header_result.IsNothing()) {
231 EXPECT_TRUE(try_catch.HasCaught()); 225 EXPECT_TRUE(try_catch.HasCaught());
232 return; 226 return;
233 } 227 }
234 ASSERT_TRUE(header_result.ToChecked()); 228 ASSERT_TRUE(header_result.ToChecked());
235 ASSERT_TRUE(deserializer.ReadValue(context).IsEmpty()); 229 ASSERT_TRUE(deserializer.ReadValue(context).IsEmpty());
236 EXPECT_TRUE(try_catch.HasCaught()); 230 EXPECT_TRUE(try_catch.HasCaught());
237 } 231 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 Local<ArrayBuffer> ab = 268 Local<ArrayBuffer> ab =
275 ArrayBuffer::New(isolate(), static_cast<void*>(data), sizeof(data)); 269 ArrayBuffer::New(isolate(), static_cast<void*>(data), sizeof(data));
276 return Uint8Array::New(ab, 0, sizeof(data)); 270 return Uint8Array::New(ab, 0, sizeof(data));
277 } 271 }
278 272
279 private: 273 private:
280 Local<Context> serialization_context_; 274 Local<Context> serialization_context_;
281 Local<Context> deserialization_context_; 275 Local<Context> deserialization_context_;
282 Local<FunctionTemplate> host_object_constructor_template_; 276 Local<FunctionTemplate> host_object_constructor_template_;
283 i::Isolate* isolate_; 277 i::Isolate* isolate_;
284 bool expect_inline_wasm_ = false;
285 278
286 DISALLOW_COPY_AND_ASSIGN(ValueSerializerTest); 279 DISALLOW_COPY_AND_ASSIGN(ValueSerializerTest);
287 }; 280 };
288 281
289 TEST_F(ValueSerializerTest, DecodeInvalid) { 282 TEST_F(ValueSerializerTest, DecodeInvalid) {
290 // Version tag but no content. 283 // Version tag but no content.
291 InvalidDecodeTest({0xff}); 284 InvalidDecodeTest({0xff});
292 // Version too large. 285 // Version too large.
293 InvalidDecodeTest({0xff, 0x7f, 0x5f}); 286 InvalidDecodeTest({0xff, 0x7f, 0x5f});
294 // Nonsense tag. 287 // Nonsense tag.
(...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 EXPECT_TRUE( 2587 EXPECT_TRUE(
2595 EvaluateScriptForResultBool("result.a.toString() === '4,5,6'")); 2588 EvaluateScriptForResultBool("result.a.toString() === '4,5,6'"));
2596 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b")); 2589 EXPECT_TRUE(EvaluateScriptForResultBool("result.a === result.b"));
2597 }); 2590 });
2598 } 2591 }
2599 2592
2600 // It's expected that WebAssembly has more exhaustive tests elsewhere; this 2593 // It's expected that WebAssembly has more exhaustive tests elsewhere; this
2601 // mostly checks that the logic to embed it in structured clone serialization 2594 // mostly checks that the logic to embed it in structured clone serialization
2602 // works correctly. 2595 // works correctly.
2603 2596
2597 class ValueSerializerTestWithWasm : public ValueSerializerTest {
2598 protected:
2599 static void SetUpTestCase() {
2600 g_saved_flag = i::FLAG_expose_wasm;
2601 i::FLAG_expose_wasm = true;
2602 ValueSerializerTest::SetUpTestCase();
2603 }
2604
2605 static void TearDownTestCase() {
2606 ValueSerializerTest::TearDownTestCase();
2607 i::FLAG_expose_wasm = g_saved_flag;
2608 g_saved_flag = false;
2609 }
2610
2611 private:
2612 static bool g_saved_flag;
2613 };
2614
2615 bool ValueSerializerTestWithWasm::g_saved_flag = false;
2616
2604 // A simple module which exports an "increment" function. 2617 // A simple module which exports an "increment" function.
2605 // Copied from test/mjsunit/wasm/incrementer.wasm. 2618 // Copied from test/mjsunit/wasm/incrementer.wasm.
2606 const unsigned char kIncrementerWasm[] = { 2619 const unsigned char kIncrementerWasm[] = {
2607 0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 127, 2620 0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 127,
2608 3, 2, 1, 0, 7, 13, 1, 9, 105, 110, 99, 114, 101, 109, 101, 110, 2621 3, 2, 1, 0, 7, 13, 1, 9, 105, 110, 99, 114, 101, 109, 101, 110,
2609 116, 0, 0, 10, 9, 1, 7, 0, 32, 0, 65, 1, 106, 11, 2622 116, 0, 0, 10, 9, 1, 7, 0, 32, 0, 65, 1, 106, 11,
2610 }; 2623 };
2611 2624
2612 class ValueSerializerTestWithWasm : public ValueSerializerTest { 2625 TEST_F(ValueSerializerTestWithWasm, RoundTripWasmModule) {
2613 public: 2626 RoundTripTest(
2614 static const char* kUnsupportedSerialization; 2627 [this]() {
2615 2628 return WasmCompiledModule::DeserializeOrCompile(
2616 ValueSerializerTestWithWasm() 2629 isolate(), {nullptr, 0},
2617 : serialize_delegate_(&transfer_modules_), 2630 {kIncrementerWasm, sizeof(kIncrementerWasm)})
2618 deserialize_delegate_(&transfer_modules_) {}
2619
2620 void Reset() {
2621 current_serializer_delegate_ = nullptr;
2622 transfer_modules_.clear();
2623 SetExpectInlineWasm(false);
2624 }
2625
2626 void EnableTransferSerialization() {
2627 current_serializer_delegate_ = &serialize_delegate_;
2628 }
2629
2630 void EnableTransferDeserialization() {
2631 current_deserializer_delegate_ = &deserialize_delegate_;
2632 }
2633
2634 void EnableThrowingSerializer() {
2635 current_serializer_delegate_ = &throwing_serializer_;
2636 }
2637
2638 void EnableDefaultDeserializer() {
2639 current_deserializer_delegate_ = &default_deserializer_;
2640 }
2641
2642 protected:
2643 static void SetUpTestCase() {
2644 g_saved_flag = i::FLAG_expose_wasm;
2645 i::FLAG_expose_wasm = true;
2646 ValueSerializerTest::SetUpTestCase();
2647 }
2648
2649 static void TearDownTestCase() {
2650 ValueSerializerTest::TearDownTestCase();
2651 i::FLAG_expose_wasm = g_saved_flag;
2652 g_saved_flag = false;
2653 }
2654
2655 class ThrowingSerializer : public ValueSerializer::Delegate {
2656 public:
2657 Maybe<uint32_t> GetWasmModuleTransferId(
2658 Isolate* isolate, Local<WasmCompiledModule> module) override {
2659 isolate->ThrowException(Exception::Error(
2660 String::NewFromOneByte(
2661 isolate,
2662 reinterpret_cast<const uint8_t*>(kUnsupportedSerialization),
2663 NewStringType::kNormal)
2664 .ToLocalChecked()));
2665 return Nothing<uint32_t>();
2666 }
2667
2668 void ThrowDataCloneError(Local<String> message) override { UNREACHABLE(); }
2669 };
2670
2671 class SerializeToTransfer : public ValueSerializer::Delegate {
2672 public:
2673 SerializeToTransfer(
2674 std::vector<WasmCompiledModule::TransferrableModule>* modules)
2675 : modules_(modules) {}
2676 Maybe<uint32_t> GetWasmModuleTransferId(
2677 Isolate* isolate, Local<WasmCompiledModule> module) override {
2678 modules_->push_back(module->GetTransferrableModule());
2679 return Just(static_cast<uint32_t>(modules_->size()) - 1);
2680 }
2681
2682 void ThrowDataCloneError(Local<String> message) override { UNREACHABLE(); }
2683
2684 private:
2685 std::vector<WasmCompiledModule::TransferrableModule>* modules_;
2686 };
2687
2688 class DeserializeFromTransfer : public ValueDeserializer::Delegate {
2689 public:
2690 DeserializeFromTransfer(
2691 std::vector<WasmCompiledModule::TransferrableModule>* modules)
2692 : modules_(modules) {}
2693
2694 MaybeLocal<WasmCompiledModule> GetWasmModuleFromId(Isolate* isolate,
2695 uint32_t id) override {
2696 return WasmCompiledModule::FromTransferrableModule(isolate,
2697 modules_->at(id));
2698 }
2699
2700 private:
2701 std::vector<WasmCompiledModule::TransferrableModule>* modules_;
2702 };
2703
2704 ValueSerializer::Delegate* GetSerializerDelegate() override {
2705 return current_serializer_delegate_;
2706 }
2707
2708 ValueDeserializer::Delegate* GetDeserializerDelegate() override {
2709 return current_deserializer_delegate_;
2710 }
2711
2712 Local<WasmCompiledModule> MakeWasm() {
2713 return WasmCompiledModule::DeserializeOrCompile(
2714 isolate(), {nullptr, 0},
2715 {kIncrementerWasm, sizeof(kIncrementerWasm)})
2716 .ToLocalChecked();
2717 }
2718
2719 void ExpectPass() {
2720 RoundTripTest(
2721 [this]() { return MakeWasm(); },
2722 [this](Local<Value> value) {
2723 ASSERT_TRUE(value->IsWebAssemblyCompiledModule());
2724 EXPECT_TRUE(EvaluateScriptForResultBool(
2725 "new WebAssembly.Instance(result).exports.increment(8) === 9"));
2726 });
2727 }
2728
2729 void ExpectFail() {
2730 EncodeTest(
2731 [this]() { return MakeWasm(); },
2732 [this](const std::vector<uint8_t>& data) { InvalidDecodeTest(data); });
2733 }
2734
2735 Local<Value> GetComplexObjectWithDuplicate() {
2736 Local<Value> wasm_module = MakeWasm();
2737 serialization_context()
2738 ->Global()
2739 ->CreateDataProperty(serialization_context(),
2740 StringFromUtf8("wasm_module"), wasm_module)
2741 .FromMaybe(false);
2742 Local<Script> script =
2743 Script::Compile(
2744 serialization_context(),
2745 StringFromUtf8("({mod1: wasm_module, num: 2, mod2: wasm_module})"))
2746 .ToLocalChecked(); 2631 .ToLocalChecked();
2747 return script->Run(serialization_context()).ToLocalChecked(); 2632 },
2748 } 2633 [this](Local<Value> value) {
2749 2634 ASSERT_TRUE(value->IsWebAssemblyCompiledModule());
2750 void VerifyComplexObject(Local<Value> value) { 2635 EXPECT_TRUE(EvaluateScriptForResultBool(
2751 ASSERT_TRUE(value->IsObject()); 2636 "new WebAssembly.Instance(result).exports.increment(8) === 9"));
2752 EXPECT_TRUE(EvaluateScriptForResultBool(
2753 "result.mod1 instanceof WebAssembly.Module"));
2754 EXPECT_TRUE(EvaluateScriptForResultBool(
2755 "result.mod2 instanceof WebAssembly.Module"));
2756 EXPECT_TRUE(EvaluateScriptForResultBool("result.num === 2"));
2757 }
2758
2759 Local<Value> GetComplexObjectWithMany() {
2760 Local<Value> wasm_module1 = MakeWasm();
2761 Local<Value> wasm_module2 = MakeWasm();
2762 serialization_context()
2763 ->Global()
2764 ->CreateDataProperty(serialization_context(),
2765 StringFromUtf8("wasm_module1"), wasm_module1)
2766 .FromMaybe(false);
2767 serialization_context()
2768 ->Global()
2769 ->CreateDataProperty(serialization_context(),
2770 StringFromUtf8("wasm_module2"), wasm_module2)
2771 .FromMaybe(false);
2772 Local<Script> script =
2773 Script::Compile(
2774 serialization_context(),
2775 StringFromUtf8(
2776 "({mod1: wasm_module1, num: 2, mod2: wasm_module2})"))
2777 .ToLocalChecked();
2778 return script->Run(serialization_context()).ToLocalChecked();
2779 }
2780
2781 private:
2782 static bool g_saved_flag;
2783 std::vector<WasmCompiledModule::TransferrableModule> transfer_modules_;
2784 SerializeToTransfer serialize_delegate_;
2785 DeserializeFromTransfer deserialize_delegate_;
2786 ValueSerializer::Delegate* current_serializer_delegate_ = nullptr;
2787 ValueDeserializer::Delegate* current_deserializer_delegate_ = nullptr;
2788 ThrowingSerializer throwing_serializer_;
2789 ValueDeserializer::Delegate default_deserializer_;
2790 };
2791
2792 bool ValueSerializerTestWithWasm::g_saved_flag = false;
2793 const char* ValueSerializerTestWithWasm::kUnsupportedSerialization =
2794 "Wasm Serialization Not Supported";
2795
2796 // The default implementation of the serialization
2797 // delegate throws when trying to serialize wasm. The
2798 // embedder must decide serialization policy.
2799 TEST_F(ValueSerializerTestWithWasm, DefaultSerializationDelegate) {
2800 EnableThrowingSerializer();
2801 InvalidEncodeTest(
2802 [this]() { return MakeWasm(); },
2803 [](Local<Message> message) {
2804 size_t msg_len = static_cast<size_t>(message->Get()->Length());
2805 std::unique_ptr<char[]> buff(new char[msg_len + 1]);
2806 message->Get()->WriteOneByte(reinterpret_cast<uint8_t*>(buff.get()));
2807 // the message ends with the custom error string
2808 size_t custom_msg_len = strlen(kUnsupportedSerialization);
2809 ASSERT_GE(msg_len, custom_msg_len);
2810 size_t start_pos = msg_len - custom_msg_len;
2811 ASSERT_EQ(strcmp(&buff.get()[start_pos], kUnsupportedSerialization), 0);
2812 }); 2637 });
2813 } 2638 }
2814 2639
2815 // The default deserializer throws if wasm transfer is attempted
2816 TEST_F(ValueSerializerTestWithWasm, DefaultDeserializationDelegate) {
2817 EnableTransferSerialization();
2818 EnableDefaultDeserializer();
2819 EncodeTest(
2820 [this]() { return MakeWasm(); },
2821 [this](const std::vector<uint8_t>& data) { InvalidDecodeTest(data); });
2822 }
2823
2824 // We only want to allow deserialization through
2825 // transferred modules - which requres both serializer
2826 // and deserializer to understand that - or through
2827 // explicitly allowing inlined data, which requires
2828 // deserializer opt-in (we default the serializer to
2829 // inlined data because we don't trust that data on the
2830 // receiving end anyway).
2831
2832 TEST_F(ValueSerializerTestWithWasm, RoundtripWasmTransfer) {
2833 EnableTransferSerialization();
2834 EnableTransferDeserialization();
2835 ExpectPass();
2836 }
2837
2838 TEST_F(ValueSerializerTestWithWasm, RountripWasmInline) {
2839 SetExpectInlineWasm(true);
2840 ExpectPass();
2841 }
2842
2843 TEST_F(ValueSerializerTestWithWasm, CannotDeserializeWasmInlineData) {
2844 ExpectFail();
2845 }
2846
2847 TEST_F(ValueSerializerTestWithWasm, CannotTransferWasmWhenExpectingInline) {
2848 EnableTransferSerialization();
2849 SetExpectInlineWasm(true);
2850 ExpectFail();
2851 }
2852
2853 TEST_F(ValueSerializerTestWithWasm, ComplexObjectDuplicateTransfer) {
2854 EnableTransferSerialization();
2855 EnableTransferDeserialization();
2856 RoundTripTest(
2857 [this]() { return GetComplexObjectWithDuplicate(); },
2858 [this](Local<Value> value) {
2859 VerifyComplexObject(value);
2860 EXPECT_TRUE(EvaluateScriptForResultBool("result.mod1 === result.mod2"));
2861 });
2862 }
2863
2864 TEST_F(ValueSerializerTestWithWasm, ComplexObjectDuplicateInline) {
2865 SetExpectInlineWasm(true);
2866 RoundTripTest(
2867 [this]() { return GetComplexObjectWithDuplicate(); },
2868 [this](Local<Value> value) {
2869 VerifyComplexObject(value);
2870 EXPECT_TRUE(EvaluateScriptForResultBool("result.mod1 === result.mod2"));
2871 });
2872 }
2873
2874 TEST_F(ValueSerializerTestWithWasm, ComplexObjectWithManyTransfer) {
2875 EnableTransferSerialization();
2876 EnableTransferDeserialization();
2877 RoundTripTest(
2878 [this]() { return GetComplexObjectWithMany(); },
2879 [this](Local<Value> value) {
2880 VerifyComplexObject(value);
2881 EXPECT_TRUE(EvaluateScriptForResultBool("result.mod1 != result.mod2"));
2882 });
2883 }
2884
2885 TEST_F(ValueSerializerTestWithWasm, ComplexObjectWithManyInline) {
2886 SetExpectInlineWasm(true);
2887 RoundTripTest(
2888 [this]() { return GetComplexObjectWithMany(); },
2889 [this](Local<Value> value) {
2890 VerifyComplexObject(value);
2891 EXPECT_TRUE(EvaluateScriptForResultBool("result.mod1 != result.mod2"));
2892 });
2893 }
2894
2895 // As produced around Chrome 56. 2640 // As produced around Chrome 56.
2896 const unsigned char kSerializedIncrementerWasm[] = { 2641 const unsigned char kSerializedIncrementerWasm[] = {
2897 0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x2d, 0x00, 0x61, 0x73, 0x6d, 0x0d, 2642 0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x2d, 0x00, 0x61, 0x73, 0x6d, 0x0d,
2898 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60, 0x01, 0x7f, 0x01, 0x7f, 0x03, 2643 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60, 0x01, 0x7f, 0x01, 0x7f, 0x03,
2899 0x02, 0x01, 0x00, 0x07, 0x0d, 0x01, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65, 2644 0x02, 0x01, 0x00, 0x07, 0x0d, 0x01, 0x09, 0x69, 0x6e, 0x63, 0x72, 0x65,
2900 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x0a, 0x08, 0x01, 0x06, 0x00, 0x20, 2645 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x0a, 0x08, 0x01, 0x06, 0x00, 0x20,
2901 0x00, 0x41, 0x01, 0x6a, 0xf8, 0x04, 0xa1, 0x06, 0xde, 0xc0, 0xc6, 0x44, 2646 0x00, 0x41, 0x01, 0x6a, 0xf8, 0x04, 0xa1, 0x06, 0xde, 0xc0, 0xc6, 0x44,
2902 0x3c, 0x29, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x02, 0x00, 0x00, 0x81, 0x4e, 2647 0x3c, 0x29, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x02, 0x00, 0x00, 0x81, 0x4e,
2903 0xce, 0x7c, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x30, 0x02, 2648 0xce, 0x7c, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x30, 0x02,
2904 0x00, 0x00, 0xb0, 0x25, 0x30, 0xe3, 0xf2, 0xdb, 0x2e, 0x48, 0x00, 0x00, 2649 0x00, 0x00, 0xb0, 0x25, 0x30, 0xe3, 0xf2, 0xdb, 0x2e, 0x48, 0x00, 0x00,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 InvalidDecodeTest(raw); 2744 InvalidDecodeTest(raw);
3000 } 2745 }
3001 2746
3002 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { 2747 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) {
3003 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); 2748 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00});
3004 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); 2749 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f});
3005 } 2750 }
3006 2751
3007 } // namespace 2752 } // namespace
3008 } // namespace v8 2753 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698