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

Unclear distinction between "entry" and "incumbent" settings objects #155

Closed
jyasskin opened this issue Sep 16, 2015 · 7 comments
Closed
Assignees
Labels
clarification Standard could be clearer

Comments

@jyasskin
Copy link
Member

The incumbent settings object is the top entry in the stack of script settings objects, and the entry settings object is the top entry that's marked as a candidate entry settings object. However, I only see one place that pushes an entry onto the stack, and it marks it as a candidate.

Maybe we can eliminate one of the terms?

If not, it'd be good for other spec authors if HTML mentioned how these two terms differ, and how we should choose between them.

@annevk
Copy link
Member

annevk commented Sep 16, 2015

Yeah it would. See also:

Unfortunately this is an area that's not well understood, so I don't expect this to be addressed real soon, but it's one of the things I'd like to solve if nobody beats me to it.

@jyasskin
Copy link
Member Author

Do you have an intuitive understanding of the intended difference between the terms, that you could write down here? I have no idea, so I've been picking randomly based on the last spec I read, and I could do better with even a sketch of the difference.

@bzbarsky
Copy link
Contributor

The entry settings object is where script was first entered.

The incumbent settings object is what script was running when the call into the IDL-defined interface happened.

So a simple example. A.html has:

<iframe src="B.html"></iframe>
<script>onload = function() { frames[0].foo(); }</script>

B.html has:

<script>function foo() { someDOMObject.doSomething() }</script>

When the call to doSomething happens the entry settings object is the one for A.html and the incumbent settings object is for B.html.

It's also not true that only one place pushes an entry onto the stack. Right below the place you link to, there is:

When a JavaScript SourceElements production is to be evaluated, the settings object of the script corresponding to that SourceElements must be pushed onto the stack of script settings objects before the evaluation begins, and popped when the evaluation ends (regardless of whether it's an abrupt completion or not).

The problem, of course, is that SourceElements is an ES5 grammatical concept (it's the production for a function body or toplevel script in ES5). The intent is that any time a toplevel script is executed or a function is called, the corresponding incumbent settings object goes on the stack.

It would be better if this were defined in terms of ES6. Probably in terms of EvaluateBody and whatever the toplevel script equivalent is, though maybe it can be done in terms of the "execution context stack" manipulation ES6 performs.... maybe.

@jyasskin
Copy link
Member Author

Thanks, that's very helpful.

@domenic
Copy link
Member

domenic commented Dec 9, 2015

Update on this, which I am working on as part of the es-init branch:

  • I have confirmed it is not really feasible to try to use the JS execution context stack to track the settings object stack. I am as such adding the following non-normative note: "The stack of script settings objects does not correspond to the
    JavaScript execution context stack. The former is used for tracking transitions
    between different scripts, whereas the latter operates at the lower level of
    (roughly) individual JavaScript functions."
  • I plan to add @bzbarsky's example, alongside the spec's current more complicated one, to try to add clarity. Actually, @bzbarsky's example is basically the same as the one in the spec. I have broken up the explanatory paragraph following it into one about vocabulary and one about location.assign, in the hopes that it will be easier to skim.
  • I plan to address the ES5 vs. ES6 impedance mismatch as well.

@domenic
Copy link
Member

domenic commented Dec 9, 2015

Dammit, I got this all wrong; I didn't realize SourceElements was basically function bodies. OK, maybe there is a 1:1 correspondence between JS execution context stack and stack of script settings objects after all.

@bzbarsky
Copy link
Contributor

bzbarsky commented Dec 9, 2015

The execution context stack probably needs to be updated when calling a DOM method, but the incumbent script context should not be.

Or to put this in concrete terms, if [[Call]] for Web IDL methods is defined more or less like http://www.ecma-international.org/ecma-262/6.0/#sec-built-in-function-objects-call-thisargument-argumentslist then this testcase:

frames[0].postMessage(/* stuff */)

will have the JS execution context updated to that of frames[0] by the time the actual algorithm steps of postMessage are reached, while the incumbent script settings object needs to be the calling code.

Or to put this in a slightly different way, DOM built-in functions are not considered "different scripts" for purposes of the stack of script settings objects.

@domenic domenic self-assigned this Dec 14, 2015
domenic added a commit that referenced this issue Dec 14, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XMl-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 14, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 15, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 15, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 15, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 15, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 15, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 16, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 17, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 18, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
domenic added a commit that referenced this issue Dec 21, 2015
This brings the script execution parts of the spec up to date with the latest changes in ES. Notable changes include:

- Removed of some generalization to allow non-JavaScript scripting languages (including XML-based ones).
- Let ES track the execution context stack, and the corresponding stack of scripts; see tc39/ecma262#242. This allows us to stop tracking the stack of script settings objects, instead defining entry and incumbent settings objects with reference to ES. This is especially important since our current mechanism, of monkey-patching the SourceElement grammatical construction, no longer works since that grammar production has disappeared. Fixes #155.
- Established a direct correspondence between HTML's "script" concept and ES's Script Record/Module Record concepts. The former is stored in the [[HostDefined]] slot of the latter.
- The process of parsing and executing scripts, including handling any resulting errors, is now formalized and appropriately calls out to ES's ParseScript and ScriptEvaluation abstract operations.

Note that we do *not* use the ECMAScript ScriptEvaluationJob or job queue for our script parsing/evaluation. That setup is overengineered and does not serve the needs of HTML; we hope to remove it from ES eventually. (See tc39/ecma262#240 (comment) for details.) Instead we simply use ParseScript and EvaluateScript directly.

This almost completes https://www.w3.org/Bugs/Public/show_bug.cgi?id=25981, with the remaining work item being to integrate promise jobs and ensure they are run as microtasks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

No branches or pull requests

4 participants