Open Bug 1528982 Opened 7 years ago Updated 4 years ago

<meta http-equiv> does nothing when inserted from a script

Categories

(Core :: DOM: Core & HTML, defect, P3)

66 Branch
defect

Tracking

()

People

(Reporter: nox, Unassigned)

Details

Attachments

(1 file)

Attached file anne.html —

I may be doing something wrong, but I can't seem to write any JS that inserts a <meta http-equiv=default-style> element in a document and have it take any effect.

See attachment, where the background becomes green in both Safari and Chrome.

I think this is a more general issue. Only nsContentSink::ProcessHeaderData calls Document::SetHeaderData, which is what sets the relevant thingie.

Can you confirm this also doesn't produce expected results for other <meta http-equiv=foo> tags?

https://searchfox.org/mozilla-central/rev/05d4b6962a571585bd679d2bbb0df0a5fb4e4eff/dom/base/nsContentSink.cpp#293

Also, what does the spec say? Should meta tags react dynamically to DOM changes? The following also doesn't work, as expected:

<!doctype html>
<link rel="alternate stylesheet" title=green href="data:text/css,body{background:green;color:white}">
<meta http-equiv="default-style">
<body>
<script>document.querySelector("meta").content = "green"</script>

Spec says that yes, it should react dynamically to DOM changes. Interestingly, it doesn't seem to say it should react to attribute changes, so I don't know if your own sample is a bug or intended.

The spec defines it as a side effect of insertion of the element, whereas in Gecko it seems to be a side effect of insertion of the element from the HTML parser?

(In reply to Anne (:annevk) from comment #3)

The spec defines it as a side effect of insertion of the element, whereas in Gecko it seems to be a side effect of insertion of the element from the HTML parser?

Yes, that's right.

Component: DOM: CSS Object Model → DOM: Core & HTML
Summary: <meta http-equiv=default-style> does nothing when inserted from a script → <meta http-equiv> does nothing when inserted from a script

Note that for some of them, like <meta http-equiv="content-security-policy"> and <meta name="viewport">, it happens on insertion in the document:

https://searchfox.org/mozilla-central/rev/05d4b6962a571585bd679d2bbb0df0a5fb4e4eff/dom/html/HTMLMetaElement.cpp#87

That sounds a bit fishy.

Some of the <meta> tag implementations predate the WhatWG HTML spec and were based on reverse-engineering existing browsers at the time. Others postdate the spec and were written based on the spec.

If other browsers match the spec for the ones that predate it (so the spec was based on those browsers, or they later changed to align with the spec), we should match too. If not, the spec should be changed accordingly.

Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: