Bug 1305197: Return value of WebAssembly_validate must be consistent with werror; r=luke

MozReview-Commit-ID: 3WqMltmc35l

--HG--
extra : rebase_source : e8518af45727140067e599c48371e180c65dab35
extra : amend_source : 0b513f243b5e8bd74bf3f82f3f837ef4c54f1d99
This commit is contained in:
Benjamin Bouvier 2016-09-26 11:04:04 +02:00
parent 419860c96f
commit 36f06cc08f
2 changed files with 10 additions and 3 deletions

View File

@ -1578,9 +1578,9 @@ WebAssembly_validate(JSContext* cx, unsigned argc, Value* vp)
return false;
}
if (error) {
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr,
JSMSG_WASM_COMPILE_ERROR, error.get());
if (error && !JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr,
JSMSG_WASM_COMPILE_ERROR, error.get())) {
return false;
}
callArgs.rval().setBoolean(validated);

View File

@ -24,3 +24,10 @@ assertEq(validate(wasmTextToBinary(`(module (func) (export "run" 0))`)), true);
// Feature-testing proof-of-concept.
assertEq(validate(wasmTextToBinary(`(module (memory 1) (func (result i32) (current_memory)))`)), true);
assertEq(validate(wasmTextToBinary(`(module (memory 1) (func (result i32) (grow_memory (i32.const 42))))`)), true);
// Enable warning as errors.
options("werror");
assertErrorMessage(() => validate(wasmTextToBinary(`(module (func) (func) (export "a" 2))`)),
WebAssembly.CompileError,
/exported function index out of bounds/);
options("werror");