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

Unified Diff: test/mjsunit/wasm/wasm-realms.js

Issue 2263953002: [wasm] Use the right context in the wasm-to-js wrapper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanup the test. Created 4 years, 4 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
« src/runtime/runtime-compiler.cc ('K') | « test/cctest/wasm/wasm-run-utils.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/wasm-realms.js
diff --git a/test/mjsunit/wasm/wasm-realms.js b/test/mjsunit/wasm/wasm-realms.js
new file mode 100644
index 0000000000000000000000000000000000000000..106868461a653792a938b31381910c4ee9ea97a0
--- /dev/null
+++ b/test/mjsunit/wasm/wasm-realms.js
@@ -0,0 +1,36 @@
+// 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 testImportsUseTheInstantiateRealm() {
+ print("testImportsUseTheInstantiateRealm");
+ Realm.create();
+
+ Object.prototype.valueOf = function() { return 1; };
+
+ var builder = new WasmModuleBuilder();
+
+ var sig_index = builder.addType(kSig_i);
+ builder.addImport("func", sig_index);
+ builder.addFunction("main", sig_index)
+ .addBody([
+ kExprCallImport, kArity0, 0 // --
+ ]) // --
+ .exportFunc();
+
+ var func = function() {return {};};
+ var main = builder.instantiate({func: func}).exports.main;
+ assertEquals(1, main());
+ Realm.eval(1, "Object.prototype.valueOf = function() { return 2; };");
+ assertEquals(1, main());
+ assertEquals(1, Realm.eval(1, "x => { return x(); };")(main));
+ Object.prototype.valueOf = function() { return 3; };
+ assertEquals(3, main());
+ assertEquals(3, Realm.eval(1, "x => { return x(); };")(main));
+})();
« src/runtime/runtime-compiler.cc ('K') | « test/cctest/wasm/wasm-run-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698