mod common; use common::run; #[test] fn ecma429_required_global_exposures_exist() { let output = run( r#" const interfaces = [ 'AbortController', 'AbortSignal', 'Event', 'EventTarget', 'CustomEvent', 'ErrorEvent', 'MessageChannel', 'MessageEvent', 'MessagePort', 'PromiseRejectionEvent', 'DOMException', 'Headers', 'Request', 'Response', 'FormData', 'Blob', 'File', 'CompressionStream', 'DecompressionStream', 'ByteLengthQueuingStrategy', 'CountQueuingStrategy', 'ReadableByteStreamController', 'ReadableStream', 'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest', 'ReadableStreamDefaultController', 'ReadableStreamDefaultReader', 'TransformStream', 'TransformStreamDefaultController', 'WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter', 'TextDecoder', 'TextDecoderStream', 'TextEncoder', 'TextEncoderStream', 'URL', 'URLSearchParams', 'URLPattern', 'Crypto', 'CryptoKey', 'SubtleCrypto', 'Performance', ]; for (const name of interfaces) { if (typeof globalThis[name] !== 'function') throw Error(`Missing interface ${name}`); } const wasmInterfaces = [ 'Global', 'Instance', 'Memory', 'Module', 'Table', 'Tag', 'Exception', 'CompileError', 'LinkError', 'RuntimeError', ]; for (const name of wasmInterfaces) { if (typeof WebAssembly[name] !== 'function') throw Error(`Missing WebAssembly.${name}`); } const methods = [ 'atob', 'btoa', 'clearTimeout', 'clearInterval', 'queueMicrotask', 'reportError', 'setTimeout', 'setInterval', 'structuredClone', 'fetch', ]; for (const name of methods) { if (typeof globalThis[name] !== 'function') throw Error(`Missing globalThis.${name}`); } if (globalThis.globalThis !== globalThis || self !== globalThis) throw Error('Global aliases'); if (!(globalThis instanceof EventTarget)) throw Error('Global EventTarget branding'); if (typeof navigator.userAgent !== 'string' || !navigator.userAgent) throw Error('navigator.userAgent'); if (typeof console !== 'object' || typeof crypto !== 'object' || typeof performance !== 'object') { throw Error('Required global objects'); } for (const name of ['onerror', 'onunhandledrejection', 'onrejectionhandled']) { if (!(name in globalThis)) throw Error(`Missing global handler ${name}`); } for (const name of ['compile', 'compileStreaming', 'instantiate', 'instantiateStreaming', 'validate']) { if (typeof WebAssembly[name] !== 'function') throw Error(`Missing WebAssembly.${name}`); } if (!('JSTag' in WebAssembly)) throw Error('Missing WebAssembly.JSTag'); console.log('ECMA-429 exposure smoke'); "#, &[], ); assert_eq!(output.stdout, b"ECMA-429 exposure smoke\n"); }