Should this paragraph be green?


This test creates a DOM comment containing the string #test1 { color: green;} and appends it to an empty <style> element already in the document. Since this is a comment and not a text node, browsers don't parse the comment's textual contents as a stylesheet. But if the DOM of the document (after the script is executed) is serialized and reparsed, the paragraph SHOULD be green because the parsing rules of HTML will not interpret the comment as a comment but as a raw text node.

Because of that, and for consistency reasons between DOM and parsing rules, I think browsers should PASS the current test. In other terms, a DOM comment as child of a <style> element should be treated as the literal string <!-- followed by the comment's data and the literal string -->.


Firefox 4.0b9pre, Mac OS X, 2010-12-27 FAIL
Opera 11.00 (1156), Mac OS X FAIL
Google Chrome 8.0.552.224, Windows XP PASS
Safari 5.0.3 (6533.19.4), Mac OS X PASS
Internet Explorer 9 Platform Prview 1.9.8023.6000, Windows 7 FAIL

Test by Daniel Glazman, 2010-12-27