If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

cssRule's selectorText and cssText don't preserve parentheses




DOM: CSS Object Model
9 years ago
5 years ago


(Reporter: Ben Lerner, Unassigned)



Firefox Tracking Flags

(Not tracked)



(1 attachment)



9 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2008120122 Firefox/3.0.5
Build Identifier: Firefox 3.0.5 -- Shiretoko nightly

For selectors containing parentheses--e.g. treechildren::-moz-tree-row( foo bar )--syntax as indicated at https://developer.mozilla.org/en/CSS/:-moz-tree-row, getting the cssText or selectorText returns the text without parentheses or spaces--e.g. treechildren:--moz-tree-rowfoobar--which is of course not the intended result.

Reproducible: Always

Steps to Reproduce:
See the attached file.

The particular project I'm working on involves Firefox extensions and requires parsing CSS files and extracting their declarations.  Since it's an extension project, I'm going to encounter CSS rules like this containing Mozilla proprietary extensions to the CSS syntax, so I need to use Mozilla's parser...  If there's a workaround for this bug, I'd be happy to use that instead, but until then this blocks my project somewhat.

Comment 1

9 years ago
Created attachment 358654 [details]
Short test case demonstrating the problem

I can get the raw text of the entire CSS file using the innerHTML property of the style tag, but that doesn't help me find the legal CSS declarations in the file, or what the cssText of those declarations is.

Comment 2

9 years ago
If this helps -- it does not matter whether I use an HTML IFrame or a XUL IFrame, with CSS included from web content or chrome or a style tag.  So it's not likely to be a chrome/web permissions problem (since the example I cited was a Mozilla-private property for a XUL element)
Version: unspecified → 1.9.1 Branch

Comment 3

9 years ago
Confirmed on mozilla-central.  I'll teach my CSS parser fuzzer to look for more bugs like this.
Ever confirmed: true

Comment 4

9 years ago
That got me bug 475214, bug 475215, and bug 475216.  Thanks for the inspiration, Ben ;)


9 years ago
OS: Windows XP → All
Hardware: x86 → All
Version: 1.9.1 Branch → Trunk
Sounds like nsCSSSelector::ToStringInternal needs to be taught to serialize this correctly.  If any instances of this selector were tested in layout/style/tests/test_selectors.html we would have caught this...

Comment 6

9 years ago
A (tangential) documentation & parsing question: which is the correct syntax?
a) treechildren::-moz-tree-line(selected focus)   <<-- sans comma
b) treechildren::-moz-tree-line(selected, focus)  <<-- with comma

It appears that (a) is correct according to the W3C spec, (b) is properly rejected by Firefox when I try it, (a) is recommended by https://developer.mozilla.org/en/CSS/:-moz-tree-row, and (b) is recommended by http://www.xulplanet.com/tutorials/xultu/treestyle.html (linked to from the first page), and (b) is used by e.g. AdBlock Plus.

I recognize this bug is about the CSS printing issue I raised above; I seem to have lost the link to filing MDC bugs, though.  If some kind someone could provide an answer and/or the link, I'll redirect this as appropriate :)
QA Contact: general → style-system
I think this was fixed by bug 602341.
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.