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

Unified Diff: test/mjsunit/wasm/table.js

Issue 2636173002: [wasm] Enforce memory and table limits during instantiation. (Closed)
Patch Set: 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
« test/mjsunit/wasm/indirect-tables.js ('K') | « test/mjsunit/wasm/module-memory.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/table.js
diff --git a/test/mjsunit/wasm/table.js b/test/mjsunit/wasm/table.js
index d2b0dcdee6c6d197181eb767f1e3136dbf575b64..deaa47dd9c9f221895f3e78e481517d1687370a4 100644
--- a/test/mjsunit/wasm/table.js
+++ b/test/mjsunit/wasm/table.js
@@ -13,6 +13,8 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
var outOfUint32RangeValue = 1e12;
var int32ButOob = 1073741824;
+var kMaxUint32 = (4 * 1024 * 1024 * 1024) - 1;
+var kV8MaxWasmTableSize = 10000000;
function assertTableIsValid(table) {
assertSame(WebAssembly.Table.prototype, table.__proto__);
@@ -48,8 +50,6 @@ function assertTableIsValid(table) {
assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: outOfUint32RangeValue}), RangeError);
assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: 9}), RangeError);
- assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: int32ButOob}));
-
let table;
table = new WebAssembly.Table({element: "anyfunc", initial: 1});
assertTableIsValid(table);
@@ -94,6 +94,14 @@ function assertTableIsValid(table) {
table = new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: undefined});
assertTableIsValid(table);
assertEquals(0, table.length);
+
+ table = new WebAssembly.Table({element: "anyfunc", maximum: kMaxUint32});
+ assertTableIsValid(table);
+ assertEquals(0, table.length);
+
+ table = new WebAssembly.Table({element: "anyfunc", maximum: kV8MaxWasmTableSize + 1});
+ assertTableIsValid(table);
+ assertEquals(0, table.length);
})();
(function TestMaximumIsReadOnce() {
@@ -260,4 +268,8 @@ function assertTableIsValid(table) {
assertThrows(() => table.grow(-10), RangeError);
assertThrows(() => WebAssembly.Table.prototype.grow.call([], 0), TypeError);
+
+ table = new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: kV8MaxWasmTableSize});
rossberg 2017/01/17 14:22:06 Nit: line length
titzer 2017/01/17 16:47:18 Done.
+ table.grow(kV8MaxWasmTableSize);
+ assertThrows(() => table.grow(1), RangeError);
})();
« test/mjsunit/wasm/indirect-tables.js ('K') | « test/mjsunit/wasm/module-memory.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698