Closed Bug 754772 Opened 12 years ago Closed 7 years ago

CSS rules are recognized as CSSNameSpaceRule

Categories

(Core :: DOM: CSS Object Model, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: sebo, Unassigned)

References

Details

Attachments

(1 file)

Testing a MozCSSKeyframesRule for "instanceof CSSNameSpaceRule" returns true.
See the attached test case for more info.

Sebastian
Attached file Test case
Btw. MozCSSKeyframeRules are also recognized as CSSNameSpaceRules.

Sebastian
Attachment #623587 - Attachment mime type: text/plain → text/html
I'm guessing this is because CSSNameSpaceRule doesn't have any of its own interfaces; it just implements the generic CSS rule interface.
Though a MozCSSKeyframeRule isn't an instance of a CSSNameSpaceRule.

I tried the following (via Firebug's Command Editor) to verify that:

function isInstanceOf(object, constructor)
{
    var proto = Object.getPrototypeOf(object);
    do {
        if (proto === constructor)
           return true;
        proto = Object.getPrototypeOf(proto);
    } while (proto !== null);
    return false;
}

isInstanceOf(document.styleSheets[1].cssRules[0], CSSNameSpaceRule.prototype);

Sebastian
This is a bit weird.  CSSNameSpaceRule.prototype.__proto__ == CSSRule.prototype.  That part is fine.

Peter, is the issues that we end up QIing to nsIDOMCSSRule in some xpconnect hasInstance hook here?

In any case, new bindings, when they happen, will fix this.
Depends on: ParisBindings
Note that this problem also occurs for the new CSSPageRule.
A test case can be found at https://getfirebug.com/tests/manual/issues/6282/issue6282.html.

Executing document.styleSheets[2].cssRules[1] instanceof CSSNameSpaceRule will incorrectly return true.

Sebastian
Just stumbled over this again when trying to check an CSSCounterStyleRule.

As David and Boris indicate this actually happens for all types of CSS rules.

> Peter, is the issues that we end up QIing to nsIDOMCSSRule in some xpconnect hasInstance hook here?
@Boris, could it be that Peter didn't get this message? At least there's no Peter in the CC list.

Also you marked this issue being blocked by the big Paris Bindings issue. I guess the more specific issue this depends on is bug 851892, so I replaced the bug number. Please correct me if that's wrong.

Sebastian
Depends on: 851892
No longer depends on: ParisBindings
Summary: MozCSSKeyframesRule is recognized as CSSNameSpaceRule → CSS rules are recognized as CSSNameSpaceRule
ni'ing regarding comment 7.

Sebastian
Flags: needinfo?(bzbarsky)
Looks like I forgot to cc Peter.  Anyway, the right fix here is the webidl conversion.
Flags: needinfo?(bzbarsky)
Fixed in bug 851892.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
I can confirm that it works in Nightly 53.0a1 2017-01-21. Thank you, Boris!

Sebastian
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: