Repository navigation
Description
What is the issue with the HTML Standard?
The processing of http-equiv meta tags is currently done in the insertion steps (see this usage and this usage), meaning it happens synchronously upon insertion, before the post-insertion steps (which all browsers seem to have some form of) run.
But implementations don't seem to do this. See this test: https://wpt.fyi/results/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-default-style-meta-from-fragment.tentative.html?label=experimental&label=master&aligned. All browsers currently fail it (except for Edge, mysteriously), because Blink, WebKit, and Gecko (though I can't find the exact source code for this) all process http-equiv in the post-insertion steps.
Once whatwg/dom#1261 lands (🤞), we should update the spec to use the post-insertion steps for this kind of meta tag, to match implementations. In the meantime, I will update the test expectations.
There's an open question about what we should do with name/content meta elements. Both Chromium and WebKit also process these kinds of meta tags in the post-insertion steps, so I suppose we should update the following instances:
- https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names:insert-an-element-into-a-document
- https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names:insert-an-element-into-a-document-2
- https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names:insert-an-element-into-a-document-3
... to use the post-insertion steps too, to at least match 2/3 browser implementations. See https://wpt.fyi/results/dom/nodes/insertion-removing-steps/Node-append-meta-referrer-and-script-from-fragment.tentative.html?label=experimental&label=master&aligned. Given this, Gecko would be the odd one out and we'd file a bug against Gecko to start processing these kinds of meta elements in the post-insertion steps.
If anyone disagrees with this analysis and my recommendations above, let me know! I'll prepare spec PRs once the post-insertion steps primitive is a thing.
Activity
domfarolino commentedon Apr 1, 2024
cc @smaug----, for the deviation from WebKit and Blink that we're observing with Gecko (regarding
http-equivandname/contentmeta tags).Fix `<meta>` post-insertion steps expectations
Fix `<meta>` post-insertion steps expectations
domenic commentedon Apr 2, 2024
Do you know why browsers don't use the normal insertion steps for these? It seems very strange.
domfarolino commentedon Apr 2, 2024
I looked into this a bit thanks to your comment. Apparently HTMLMetaElement can (or at least once could) run script synchronously, which is absolutely not allowed during the normal insertion steps, so its entire processing phase got relegated to the post-insertion steps.
Assuming it still can run script synchronously for some meta types, I kind of imagine we could technically pull the non-script-running types into the "insertion steps", and keep only the script-running-types in the "post-insertion steps" but I'm not sure that buys us very much and it would require Blink & WebKit to change their longstanding behavior with probably very little upside for the vendors, so I'm not sure it's worth it.
domenic commentedon Apr 2, 2024
It's pretty hard to imagine how any meta elements could run scripts. I agree probably implementers won't want to invest any effort in changing this, but I wish we would, because this is bizarre.
domfarolino commentedon Apr 2, 2024
Yeah the only thing I can imagine would be unload or pagehide in a meta refresh, but those are actually unconditionally scheduled asynchronously anyways, so the script wouldn't run right away. I'll try and sniff around for other cases that motivated the original change, to see if they're still relevant.
smaug---- commentedon Apr 2, 2024
Are you sure default-style is processed at all in that testcase?
domfarolino commentedon Apr 2, 2024
Yep, in the post-insertion steps.
Fix `<meta>` post-insertion steps expectations
Fix `<meta>` post-insertion steps expectations
Fix `<meta>` referrer post-insertion steps expectations
Fix `<meta>` referrer post-insertion steps expectations
Fix `<meta>` referrer post-insertion steps expectations
Fix `<meta>` referrer post-insertion steps expectations
Fix `<meta>` referrer post-insertion steps expectations
Fix `<meta>` referrer post-insertion steps expectations
Bug 1888988 [wpt PR 45457] - Fix `<meta>` post-insertion steps expect…
Bug 1890362 [wpt PR 45611] - Fix `<meta>` referrer post-insertion ste…
Introduce DOM post-connection steps
Introduce DOM post-connection steps
Bug 1888988 [wpt PR 45457] - Fix `<meta>` post-insertion steps expect…
Bug 1890362 [wpt PR 45611] - Fix `<meta>` referrer post-insertion ste…
feat(html): the meta element's own steps re-run the page's supported …
feat(html): the default-style pragma; StyleEngine's rare state
fix(meta): the "referrer" metadata name runs in the meta element's po…