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

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

Issue 2367673003: [wasm] Do a proper HasProperty() check in the memory and table setup. (Closed)
Patch Set: Added tests also to table.js Created 4 years, 3 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/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 c04e3e2ad1de204e7ce9fa3f39e2fb7fb630cd68..0275bc05225c70e5be65032b6e0f0053b5c27cfb 100644
--- a/test/mjsunit/wasm/table.js
+++ b/test/mjsunit/wasm/table.js
@@ -9,6 +9,13 @@
var outOfUint32RangeValue = 1e12;
var int32ButOob = 1073741824;
+function assertTableIsValid(table) {
+ assertSame(WebAssembly.Table.prototype, table.__proto__);
+ assertSame(WebAssembly.Table, table.constructor);
+ assertTrue(table instanceof Object);
+ assertTrue(table instanceof WebAssembly.Table);
+}
+
(function TestConstructor() {
assertTrue(WebAssembly.Table instanceof Function);
assertSame(WebAssembly.Table, WebAssembly.Table.prototype.constructor);
@@ -39,16 +46,50 @@ var int32ButOob = 1073741824;
assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: int32ButOob}));
let table = new WebAssembly.Table({element: "anyfunc", initial: 1});
- assertSame(WebAssembly.Table.prototype, table.__proto__);
- assertSame(WebAssembly.Table, table.constructor);
- assertTrue(table instanceof Object);
- assertTrue(table instanceof WebAssembly.Table);
+ assertTableIsValid(table);
})();
(function TestConstructorWithMaximum() {
- let table = new WebAssembly.Table({element: "anyfunc", initial: 1, maximum: 10});
- assertSame(WebAssembly.Table.prototype, table.__proto__);
- assertSame(WebAssembly.Table, table.constructor);
- assertTrue(table instanceof Object);
- assertTrue(table instanceof WebAssembly.Table);
+ let table = new WebAssembly.Table({element: "anyfunc", maximum: 10});
+ assertTableIsValid(table);
+})();
+
+(function TestInitialIsUndefined() {
+ // New memory with initial = undefined, which means initial = 0.
+ let table = new WebAssembly.Table({element: "anyfunc", initial: undefined});
+ assertTableIsValid(table);
+})();
+
+(function TestMaximumIsUndefined() {
+ // New memory with maximum = undefined, which means maximum = 0.
+ let table = new WebAssembly.Table({element: "anyfunc", initial: 0, maximum: undefined});
+ assertTableIsValid(table);
+})();
+
+(function TestMaximumIsReadOnce() {
+ var a = true;
+ var desc = {element: "anyfunc", initial: 10};
+ Object.defineProperty(desc, 'maximum', {get: function() {
+ if (a) {
+ a = false;
+ return 16;
+ }
+ else {
+ // Change the return value on the second call so it throws.
+ return -1;
+ }
+ }});
+ let table = new WebAssembly.Table(desc);
+ assertTableIsValid(table);
+})();
+
+(function TestMaximumDoesHasProperty() {
+ var hasPropertyWasCalled = false;
+ var desc = {element: "anyfunc", initial: 10};
+ var proxy = new Proxy({maximum: 16}, {
+ has: function(target, name) { hasPropertyWasCalled = true; }
+ });
+ Object.setPrototypeOf(desc, proxy);
+ let table = new WebAssembly.Table(desc);
+ assertTableIsValid(table);
})();
« no previous file with comments | « test/mjsunit/wasm/memory.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698