Skip to content

Instead of removing non-deterministic APIs why not simply allow specifying the implementation? #32

@Jamesernator

Description

@Jamesernator

As the title says, instead of removing Date.now / Math.random / String.prototype.localeCompare / etc, why not not just allow specifying host-implementations and provide a default implementation that is deterministic?

For example maybe some like:

let i = 0;
let rng = getRngSomehow();

const immutableRoot = Realm.makeImmutableRootRealm({
  hostImplementations: {
    random: () => rng.next(),
    now: () => i++,
    locale: 'fr-FR', // Affects appropriate ECMA-402 APIs within Realm
    promiseRejectionTracker: (promise, operation) => { /* Track rejections */},
  },
})

Where any non-specified implementations of host/implementation-defined features are given a secure deterministic implementation instead (e.g. Math.random() always returns 0 or something like that).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions