From 2175983b113172c684d216f631f6450ae09a7477 Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Fri, 24 Nov 2023 01:29:25 -0800 Subject: [PATCH] More wasm feature checking --- fiat-html/disable-wasm-option.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/fiat-html/disable-wasm-option.js b/fiat-html/disable-wasm-option.js index 2c907f8a611..a6f8fab3223 100644 --- a/fiat-html/disable-wasm-option.js +++ b/fiat-html/disable-wasm-option.js @@ -1,21 +1,39 @@ document.addEventListener('DOMContentLoaded', async function() { const wasmCheckbox = document.getElementById('wasm'); const extraWasmLabel = document.getElementById('extraWasmLabel'); - wasmCheckbox.disabled = true; // Initially disable the checkbox + wasmCheckbox.disabled = true; // Initially disable the checkbox try { - if (await wasmFeatureDetect.tailCall()) { - wasmCheckbox.disabled = false; // Re-enable the checkbox if tail calls are supported + 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 javascript.options.wasm_tail_calls in about:config)'; + extraWasmLabel.innerHTML = `(enable ${firefoxText} in about:config)`; } else { - extraWasmLabel.innerHTML = '(wasm tail calls not supported)'; + extraWasmLabel.innerHTML = `(missing wasm support for: ${featureText})`; } } } catch (error) { - console.error('Error checking wasm tail call support:', error); + console.error('Error checking wasm feature support:', error); } });