e8d79f070c
This fixes exception creation (by the WebAssembly throw operation) so that it is not observable by JavaScript. Internal properties are now stored with symbol names instead of string names, which also prevents them from being accessed or monkey-patched directly by JavaScript. R=clemensh@chromium.org TEST=mjsunit/regress/wasm/regress-8094 BUG=v8:8094 Change-Id: I33cb27f4373114cd4db28d9aef23560093e55242 Reviewed-on: https://chromium-review.googlesource.com/1203951 Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#55602}
31 lines
1003 B
JavaScript
31 lines
1003 B
JavaScript
// Copyright 2018 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 --experimental-wasm-eh
|
|
|
|
load("test/mjsunit/wasm/wasm-constants.js");
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
// Instantiate a throwing module.
|
|
var builder = new WasmModuleBuilder();
|
|
builder.addException(kSig_v_v);
|
|
builder.addFunction("propel", kSig_v_v)
|
|
.addBody([kExprThrow, 0])
|
|
.exportFunc();
|
|
var instance = builder.instantiate();
|
|
|
|
// Catch the exception.
|
|
var exception;
|
|
try {
|
|
instance.exports.propel();
|
|
} catch (e) {
|
|
exception = e;
|
|
}
|
|
|
|
// Check that the exception is an instance of the correct error function and
|
|
// that no extraneous properties exist. Setting such properties could be
|
|
// observable by JavaScript and could break compatibility.
|
|
assertInstanceof(exception, WebAssembly.RuntimeError);
|
|
assertArrayEquals(["stack", "message"], Object.getOwnPropertyNames(exception));
|