| 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));
|
| +})();
|
|
|