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

Unified Diff: test/mjsunit/wasm/test-wasm-module-builder.js

Issue 1767203002: [wasm] Allow Uint8Array in _WASMEXP_.instantiateModule() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/test-wasm-module-builder.js
diff --git a/test/mjsunit/wasm/test-wasm-module-builder.js b/test/mjsunit/wasm/test-wasm-module-builder.js
index 7c287efa4f1138e1c13fa29e549453407ee0709d..559e8f1e6b131ef13f38dc27dea2426039d4828e 100644
--- a/test/mjsunit/wasm/test-wasm-module-builder.js
+++ b/test/mjsunit/wasm/test-wasm-module-builder.js
@@ -88,3 +88,30 @@ var debug = false;
var instance = _WASMEXP_.instantiateModule(buffer);
assertEquals(151587081, instance.exports.load(0));
})();
+
+
+(function BasicTestWithUint8Array() {
+ var module = new WasmModuleBuilder();
+ module.addMemory(1, 2, false);
+ module.addFunction("foo", [kAstI32])
+ .addBody([kExprI8Const, 17])
+ .exportAs("blarg");
+
+ var buffer = module.toBuffer(debug);
+ var array = new Uint8Array(buffer);
+ var instance = _WASMEXP_.instantiateModule(array);
+ assertEquals(17, instance.exports.blarg());
+
+ var kPad = 5;
+ var buffer2 = new ArrayBuffer(kPad + buffer.byteLength + kPad);
+ var whole = new Uint8Array(buffer2);
+ for (var i = 0; i < whole.byteLength; i++) {
+ whole[i] = 0xff;
+ }
+ var array2 = new Uint8Array(buffer2, kPad, buffer.byteLength);
+ for (var i = 0; i < array2.byteLength; i++) {
+ array2[i] = array[i];
+ }
+ var instance = _WASMEXP_.instantiateModule(array2);
+ assertEquals(17, instance.exports.blarg());
+})();
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698