Console warning for undefined property rule.selectorText

RESOLVED FIXED

Status

()

Firefox
Tabbed Browser
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: Dolske, Assigned: fryn)

Tracking

({regression})

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [fixed-in-bug-851436])

(Reporter)

Description

5 years ago
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
I filed bug 851870 on warning about that.
The good news is that this is new code in 21.
Keywords: regression
(Assignee)

Comment 4

5 years ago
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
(Assignee)

Updated

5 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 5 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.