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

Unified Diff: test/mjsunit/wasm/add-getters.js

Issue 2554343002: [runtime] Add instance size check for CheckEquivalent(). (Closed)
Patch Set: Fix the header size calculation for modules. Created 4 years 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/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/add-getters.js
diff --git a/test/mjsunit/wasm/add-getters.js b/test/mjsunit/wasm/add-getters.js
new file mode 100644
index 0000000000000000000000000000000000000000..029f58f11bfec05c74668aeee4e1d27362554308
--- /dev/null
+++ b/test/mjsunit/wasm/add-getters.js
@@ -0,0 +1,68 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-wasm
+
+load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
+
+function testAddGetter(object, name, val) {
+ Object.defineProperty(object, name, { get: function() { return val; } });
+ assertSame(val, object[name]);
+}
+
+function testAddGetterBothWays(object, name, val) {
+ print("Object.defineProperty");
+ Object.defineProperty(object, name, { get: function() { return val; } });
+ print("object.__defineGetter__");
+ object.__defineGetter__(name, () => val);
+ assertSame(val, object[name]);
+}
+
+function testFailToAddGetter(object, name, val) {
+ assertThrows(() => Object.defineProperty(object, name, { get: function() { return val; } }));
+}
+
+testAddGetter(testAddGetter, "name", 11);
+
+function makeBuilder() {
+ var builder = new WasmModuleBuilder();
+
+ builder.addFunction("f", kSig_v_v)
+ .addBody([])
+ .exportFunc();
+ return builder;
+}
+
+(function TestAddGetterToFunction() {
+ print("TestAddGetterToFunction...");
+ var builder = makeBuilder();
+ var f = builder.instantiate().exports.f;
+ testAddGetterBothWays(f, "name", "foo");
+ testAddGetter(f, "blam", "baz");
+})();
+
+(function TestAddGetterToModule() {
+ print("TestAddGetterToModule...");
+ var builder = makeBuilder();
+ var module = new WebAssembly.Module(builder.toBuffer());
+ testAddGetter(module, "exports", 290);
+ testAddGetter(module, "xyz", new Object());
+})();
+
+(function TestAddGetterToInstance() {
+ print("TestAddGetterToInstance...");
+ var builder = makeBuilder();
+ var instance = builder.instantiate();
+ testAddGetter(instance, "exports", 290);
+ testAddGetter(instance, "xyz", new Object());
+})();
+
+(function TestAddGetterToExports() {
+ print("TestAddGetterToExports...");
+ var builder = makeBuilder();
+ var exports = builder.instantiate().exports;
+ testFailToAddGetter(exports, "f", 9834);
+ testAddGetter(exports, "nag", new Number(2));
+})();
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698