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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/wasm/wasm_serialization_tests.js

Issue 2749503002: [wasm] enable wasm structured cloning in specific cases (Closed)
Patch Set: async Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium 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 function TestInstantiateInWorker() { 5 function TestInstantiateInWorker() {
6 return createWasmModule() 6 return createWasmModule()
7 .then((mod) => { 7 .then((mod) => {
8 var worker = new Worker("wasm_serialization_worker.js"); 8 var worker = new Worker("wasm_serialization_worker.js");
9 return new Promise((resolve, reject) => { 9 return new Promise((resolve, reject) => {
10 worker.postMessage(mod); 10 worker.postMessage(mod);
(...skipping 15 matching lines...) Expand all
26 byteView[i+2] === ascii('m')) { 26 byteView[i+2] === ascii('m')) {
27 return i; 27 return i;
28 } 28 }
29 } 29 }
30 return -1; 30 return -1;
31 } 31 }
32 32
33 function TestIncompatibleDowngrade() { 33 function TestIncompatibleDowngrade() {
34 return createWasmModule() 34 return createWasmModule()
35 .then((mod) => { 35 .then((mod) => {
36 var buffer = window.internals.serializeObject(mod); 36 var buffer = window.internals.serializeWithInlineWasm(mod);
37 var byteView = new Uint8Array(buffer); 37 var byteView = new Uint8Array(buffer);
38 // The serialized payload starts with some serialization header, followed 38 // The serialized payload starts with some serialization header, followed
39 // by the wasm wire bytes. Those should start with the characters 39 // by the wasm wire bytes. Those should start with the characters
40 // 'a' 's' 'm'. 40 // 'a' 's' 'm'.
41 // Find the start of that sequence and invalidate the wire bytes by 41 // Find the start of that sequence and invalidate the wire bytes by
42 // clearing the first byte. 42 // clearing the first byte.
43 var startOfWasmHeader = findStartOfWasmHeader(byteView); 43 var startOfWasmHeader = findStartOfWasmHeader(byteView);
44 assert_greater_than(startOfWasmHeader, 0, 44 assert_greater_than(startOfWasmHeader, 0,
45 "The wire format should contain a wasm header."); 45 "The wire format should contain a wasm header.");
46 byteView[startOfWasmHeader] = 0; 46 byteView[startOfWasmHeader] = 0;
47 // Also invalidate the serialized blob. That follows the wire bytes. 47 // Also invalidate the serialized blob. That follows the wire bytes.
48 // Start from the end and clear the first non-null byte. 48 // Start from the end and clear the first non-null byte.
49 var invalidalidated = false; 49 var invalidalidated = false;
50 for (var i = byteView.length - 1; i >= startOfWasmHeader + 3; --i) { 50 for (var i = byteView.length - 1; i >= startOfWasmHeader + 3; --i) {
51 if (byteView[i] != 0) { 51 if (byteView[i] != 0) {
52 byteView[i] = 0; 52 byteView[i] = 0;
53 invalidated = true; 53 invalidated = true;
54 break; 54 break;
55 } 55 }
56 } 56 }
57 assert_true(invalidated, 57 assert_true(invalidated,
58 "the serialized blob should contain some non-null bytes."); 58 "the serialized blob should contain some non-null bytes.");
59 59
60 var deserialized = window.internals.deserializeBuffer(byteView.buffer); 60 var deserialized = window.internals.deserializeBufferContainingWasm(byteVi ew.buffer);
61 assert_equals(deserialized, null); 61 assert_equals(deserialized, null);
62 }); 62 });
63 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698