mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1637430 - Add tests. r=lth
Differential Revision: https://phabricator.services.mozilla.com/D74971
This commit is contained in:
parent
4be7b67b8e
commit
64d23cd941
@ -242,3 +242,51 @@ for (let mutable of [true, false]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test invalid ref.func indices
|
||||
|
||||
function testCodeRefFuncIndex(index) {
|
||||
assertErrorMessage(() => {
|
||||
new WebAssembly.Module(moduleWithSections(
|
||||
[v2vSigSection,
|
||||
declSection([0]), // One function
|
||||
bodySection(
|
||||
[funcBody(
|
||||
{locals:[],
|
||||
body:[
|
||||
RefFuncCode,
|
||||
...varU32(index),
|
||||
DropCode
|
||||
]})])
|
||||
]))
|
||||
},
|
||||
WebAssembly.CompileError,
|
||||
/(function index out of range)|(function index out of bounds)/);
|
||||
}
|
||||
|
||||
testCodeRefFuncIndex(1);
|
||||
testCodeRefFuncIndex(2);
|
||||
testCodeRefFuncIndex(10);
|
||||
testCodeRefFuncIndex(1000);
|
||||
|
||||
function testGlobalRefFuncIndex(index) {
|
||||
assertErrorMessage(() => {
|
||||
new WebAssembly.Module(moduleWithSections(
|
||||
[v2vSigSection,
|
||||
globalSection([
|
||||
{
|
||||
valType: AnyFuncCode,
|
||||
flags: 0,
|
||||
initExpr: [RefFuncCode, ...varU32(index), EndCode],
|
||||
}
|
||||
])
|
||||
]))
|
||||
},
|
||||
WebAssembly.CompileError,
|
||||
/(function index out of range)|(function index out of bounds)/);
|
||||
}
|
||||
|
||||
testGlobalRefFuncIndex(1);
|
||||
testGlobalRefFuncIndex(2);
|
||||
testGlobalRefFuncIndex(10);
|
||||
testGlobalRefFuncIndex(1000);
|
||||
|
Loading…
Reference in New Issue
Block a user