char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
688e96e
main
1mod common; 2 3use common:: run; 4 5# [ test ] 6fn ecma429_required_global_exposures_exist () { 7let output =run ( 8r#" 9const interfaces = [ 10'AbortController', 'AbortSignal', 'Event', 'EventTarget', 11'CustomEvent', 'ErrorEvent', 'MessageChannel', 'MessageEvent', 12'MessagePort', 'PromiseRejectionEvent', 'DOMException', 13'Headers', 'Request', 'Response', 'FormData', 'Blob', 'File', 14'CompressionStream', 'DecompressionStream', 15'ByteLengthQueuingStrategy', 'CountQueuingStrategy', 16'ReadableByteStreamController', 'ReadableStream', 17'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest', 18'ReadableStreamDefaultController', 'ReadableStreamDefaultReader', 19'TransformStream', 'TransformStreamDefaultController', 'WritableStream', 20'WritableStreamDefaultController', 'WritableStreamDefaultWriter', 21'TextDecoder', 'TextDecoderStream', 'TextEncoder', 'TextEncoderStream', 22'URL', 'URLSearchParams', 'URLPattern', 'Crypto', 'CryptoKey', 23'SubtleCrypto', 'Performance', 24]; 25for (const name of interfaces) { 26if (typeof globalThis[name] !== 'function') throw Error(`Missing interface ${name}`); 27} 28const wasmInterfaces = [ 29'Global', 'Instance', 'Memory', 'Module', 'Table', 'Tag', 30'Exception', 'CompileError', 'LinkError', 'RuntimeError', 31]; 32for (const name of wasmInterfaces) { 33if (typeof WebAssembly[name] !== 'function') throw Error(`Missing WebAssembly.${name}`); 34} 35const methods = [ 36'atob', 'btoa', 'clearTimeout', 'clearInterval', 'queueMicrotask', 37'reportError', 'setTimeout', 'setInterval', 'structuredClone', 'fetch', 38]; 39for (const name of methods) { 40if (typeof globalThis[name] !== 'function') throw Error(`Missing globalThis.${name}`); 41} 42if (globalThis.globalThis !== globalThis || self !== globalThis) throw Error('Global aliases'); 43if (!(globalThis instanceof EventTarget)) throw Error('Global EventTarget branding'); 44if (typeof navigator.userAgent !== 'string' || !navigator.userAgent) throw Error('navigator.userAgent'); 45if (typeof console !== 'object' || typeof crypto !== 'object' || typeof performance !== 'object') { 46throw Error('Required global objects'); 47} 48for (const name of ['onerror', 'onunhandledrejection', 'onrejectionhandled']) { 49if (!(name in globalThis)) throw Error(`Missing global handler ${name}`); 50} 51for (const name of ['compile', 'compileStreaming', 'instantiate', 'instantiateStreaming', 'validate']) { 52if (typeof WebAssembly[name] !== 'function') throw Error(`Missing WebAssembly.${name}`); 53} 54if (!('JSTag' in WebAssembly)) throw Error('Missing WebAssembly.JSTag'); 55console.log('ECMA-429 exposure smoke'); 56"# , 57& [], 58); 59assert_eq! ( output. stdout , b"ECMA-429 exposure smoke\n" ); 60}