This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The validate() method of the WebAssembly object validates a given typed array source, returning a Boolean that specifies whether the source is valid wasm code (true) or not (false).
var test = WebAssembly.validate(bufferSource);
A Boolean that specifies whether the source is valid wasm code (true) or not (false).
If the parameter is not a buffer source, a TypeError is thrown.
The following example fetches a .wasm module and converts it into a types array. The validate() method is then used to check whether the module is valid.
fetch('simple.wasm').then(function(response) {
response.arrayBuffer().then(function(bytes) {
var test = WebAssembly.validate(bytes);
console.log(test);
})
});
| Specification | Status | Comment |
|---|---|---|
| Unknown The definition of 'validate()' in that specification. | Unknown | Initial draft definition. |
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Basic support | No support[1] | No support | No support[2] | No support | No support[1] | No support |
| Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|---|
| Basic support | No support | No support[1] | No support | No support[2] | No support | No support | No support | No support[1] |
[1] Experimental support can be enabled in Chrome 51+ and Opera 38+ by going to chrome://flags and enabling the Experimental WebAssembly flag.
[2] Experimental support can be enabled in Firefox 47+ by enabling the javascript.options.wasm flag in about:config.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate