CSS rules are recognized as CSSNameSpaceRule

VERIFIED FIXED

Status

()

Core
DOM: CSS Object Model
VERIFIED FIXED
5 years ago
5 months ago

People

(Reporter: Sebastian Zartner, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

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

Sebastian
(Reporter)

Comment 1

5 years ago
Created attachment 623587 [details]
Test case
(Reporter)

Comment 2

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

Comment 4

5 years ago
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: 580070
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
(Reporter)

Comment 7

3 years ago
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: 580070
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
Last Resolved: 6 months 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.