Files
rust_browser/docs/JavaScript_Implementation_Checklist.md
Zachary D. Rowitsch 9e6300d7a0 Implement ES modules with code review fixes (§3.4)
Add import/export parsing, module registry, bytecode opcodes, host
integration, and <script type="module"> HTML pipeline support. Includes
three rounds of code review with 21 remaining action items tracked in
the story file for follow-up.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 07:23:48 -04:00

23 KiB

JavaScript Implementation Checklist

Checked items mean the feature is implemented and working end-to-end (parse → execute → correct result). Partial support is left unchecked and called out inline.

Phase 0: Infrastructure & Conformance

  • Hand-written recursive-descent parser producing AST
  • Tree-walking interpreter over AST
  • Statement limit for infinite-loop prevention (configurable, default 100,000)
  • Call-depth limit (configurable, default 64)
  • JS262 conformance harness (vendored Test262 tests, TOML manifest, pass/known_fail/skip)
  • Full Test262 integration (Tier 2: upstream clone, auto-generated manifest, triage tooling)
  • Bytecode compiler + VM (top-level bytecode compilation; function calls delegate to AST interpreter)
  • Source maps support
  • Cycle-detecting garbage collection (currently Rc<RefCell<>>; no cycle collection)

Phase 1: Lexical Grammar & Tokenization

  • Identifiers and reserved words
  • Numeric literals (integers, floats, hex 0x, octal 0o, binary 0b, exponential)
  • String literals (single/double quotes, escape sequences)
  • Template literal tokenization (backticks, ${expr} interpolation)
  • Regular expression literal tokenization with flags
  • Single-line (//) and multi-line (/* */) comments
  • Automatic semicolon insertion (ASI)
    • Current state: core ASI works; 5 known-fail edge cases remain (labeled statements, do-while ASI).
  • Hashbang (#!) comment support
  • BigInt literals (123n)

Phase 2: Declarations & Scoping

  • var declarations with function-scoped hoisting
  • let declarations with block scoping
  • const declarations with block scoping
  • Temporal Dead Zone (TDZ) for let/const
  • Function declarations with hoisting
  • Function expressions (named and anonymous)
  • Arrow function expressions (=> with expression and block bodies)
  • Class declarations (constructor, methods, extends, super(), super.method(), static methods)
  • Class expressions
  • Block-scoped function declarations (Annex B semantics)
  • import / export declarations (ES modules)
  • import() dynamic import expressions

Phase 3: Statements & Control Flow

  • Block statements with scope
  • if / else
  • for (C-style)
  • for...in (property enumeration)
  • for...of (iterable iteration)
    • Current state: works with arrays and strings only; does not invoke the general iterator protocol.
  • while and do...while
  • switch / case with fall-through
  • break and continue
  • try / catch / finally
  • throw statement
  • Empty statements (;)
  • Labeled statements (label: stmt, break label, continue label)
  • with statement (deprecated but spec-required in non-strict mode)
  • for await...of
  • debugger statement (can be a no-op, but should parse)

Phase 4: Expressions & Operators

4.1 Arithmetic & Assignment

  • Arithmetic: +, -, *, /, %, **
  • Unary: +, -, !, ~, typeof, void, delete
  • Increment / decrement: ++, -- (prefix and postfix)
  • Assignment: =
  • Compound assignment: +=, -=, *=, /=, %=, **=
  • Bitwise compound assignment: &=, |=, ^=, <<=, >>=, >>>=
  • Logical assignment: &&=, ||=, ??=

4.2 Comparison & Logical

  • Equality: ==, ===, !=, !==
  • Relational: <, >, <=, >=
  • Logical: &&, ||, !
  • Nullish coalescing: ??
  • Conditional (ternary): ? :

4.3 Bitwise

  • Bitwise: &, |, ^, ~
  • Shift: <<, >>, >>>

4.4 Member Access & Calls

  • Dot member access: obj.prop
  • Bracket member access: obj[expr]
  • Function calls: fn(args)
  • Method calls: obj.method(args)
  • new expressions
    • Current state: works with identifier targets; new foo.Bar() with member expressions is not supported.
  • instanceof operator
  • in operator
  • Optional chaining: ?.
  • Tagged template expressions: tag`str`

4.5 Spread & Destructuring (Expressions)

  • Spread in array literals: [...arr]
  • Spread in function calls: fn(...args)
  • Spread in object literals: {...obj}
  • Comma operator

Phase 5: Functions

  • Function declarations and expressions
  • Arrow functions with lexical this
  • Default parameters
  • Rest parameters (...args)
  • this binding (global, method, constructor contexts)
  • Function.prototype.call(thisArg, ...args)
  • Closures with variable capture
    • Current state: variables captured by value at definition time; mutable closure state requires specific patterns.
  • Recursion support
  • Function.prototype.apply(thisArg, argsArray)
  • Function.prototype.bind(thisArg, ...args)
  • arguments object
  • Generator functions (function* / yield / yield*)
  • Async functions (async function / await)
  • Async generator functions (async function*)
  • Getter / setter methods (get prop() / set prop())
  • new.target meta-property

Phase 6: Classes

  • Class declarations and expressions
  • Constructor method
  • Instance methods
  • Static methods
  • extends with simple identifier targets
  • super() in constructors
  • super.method() calls
  • Prototype chain setup
  • Class fields (public instance properties)
  • Private fields (#field)
  • Private methods (#method())
  • Static fields and static initialization blocks
  • Computed method names ([expr]() {})
  • Getter / setter methods in classes
  • extends with member expressions (class Foo extends ns.Bar)

Phase 7: Destructuring & Patterns

  • Array destructuring: const [a, b] = arr
  • Object destructuring: const {x, y} = obj
  • Nested destructuring
  • Default values: const {x = 5} = obj
  • Renaming: const {x: newX} = obj
  • Rest in arrays: const [first, ...rest] = arr
  • Rest in objects: const {a, ...rest} = obj
  • Array holes: const [a, , c] = arr
  • Destructuring in function parameters
  • Assignment destructuring: [a, b] = [1, 2]
  • Destructuring in for...of / for...in bindings
  • Computed property destructuring: const {[expr]: val} = obj

Phase 8: Template Literals

  • Basic template literals: `text`
  • Expression interpolation: `${expr}`
  • Nested expressions
  • Multiline strings
  • Escape sequences
  • Tagged templates: tag`str`
  • String.raw tag function

Phase 9: Strict Mode

  • Directive prologue detection ("use strict")
  • Function-scoped and inherited strict mode
  • Escape sequence guard (prevents "use\040strict" interpretation)
  • Reserved word enforcement
  • Duplicate parameter rejection
  • Non-simple parameter rejection (with defaults/rest)
  • delete identifier prohibition
  • this undefined in non-constructor strict calls
  • .call() does not coerce non-object this
  • Octal escape sequence rejection

Phase 10: Error Types & Handling

  • Error base type with message and name properties
  • TypeError
  • ReferenceError
  • SyntaxError
  • RangeError
  • EvalError
  • URIError
  • Proper prototype chain for all error types
  • toString() method on errors
  • Constructor callable without new
  • instanceof checks on error types
  • Error.prototype.stack (stack traces)
  • AggregateError (ES2021)

Phase 11: Object Built-in

  • Object() constructor
  • Object.create(proto)
  • Object.keys(obj)
  • Object.values(obj)
  • Object.entries(obj)
  • Object.assign(target, ...sources)
  • Object.getPrototypeOf(obj)
  • Object.getOwnPropertySymbols(obj)
  • Object.prototype.toString() (with Symbol.toStringTag support)
  • Object.prototype.valueOf()
  • Object.prototype.hasOwnProperty(prop)
  • Object.prototype.propertyIsEnumerable(prop)
  • Object.setPrototypeOf(obj, proto)
  • Object.getOwnPropertyNames(obj)
  • Object.getOwnPropertyDescriptor(obj, prop)
  • Object.getOwnPropertyDescriptors(obj)
  • Object.defineProperty(obj, prop, descriptor)
  • Object.defineProperties(obj, descriptors)
  • Object.freeze(obj) / Object.isFrozen(obj)
  • Object.seal(obj) / Object.isSealed(obj)
  • Object.preventExtensions(obj) / Object.isExtensible(obj)
  • Object.is(a, b)
  • Object.fromEntries(iterable)
  • Object.hasOwn(obj, prop) (ES2022)
  • Object.prototype.isPrototypeOf(obj)
  • Object.prototype.toLocaleString()

Phase 12: Array Built-in

  • Array() constructor / new Array(len)
  • Array.isArray(value)
  • .push(...items) / .pop()
  • .shift() / .unshift(...items)
  • .slice(start, end)
  • .concat(...items)
  • .join(separator)
  • .reverse()
  • .sort(compareFn)
  • .indexOf(item, from) / .lastIndexOf(item, from)
  • .includes(item, from)
  • .forEach(cb, thisArg)
  • .map(cb, thisArg)
  • .filter(cb, thisArg)
  • .find(cb, thisArg) / .findIndex(cb, thisArg)
  • .some(cb, thisArg) / .every(cb, thisArg)
  • .reduce(cb, init) / .reduceRight(cb, init)
  • .toString()
  • .length property (auto-maintained)
  • .splice(start, deleteCount, ...items)
  • .fill(value, start, end)
  • .copyWithin(target, start, end)
  • .flat(depth) / .flatMap(cb, thisArg)
  • .at(index)
  • .findLast(cb) / .findLastIndex(cb) (ES2023)
  • .entries() / .keys() / .values()
  • .toLocaleString()
  • Array.from(iterable, mapFn) / Array.of(...items)
  • .toReversed() / .toSorted() / .toSpliced() / .with() (ES2023 immutable methods)

Phase 13: String Built-in

  • String() constructor (wrapper object via new)
  • .charAt(index) / .charCodeAt(index)
  • .slice(start, end) / .substring(start, end)
  • .indexOf(str, from) / .lastIndexOf(str, from)
  • .includes(str, pos) / .startsWith(str, pos) / .endsWith(str, len)
  • .toUpperCase() / .toLowerCase()
  • .trim() / .trimStart() / .trimEnd()
  • .split(separator, limit) (including regex with capture groups)
  • .replace(pattern, replacement) (string and regex patterns)
  • .match(regexp) / .search(regexp)
  • .repeat(count)
  • .concat(...strings)
  • .toString() / .valueOf()
  • .length property
  • .substr(start, length) (legacy but widely used)
  • .padStart(len, pad) / .padEnd(len, pad)
  • .at(index)
  • .codePointAt(index)
  • .normalize(form)
  • .matchAll(regexp)
  • .replaceAll(pattern, replacement)
  • String.fromCharCode(...codes) / String.fromCodePoint(...codes)
  • .toLocaleLowerCase() / .toLocaleUpperCase() / .localeCompare()

Phase 14: Number Built-in

  • Number() constructor (wrapper object via new)
  • Number.prototype.toString()
  • Number.prototype.valueOf()
  • Number.prototype.toFixed(digits)
  • Number.prototype.toExponential(digits)
  • Number.prototype.toPrecision(digits)
  • Number.prototype.toLocaleString()
  • Number.isNaN(value)
  • Number.isFinite(value)
  • Number.isInteger(value)
  • Number.isSafeInteger(value)
  • Number.parseFloat(string) / Number.parseInt(string, radix)
  • Number.MAX_VALUE / Number.MIN_VALUE
  • Number.MAX_SAFE_INTEGER / Number.MIN_SAFE_INTEGER
  • Number.EPSILON
  • Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY / Number.NaN

Phase 15: Boolean Built-in

  • Boolean() constructor (wrapper object via new)
  • Boolean.prototype.toString()
  • Boolean.prototype.valueOf()

Phase 16: RegExp Built-in

  • Regex literals: /pattern/flags
  • new RegExp(pattern, flags) constructor
  • .test(string)
  • .exec(string) with capture groups, index, and input properties
  • .toString()
  • .source / .flags / .lastIndex properties
  • Flags: g, i, m, s, u, y
  • String integration: .match(), .replace(), .search(), .split()
  • Function replacers in .replace(regexp, fn)
  • .matchAll() (returns iterator)
  • Named capture groups ((?<name>...) and $<name>)
  • Lookbehind assertions ((?<=...) / (?<!...))
    • Lookahead is supported via the regress crate.
  • RegExp.prototype[Symbol.match] / [Symbol.replace] / [Symbol.search] / [Symbol.split]
  • d flag (hasIndices)

Phase 17: Symbol Built-in

  • Symbol(description) creation
  • .description property
  • .toString()"Symbol(description)"
  • Symbol.for(key) / Symbol.keyFor(symbol) (global registry)
  • Symbol-keyed object properties
  • Object.getOwnPropertySymbols(obj)
  • Well-known symbols:
    • Symbol.iterator
    • Symbol.toPrimitive
    • Symbol.hasInstance
    • Symbol.toStringTag
    • Symbol.species
    • Symbol.isConcatSpreadable
  • Symbol.asyncIterator
  • Symbol.match / Symbol.replace / Symbol.search / Symbol.split
  • Symbol.toPrimitive full hint protocol in all coercion contexts

Phase 18: Promise

  • new Promise(executor)
  • Promise.resolve(value) / Promise.reject(reason)
  • .then(onFulfilled, onRejected)
  • .catch(onRejected)
  • Microtask queue integration
  • Handler chaining
  • Error propagation
  • .finally(onFinally)
  • Promise.all(iterable)
  • Promise.race(iterable)
  • Promise.allSettled(iterable)
  • Promise.any(iterable) (ES2021)
  • Promise.withResolvers() (ES2024)

Phase 19: JSON

  • JSON.stringify(value, replacer, space)
    • Replacer function and array support
    • Space / indentation parameter
    • toJSON() method support
    • Circular reference detection
    • Boxed primitive handling
  • JSON.parse(text, reviver)
    • Full JSON spec compliance
    • Surrogate pair handling
    • Depth limit enforcement (512)
    • Reviver function support

Phase 20: WeakMap / WeakSet / Map / Set

  • WeakMap: new WeakMap(), .get(), .set(), .has(), .delete()
    • Object-key-only enforcement implemented.
  • WeakSet
  • WeakRef / FinalizationRegistry (ES2021)
  • Map: new Map(), .get(), .set(), .has(), .delete(), .size, .forEach(), .entries(), .keys(), .values(), .clear()
  • Set: new Set(), .add(), .has(), .delete(), .size, .forEach(), .entries(), .keys(), .values(), .clear()

Phase 21: Proxy & Reflect

Proxy

  • new Proxy(target, handler)
  • Proxy.revocable(target, handler)
  • Trap: get
  • Trap: set
  • Trap: has
  • Trap: deleteProperty
  • Trap: apply (function targets)
  • Trap: construct
  • Trap: ownKeys
  • Trap: getOwnPropertyDescriptor
  • Trap: defineProperty
  • Trap: getPrototypeOf / setPrototypeOf
  • Trap: preventExtensions / isExtensible

Reflect

  • Reflect.get() / Reflect.set() / Reflect.has()
  • Reflect.deleteProperty() / Reflect.apply() / Reflect.construct()
  • Reflect.ownKeys() / Reflect.getOwnPropertyDescriptor()
  • Reflect.defineProperty() / Reflect.getPrototypeOf() / Reflect.setPrototypeOf()
  • Reflect.preventExtensions() / Reflect.isExtensible()

Phase 22: Missing Global Objects

Math

  • Constants: Math.PI, Math.E, Math.LN2, Math.LN10, Math.LOG2E, Math.LOG10E, Math.SQRT2, Math.SQRT1_2
  • Math.abs(), Math.ceil(), Math.floor(), Math.round(), Math.trunc()
  • Math.max(), Math.min()
  • Math.pow(), Math.sqrt(), Math.cbrt(), Math.hypot()
  • Math.log(), Math.log2(), Math.log10(), Math.exp(), Math.expm1(), Math.log1p()
  • Math.sin(), Math.cos(), Math.tan(), Math.asin(), Math.acos(), Math.atan(), Math.atan2()
  • Math.random(), Math.sign(), Math.clz32(), Math.fround(), Math.imul()

Date

  • new Date() / Date.now() / Date.parse() / Date.UTC()
  • Getter methods: .getFullYear(), .getMonth(), .getDate(), .getDay(), .getHours(), .getMinutes(), .getSeconds(), .getMilliseconds(), .getTime(), .getTimezoneOffset()
  • Setter methods: .setFullYear(), .setMonth(), .setDate(), .setHours(), .setMinutes(), .setSeconds(), .setMilliseconds(), .setTime()
  • UTC variants of getters and setters
  • .toISOString(), .toJSON(), .toDateString(), .toTimeString(), .toLocaleDateString(), .toLocaleTimeString(), .toLocaleString(), .toString(), .valueOf()

Global Functions

  • parseInt(string, radix)
  • parseFloat(string)
  • isNaN(value) / isFinite(value)
  • encodeURI() / decodeURI()
  • encodeURIComponent() / decodeURIComponent()
  • eval() direct and indirect
    • Current state: eval() is implemented with direct/indirect semantics and strict mode isolation.

Phase 23: Iterators & Generators

Iterator Protocol

  • Symbol.iterator invocation in for...of, spread, destructuring
    • Generalized: for...of and spread now invoke Symbol.iterator on any object.
  • IteratorResult protocol ({ value, done })
  • Iterator helpers: .next(), .return(), .throw()
  • Built-in iterables: Array, String, Map, Set, TypedArray, arguments
    • Arrays and strings work via hardcoded fallbacks + Symbol.iterator protocol.
  • Symbol.asyncIterator for async iteration

Generators

  • function* declarations and expressions
  • yield expression
  • yield* delegation
  • Generator objects with .next(), .return(), .throw()
  • Async generators (async function*)

Phase 24: Async / Await

  • async function declarations and expressions
  • async arrow functions
  • await expression
  • async methods in classes and objects
  • for await...of loops
  • Top-level await (module context)

Phase 25: Modules (ES Modules)

  • import declarations (named, default, namespace)
  • export declarations (named, default, re-export)
  • import() dynamic import
  • Module resolution algorithm
  • Module evaluation and linking
  • import.meta
  • Top-level await
  • Circular dependency handling

Phase 26: TypedArrays & ArrayBuffer

  • ArrayBuffer / SharedArrayBuffer
  • DataView
  • TypedArray constructors: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array
  • TypedArray methods (.set(), .subarray(), .slice(), .from(), .of(), etc.)
  • Atomics (for shared memory)

Phase 27: Web APIs (Browser Integration)

DOM Access

  • document.getElementById(id)
  • document.createElement(tagName)
  • element.appendChild(child) / element.removeChild(child)
  • element.textContent (get/set)
  • Element properties: id, tagName, className
  • Element attribute access (read/write)
  • document.querySelector() / document.querySelectorAll()
  • document.getElementsByTagName() / document.getElementsByClassName()
  • element.insertBefore() / element.replaceChild()
  • element.innerHTML (get/set)
    • Current state: wired to fragment parse/serialize but not fully spec-compliant.
  • element.outerHTML
  • element.classList (DOMTokenList)
  • element.style (CSSStyleDeclaration)
  • element.getBoundingClientRect()
  • element.parentElement / element.children / element.nextSibling etc.
  • document.createTextNode() / document.createDocumentFragment()
  • Node.cloneNode(deep)

Events

  • addEventListener(type, listener, useCapture)
  • removeEventListener(type, listener)
  • Event object: type, target, currentTarget, bubbles, cancelable
  • event.preventDefault() / event.stopPropagation()
  • Event bubbling
    • Current state: target + bubble phases implemented for click.
  • Event capture phase
  • dispatchEvent(event) (custom events)
  • Keyboard events: keydown, keyup, keypress
  • Mouse events: mousedown, mouseup, mousemove, mouseenter, mouseleave
  • Focus events: focus, blur, focusin, focusout
  • Input events: input, change

Timers & Scheduling

  • setTimeout(callback, delay) / clearTimeout(id)
  • queueMicrotask(callback)
  • Microtask queue draining after script execution
  • setInterval(callback, delay) / clearInterval(id)
  • requestAnimationFrame(callback) / cancelAnimationFrame(id)

Window & Navigation

  • window global object
  • window.location / Location API
  • window.history / History API (pushState, replaceState, popstate)
  • window.navigator
  • window.innerWidth / window.innerHeight
  • window.getComputedStyle(element)
  • window.scrollTo() / window.scrollBy()

Network

  • fetch() API with Request / Response / Headers
  • XMLHttpRequest
  • WebSocket

Storage

  • localStorage / sessionStorage
  • IndexedDB
  • document.cookie

Console

  • console.log(...args)
  • console.warn() / console.error() / console.info() / console.debug()
  • console.table() / console.dir()
  • console.time() / console.timeEnd()
  • console.assert()
  • console.group() / console.groupEnd()

Phase 28: Additional ES2015+ Features

  • BigInt type and operations
  • Optional chaining (?.)
  • globalThis
  • structuredClone()
  • queueMicrotask() (already in Web APIs — ensure global availability)
  • Logical assignment operators (&&=, ||=, ??=)
    • Current state: parsing and execution implemented.
  • Private class fields and methods (#)
  • Class static initialization blocks
  • at() method on Array, String, TypedArray
  • Object.hasOwn()
  • Array.prototype.toSorted() / .toReversed() / .toSpliced() / .with()
  • Error.prototype.cause
  • RegExp match indices (d flag)

Phase 29: Property Descriptors & Meta-Object Protocol

  • Property descriptors (writable, enumerable, configurable)
  • Object.defineProperty() / Object.getOwnPropertyDescriptor()
  • Accessor properties (getters/setters via descriptors)
  • Object.freeze() / Object.seal() / Object.preventExtensions()
  • Non-configurable / non-writable property enforcement
  • [[Prototype]] chain with proper property lookup semantics
    • Current state: prototype chain lookup works for basic get; descriptor-level semantics are missing.

Phase 30: Eval

  • Direct eval() with scope access
  • Indirect eval() with global scope
  • Strict mode isolation in eval
  • Parse error handling as SyntaxError
  • new Function(args, body) constructor

Phase 31: Conformance Exit Criteria

  • Pass Test262 conformance targets (define threshold per feature area)
  • No crashers: malformed JS must not crash the engine
  • All known failures have linked issues and documented spec rationale
  • Math, Date, Map, Set built-ins implemented (required by most real-world JS)
  • Iterator protocol fully integrated with for...of, spread, and destructuring
  • Property descriptor model implemented (required by many libraries)
  • Publish JavaScript conformance report with pass rates and remaining gaps