Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Propagate active ScriptOrModule with JobCallback Record #3195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Oct 13, 2023

HTML HostEnqueuePromiseJob doesn't follow the requirements of ecma262 HostEnqueuePromiseJob as ecma262 defines that

However, HTML saves the active ScriptOrModule at the time of HostMakeJobCallback is invoked rather than at the time of HostEnqueuePromiseJob is invoked. However, the two host hooks are invoked with the same active script or module consecutively.

Update the steps of HostMakeJobCallback, HostCallJobCallback, and HostEnqueuePromiseJob to fix the inconsistency between ecma262 and the HTML spec.

This change also mandates that the active scripts are propagated through promise jobs and FinalizationRegistry cleanup callbacks. For example, the following example would be able to use the original script's base URL appropriately.

Promise.resolve('import(`./example.mjs`)').then(eval);

const registry = new FinalizationRegistry(eval);
registry.register({}, 'import(`./example.mjs`');

This proposed behavior exists in the HTML spec since HTML HostMakeJobCallback already propagates the active script. This PR fixes the inconsistent requirement on ecma262 HostEnqueuePromiseJob and HTML HostMakeJobCallback.

@legendecas legendecas changed the title Nomative: Propagate active ScriptOrModule with JobRecord Nomative: Propagate active ScriptOrModule with JobCallback Record Oct 13, 2023
@nicolo-ribaudo
Copy link
Member

This should be discussed together with #3160 — we should move towards less dynamic scoping, not more.

@ljharb ljharb changed the title Nomative: Propagate active ScriptOrModule with JobCallback Record Normative: Propagate active ScriptOrModule with JobCallback Record Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants