Closed Bug 851862 Opened 11 years ago Closed 11 years ago

Console warning for undefined property rule.selectorText

Categories

(Firefox :: Tabbed Browser, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Dolske, Assigned: fryn)

References

Details

(Keywords: regression, Whiteboard: [fixed-in-bug-851436])

I've sometimes noticed this console warning in my builds:

JavaScript strict warning: chrome://browser/content/tabbrowser.xml, line 3062: reference to undefined property rule.selectorText

This is easily reproducible with a new profile:

1) Start browser (you'll get 2 default tabs)
2) Close the leftmost tab

Relevant code:

      <field name="_delayResizingRule" readonly="true"><![CDATA[
        const href = "chrome://browser/content/browser.css";
        const selector = ".tabbrowser-tabs[dontresize] > .tabbrowser-tab[fadein]:not([pinned])";

        // XXX: document.styleSheets is not iterable (see bug 738196)
        for (let sheet of Array.slice(document.styleSheets))
          if (sheet.href == href)
            for (let rule of Array.slice(sheet.cssRules))
              if (rule.selectorText == selector) { rule; break; }
      ]]></field>


Some debug logging seems to show this it triggered right away by the first 2 rules in the sheet. I suspect this is because the first two rules in browser.css are:

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");

Seems like |sheet.cssRules| should either just skip this info, or map it into a useful form.
sheet.cssRules is a CSSRuleList, which is essentially an array of CSSRule objects.  selectorText is on CSSStyleRule, which is a subclass of CSSRule.  So the frontend code here is buggy.

Worse, though, it's really bad form for any code in the Firefox frontend to be poking at the object model of style sheets; it defeats sharing optimizations and forces each window to have a separate copy of all the data in that style sheet.
Component: Style System (CSS) → Tabbed Browser
Product: Core → Firefox
The good news is that this is new code in 21.
Keywords: regression
I'm fixing this in bug 851436 by backing all the relevant stuff out: the patches for bug 837486, bug 649654, and bug 821859 in that order. When that lands, I will close this as [fixed-in-bug-851436].
Assignee: nobody → fyan
Status: NEW → ASSIGNED
Depends on: 851436
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-bug-851436]
You need to log in before you can comment on or make changes to this bug.