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

Unified Diff: test/mjsunit/wasm/indirect-tables.js

Issue 2636173002: [wasm] Enforce memory and table limits during instantiation. (Closed)
Patch Set: [wasm] Enforce memory and table limits during instantiation. Created 3 years, 11 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 | « test/mjsunit/wasm/import-memory.js ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/indirect-tables.js
diff --git a/test/mjsunit/wasm/indirect-tables.js b/test/mjsunit/wasm/indirect-tables.js
index 057d0f3661f044879a28dc6015484182a8ee1f19..80920c91c63fdd1fe8c31b2371e542da374de97e 100644
--- a/test/mjsunit/wasm/indirect-tables.js
+++ b/test/mjsunit/wasm/indirect-tables.js
@@ -199,7 +199,8 @@ function js_div(a, b) { return (a / b) | 0; }
for (let i = 0; i < 5; i++) {
print(" base = " + i);
let table = new WebAssembly.Table({element: "anyfunc",
- initial: kTableSize});
+ initial: kTableSize,
+ maximum: kTableSize});
assertEquals(10, table.length);
let i2 = new WebAssembly.Instance(m2, {q: {base: i, table: table,
js_div: js_div}});
@@ -242,7 +243,8 @@ function js_div(a, b) { return (a / b) | 0; }
print("CumulativeTest...");
let kTableSize = 10;
- let table = new WebAssembly.Table({element: "anyfunc", initial: 10});
+ let table = new WebAssembly.Table(
+ {element: "anyfunc", initial: kTableSize, maximum: kTableSize});
var builder = new WasmModuleBuilder();
@@ -457,3 +459,22 @@ function js_div(a, b) { return (a / b) | 0; }
}
assertThrows(() => table.grow(11));
})();
+
+
+(function TestImportTooLarge() {
+ print("TestImportTooLarge...");
+ let builder = new WasmModuleBuilder();
+ builder.addImportedTable("t", "t", 1, 2);
+
+ // initial size is too large
+ assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
+ {element: "anyfunc", initial: 3, maximum: 3})}}));
+
+ // maximum size is too large
+ assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
+ {element: "anyfunc", initial: 1, maximum: 4})}}));
+
+ // no maximum
+ assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
+ {element: "anyfunc", initial: 1})}}));
+})();
« no previous file with comments | « test/mjsunit/wasm/import-memory.js ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698