Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Micro-tasks don't define insertion point semantics & all browsers disagree #165

Closed
DigiTec opened this issue Apr 5, 2016 · 9 comments
Closed

Comments

@DigiTec
Copy link

DigiTec commented Apr 5, 2016

https://jsfiddle.net/h0446dky/

FireFox prints thirdfourth as they reopen the document after the script exits, but yet they define an insertion point for the lifetime of third and fourth (two separate promises)

Chrome prints firstsecondthirdfourth as they keep an insertion point the entire time

Edge either crashes or prints third as script execution stops after the first call to document.write

@DigiTec
Copy link
Author

DigiTec commented Apr 5, 2016

@domenic @annevk Would either of you want to take a stab at this? Seems pretty critical. We believe, but have no data yet, that some sites may be hitting this issue. We are likely to put in use counters/trackers of some sort to figure out how often these edge cases are being hit.

@domenic
Copy link

domenic commented Apr 5, 2016

Sure, can you reopen over on the HTML Standard?

@annevk
Copy link
Member

annevk commented Apr 7, 2016

As far as I can tell this is a bug in Firefox. There's a microtask checkpoint that's part of script execution so I don't see how insertion point could get undefined before that point.

@annevk
Copy link
Member

annevk commented Apr 7, 2016

@DigiTec
Copy link
Author

DigiTec commented Apr 8, 2016

So for inline script execution we have:
8. Execute the script.
9. Decrement the parser’s script nesting level by one. If the parser’s script nesting level is zero (which it always should be at this point), then set the parser pause flag to false.
10. Let the insertion point be undefined again.

And https://w3c.github.io/html/single-page.html#execute-a-script-block doesn't have an explicit micro-task checkpoint.

The only micro-task checkpoint I see is BEFORE we execute the script, but that has nothing to do with the Promise's that get inserted during.

@annevk Can you help me out with how you arrived at the "microtask checkpoint that's part of script execution?"

@annevk
Copy link
Member

annevk commented Apr 8, 2016

@DigiTec I don't know anything about that specification as I (and others) explained here: https://annevankesteren.nl/2016/01/film-at-11. It's completely secret what kind of modifications were made, how, and why.

Now, https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block, in step 8, invokes https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script, which in step 10 invokes https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script, which in step 5 handles microtasks.

@DigiTec
Copy link
Author

DigiTec commented Apr 8, 2016

Thank you, I consulted the incorrect spec at this time and that is an issue for me to work out. Thank you for the explanation. I'll review the relevant sections and see if there is anything we can do here to help align Edge with the other browsers in this regard.

@travisleithead Seems like a big chunk of text to push back into the W3C version of the spec.

@annevk
Copy link
Member

annevk commented Apr 8, 2016

The W3C version, apart from it being unclear what changes were made before the initial commit (apart from breaking many links), is easily hundreds of commits behind. Coupled with the W3C having switched formats, which apparently took four-person months or so to do, I very much doubt it's going to be usable ever.

@chaals chaals added this to the HTML5.1 WD (June 2016) milestone May 10, 2016
arronei pushed a commit that referenced this issue May 16, 2016
…ATWG (#387)

* CSP integrations for Issue #201

Had to adapt "resulting URL record" -> "resulting parsed URL" (will fix
with changes to 2.5.2 eventually)

* Update refs to CSP3 (from CSP1 Note) for Issue #191

Also fix typo 'teh'

* Groundwork for realms #190 and scripting updates #165, #189

Importing dependent changes since last sync of WHATWG in mid-Jan.
Added JS-related terms

* intermediate: translated definitions in scripting section

* Imports 3 fetch script algorithms
and reorders a few sections to match WHATWG

* add algorithms for script creation

* WIP: Syncing changes through event handler section

* webappapi include mostly synced. script element section remains

* syncing changes for the script element

* pulling in more required sections for linking issues

* Further reducing linking issues

* fixes more linking issues

* Finally builds CLEAN!

* Adding some missing CSP changes

* Adding a few more CSP dependencies

* All CSP changes validated and builds clean

* Removed script modules

* tables in DTs don't render nicely; also fixed backtick use in a few places

* Fixes for @arronei's PR feedback
@travisleithead
Copy link
Member

With thanks to our friends at WHATWG, I believe I've ported over all of these dependencies in 1b70bac. Closing this issue now.

arronei pushed a commit that referenced this issue Jun 17, 2016
* CSP integrations for Issue #201

Had to adapt "resulting URL record" -> "resulting parsed URL" (will fix
with changes to 2.5.2 eventually)

* Update refs to CSP3 (from CSP1 Note) for Issue #191

Also fix typo 'teh'

* Groundwork for realms #190 and scripting updates #165, #189

Importing dependent changes since last sync of WHATWG in mid-Jan.
Added JS-related terms

* intermediate: translated definitions in scripting section

* Imports 3 fetch script algorithms
and reorders a few sections to match WHATWG

* add algorithms for script creation

* WIP: Syncing changes through event handler section

* webappapi include mostly synced. script element section remains

* syncing changes for the script element

* pulling in more required sections for linking issues

* Further reducing linking issues

* fixes more linking issues

* Finally builds CLEAN!

* Adding some missing CSP changes

* Adding a few more CSP dependencies

* All CSP changes validated and builds clean

* removing tables from dt elements for readability

* Fix a minor bad merge issue
arronei pushed a commit to arronei/html that referenced this issue Apr 17, 2017
* CSP integrations for Issue w3c#201

Had to adapt "resulting URL record" -> "resulting parsed URL" (will fix
with changes to 2.5.2 eventually)

* Update refs to CSP3 (from CSP1 Note) for Issue w3c#191

Also fix typo 'teh'

* Groundwork for realms w3c#190 and scripting updates w3c#165, w3c#189

Importing dependent changes since last sync of WHATWG in mid-Jan.
Added JS-related terms

* intermediate: translated definitions in scripting section

* Imports 3 fetch script algorithms
and reorders a few sections to match WHATWG

* add algorithms for script creation

* WIP: Syncing changes through event handler section

* webappapi include mostly synced. script element section remains

* syncing changes for the script element

* pulling in more required sections for linking issues

* Further reducing linking issues

* fixes more linking issues

* Finally builds CLEAN!

* Adding some missing CSP changes

* Adding a few more CSP dependencies

* All CSP changes validated and builds clean

* removing tables from dt elements for readability

* Fix a minor bad merge issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants