v8/test/mjsunit/wasm/asm-with-wasm-off.js
bradnelson e53f6469d9 [wasm][asm.js] Allow asm.js->wasm codegen in unsafe-eval situations.
A recent change to disallow wasm compilation in contexts where
CSP unsafe-eval would disallow eval also ended up banning asm.js there:
https://codereview.chromium.org/2646713002

This ends up banning non-evaled asm.js even in some places it should be
allowed.

NOTE: Although asm.js code converted to wasm generates an intermediate wasm
module. asm.js code evaled in a disallowed context can't even get
that far (as it's stoped at the eval site).

BUG=683867
R=mtrofin@chromium.org,titzer@chromium.org,adamk@chromium.org

Review-Url: https://codereview.chromium.org/2656463004
Cr-Commit-Position: refs/heads/master@{#42616}
2017-01-24 05:00:35 +00:00

21 lines
570 B
JavaScript

// Copyright 2017 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: --validate-asm --allow-natives-syntax
// NOTE: This is in it's own file because it calls %DisallowCodegenFromStrings,
// which messes with the isolate's state.
(function testAsmWithWasmOff() {
% DisallowCodegenFromStrings();
function Module() {
'use asm';
function foo() {
return 0;
}
return {foo: foo};
}
Module();
assertTrue(% IsAsmWasmCode(Module));
})();