Re: [heycam/webidl] Modernize invoking user code (#113)

Updated in response to code review comments at https://rawgit.com/domenic/webidl/modernize-invoke/index.html#es-user-objects

Regarding microtasks... hmm. "clean up after running script" says:

> If the JavaScript execution context stack is now empty, perform a microtask checkpoint. (If this runs scripts, these algorithms will be invoked reentrantly.)

I think in your test case the execution context stack is not empty. I think it looks like this at the time the handler executes:

1. **Bottom:** realm execution context (pushed by executing the `<script>`)
2. document.body.click's execution context ??
3. realm execution context (pushed by "invoke")
4. **Top**: function execution context for `logger.bind(undefined, 1)`.

That is, when invoke finishes, the execution context stack still contains 1 and 2. (Or at least 1... I'm having trouble remembering whether host-defined functions have execution contexts, so I'm not sure about 2.)

I created a similar test at http://jsbin.com/gukipafemo/edit?html,console,output where instead of using document.body.click() from inside a script, you manually click the button--so at the time the "invoke" finishes, you should have an empty stack. In this case Chrome works "as expected" with the interleaved calls, although Edge and Firefox do not. This reminds me of the cross-browser investigations in https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/ where Jake concluded that only Chrome was following the spec in these sort of tricky edge cases.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/113#issuecomment-220443667

Received on Thursday, 19 May 2016 20:51:05 UTC