diff --git a/fiat-html/disable-wasm-option.js b/fiat-html/disable-wasm-option.js new file mode 100644 index 0000000000..a6f8fab322 --- /dev/null +++ b/fiat-html/disable-wasm-option.js @@ -0,0 +1,39 @@ +document.addEventListener('DOMContentLoaded', async function() { + const wasmCheckbox = document.getElementById('wasm'); + const extraWasmLabel = document.getElementById('extraWasmLabel'); + wasmCheckbox.disabled = true; // Initially disable the checkbox + + try { + const features = { + tailCall: await wasmFeatureDetect.tailCall(), + gc: await wasmFeatureDetect.gc(), + exceptions: await wasmFeatureDetect.exceptions() + }; + + const unsupportedFeatures = Object.entries(features) + .filter(([feature, supported]) => !supported) + .map(([feature]) => feature); + + if (unsupportedFeatures.length === 0) { + wasmCheckbox.disabled = false; // Re-enable the checkbox if all features are supported + } else { + wasmCheckbox.checked = false; + + let featureText = unsupportedFeatures.join(', '); + let firefoxText = unsupportedFeatures.map(feature => { + if (feature === 'tailCall') return 'javascript.options.wasm_tail_calls'; + if (feature === 'gc') return 'javascript.options.wasm_gc'; + if (feature === 'exceptions') return 'javascript.options.wasm_exceptions'; + return feature; + }).join(', '); + + if (navigator.userAgent.includes('Firefox')) { + extraWasmLabel.innerHTML = `(enable ${firefoxText} in about:config)`; + } else { + extraWasmLabel.innerHTML = `(missing wasm support for: ${featureText})`; + } + } + } catch (error) { + console.error('Error checking wasm feature support:', error); + } +}); diff --git a/fiat-html/fiat-crypto.html b/fiat-html/fiat-crypto.html index 2beea09b2d..425c68af41 100644 --- a/fiat-html/fiat-crypto.html +++ b/fiat-html/fiat-crypto.html @@ -5,7 +5,7 @@ Fiat Cryptography Web Interface