cssRules No Longer Works in FireFox 1.5

M

mephraim

I have a WYSIWYG editor based on the HTMLArea project that uses the
cssRules object of a stylesheet to add/update stylesheet rules for
table cells. Ever since I upgraded to FireFox 1.5, I get the following
error message when trying to access the cssRules object:

"Access to restricted URI denied"

The code I am trying to execute looks like this:

var currStyleSheet = editor._doc.styleSheets[0];
var currRules = currStyleSheet.cssRules;
var tdIndex = currRules.length;
for(i = 0; i < currRules.length; i++) {
if(currStyleSheet.cssRules.item(i).type == 1) {
//if it is a style rule
var currRule = currRules.item(i)
if (currRule.selectorText.toLowerCase() == "td") {
tdIndex = i;
}
}

}

This code is simply looking for any rules for TD elements. I am at a
loss as to what is going on and/or what changed if FireFox to cause
this error. It worked fine in previous releases of FireFox. The
document that I am trying to access the stylesheet for is within an
IFRAME, which is what I believe is causing the problem. Thanks.
 
M

Martin Honnen

mephraim said:
I have a WYSIWYG editor based on the HTMLArea project that uses the
cssRules object of a stylesheet to add/update stylesheet rules for
table cells. Ever since I upgraded to FireFox 1.5, I get the following
error message when trying to access the cssRules object:

"Access to restricted URI denied"

The code I am trying to execute looks like this:

var currStyleSheet = editor._doc.styleSheets[0];
var currRules = currStyleSheet.cssRules;

Does the error message not name the exact line number causing the error?
which line is that, the attempt to access
editor._doc
or the attempt to access
currStyleSheet.cssRules

What is the URL of the HTML document with the script, what is the URL of
the iframe? As the error message says "Access to restricted URI denied"
seeing the URIs could help.
 
M

mephraim

The error occurrs on the line with the following:

var currRules = currStyleSheet.cssRules

I am able to read the stylesheet, but it throws that error when I try
to access cssRules.

I am running this page on a development server
(http://niagara.leepfrog.com/), and the IFRAME is populated with a
series of iframe.document.write() calls, not a SRC. It works when I
try to access cssRules from the main Document sylesheet, but throws the
error when I try to access cssRules in the IFRAME from the Main
Document. Hopefully this clears thins up a little bit.
 
M

Martin Honnen

mephraim said:
The error occurrs on the line with the following:

var currRules = currStyleSheet.cssRules

I am able to read the stylesheet, but it throws that error when I try
to access cssRules.

I am running this page on a development server
(http://niagara.leepfrog.com/), and the IFRAME is populated with a
series of iframe.document.write() calls, not a SRC.

Do you still experience the problem? Do you have a URL with the example?
 
V

VK

mephraim said:
I have a WYSIWYG editor based on the HTMLArea project that uses the
cssRules object of a stylesheet to add/update stylesheet rules for
table cells. Ever since I upgraded to FireFox 1.5, I get the following
error message when trying to access the cssRules object:

"Access to restricted URI denied"

The code I am trying to execute looks like this:

var currStyleSheet = editor._doc.styleSheets[0];
var currRules = currStyleSheet.cssRules;
var tdIndex = currRules.length;
for(i = 0; i < currRules.length; i++) {
if(currStyleSheet.cssRules.item(i).type == 1) {
//if it is a style rule
var currRule = currRules.item(i)
if (currRule.selectorText.toLowerCase() == "td") {
tdIndex = i;
}
}

}

Uhmm... and who told you that ever worked for Firefox at all? Did you
get yours from mozilla.org ?

Presuming that your style sheet has an ID (the only way to work
reliably with Firefox) and this ID is say "myCSS" then:

document.getElementById('myCSS').sheet.cssRules[0].style.backgroundColor;
and so on...

Works just fine since 1.0.4
 
T

Thomas 'PointedEars' Lahn

VK said:
mephraim said:
I have a WYSIWYG editor based on the HTMLArea project that uses the
cssRules object of a stylesheet to add/update stylesheet rules for
table cells. Ever since I upgraded to FireFox 1.5, I get the
following error message when trying to access the cssRules object:

"Access to restricted URI denied"

The code I am trying to execute looks like this:

var currStyleSheet = editor._doc.styleSheets[0];
var currRules = currStyleSheet.cssRules;
var tdIndex = currRules.length;
for(i = 0; i < currRules.length; i++) {
if(currStyleSheet.cssRules.item(i).type == 1) {
//if it is a style rule
var currRule = currRules.item(i)
if (currRule.selectorText.toLowerCase() == "td") {
tdIndex = i;
}
}

}

Uhmm... and who told you that ever worked for Firefox at all?

It is specified so.
Did you get yours from mozilla.org ?

Obviously you did not.
Presuming that your style sheet has an ID (the only way to work
reliably with Firefox)

Nonsense, Firefox (i.e. the Gecko DOM) provides the document.styleSheets
collection (a reference to a StyleSheetList object) accessed here as
specified in W3C DOM Level 2 Style.
and this ID is say "myCSS" then:

document.getElementById('myCSS').sheet.cssRules[0].style.backgroundColor;
and so on...
Nonsense:

Works just fine since 1.0.4

Of course it does not. A CSSStyleSheet object referred to by the return
value of document.getElementById() here does not have a 'sheet' property
at all. What would also work instead is

document.getElementById('myCSS').cssRules[0].style.backgroundColor;

However this required an ID while the document.styleSheets collection did
not. Unfortunately as usual, the information you provided is factually
flawed and therefore potentially harmful to others.


PointedEars
 
V

VK

Thomas said:
However this required an ID while the document.styleSheets collection did
not. Unfortunately as usual, the information you provided is factually
flawed and therefore potentially harmful to others.

as usual 2 months of experiments are defited by one specs reading...
 
T

Thomas 'PointedEars' Lahn

VK said:
as usual 2 months of experiments are defited by one specs reading...

What are you babbling about? The Gecko DOM does _not_ specify nor
_implement_ a `sheet' property for CSSStyleSheet objects. However, it has
specified _and_ has _implemented_ the document.styleSheets collection ever
since.

<URL:http://developer.mozilla.org/en/docs/DOM:style>

If your tests showed the opposite, then your tests are flawed. Which would
not be surprising, though.


PointedEars
 
M

Michael Winter

VK wrote:
[snip]
Uhmm... and who told you that [styleSheets and cssRules
collections] ever worked for Firefox at all?

It is specified so.

Quite right, though more importantly, it is implemented as such (since
at least Moz 1.3 - the earliest Gecko browser I have available at the
moment).

[snip]
Nonsense, Firefox (i.e. the Gecko DOM) provides the
document.styleSheets collection (a reference to a StyleSheetList
object) accessed here as specified in W3C DOM Level 2 Style.

Again, very true.

[snip]
A CSSStyleSheet object referred to by the return value of
document.getElementById() here does not have a 'sheet' property at
all.

An object implementing the CSSStyleSheet interface does not have a sheet
property, as you say, but a LINK or STYLE element that references a
cascading style sheet doesn't implement the CSSStyleSheet interface
directly. Instead, they both implement the LinkStyle interface, which
only has one property, sheet (and that does implement the StyleSheet
interface).
What would also work instead is

document.getElementById('myCSS').cssRules[0].style.backgroundColor;

You should have tested that; it doesn't (though I'm guilty of the same
charge on occasions when I'm feeling lazy :-/).

[snip]

It seems to me that this should be a security issue: the OP is trying to
access style sheet rules from an IFRAME element that isn't part of the
same domain (from the description, there's no URL). That said, I thought
security issues started when trying to access the document object[1].

Mike


[1] I don't 'do' frames, so I'll plead ignorance, here. It's a
potential starting point, though.
 
M

Michael Winter

On 28/01/2006 20:30, VK wrote:

[snip]
as usual 2 months of experiments are defited by one specs reading...

It took you two months to conclude that the Gecko DOM doesn't support
the styleSheets collection, when in fact it does?

Mike
 
T

Thomas 'PointedEars' Lahn

Michael said:
VK said:
Uhmm... and who told you that [styleSheets and cssRules
collections] ever worked for Firefox at all?

It is specified so.

Quite right, though more importantly, it is implemented as such (since
at least Moz 1.3 - the earliest Gecko browser I have available at the
moment).

I think it has been a Gecko DOM feature ever since. However, it is good
that you mention in works in release version 1.3, too, because the Cross
Reference at MDC says it worked since 1.4:

<URL:http://developer.mozilla.org/en/docs/DOM_Client_Object_Cross-Reference:document>

I guess I should correct this. Could you please post the original
User-Agent header or navigator.userAgent property value of the Mozilla/5.0
UA you have tested with?
A CSSStyleSheet object referred to by the return value of
document.getElementById() here does not have a 'sheet' property at
all.

An object implementing the CSSStyleSheet interface does not have a sheet
property, as you say, but a LINK or STYLE element that references a
cascading style sheet doesn't implement the CSSStyleSheet interface
directly. Instead, they both implement the LinkStyle interface, which
only has one property, sheet (and that does implement the StyleSheet
interface).
Correct.
What would also work instead is

document.getElementById('myCSS').cssRules[0].style.backgroundColor;

You should have tested that;

I have now and was quite surprised that there is a difference indeed.
it doesn't [...]

You are right. I consider this another reason why one should use
document.styleSheets instead, if possible.
It seems to me that this should be a security issue: the OP is trying to
access style sheet rules from an IFRAME element that isn't part of the
same domain

The same _second-level_ domain, to be exact. You can "cheat" the SOP by
assigning a value to `document.domain'.
(from the description, there's no URL).

Yeah, maybe it is a resource accessed with a http:// URI/URL trying to
access a resource with a file:// URI.
That said, I thought security issues started when trying to access the
document object[1].

That was my assumption as well and as Martin already asked the OP about
this, I found it unnecessary to ask again. However, since the OP did not
to post the relevant URIs to date it only stays an educated guess :-/


Regards,
PointedEars
 
R

Richard Cornford

Thomas said:
Michael said:
Thomas said:
VK wrote:
Uhmm... and who told you that [styleSheets and cssRules
collections] ever worked for Firefox at all?

It is specified so.

Quite right, though more importantly, it is implemented
as such (since at least Moz 1.3 - the earliest Gecko
browser I have available at the moment).

I think it has been a Gecko DOM feature ever since.

The oldest Gecko browser I have that implements document.styleSheets
(with cssRules) is 0.9.3, which is as close to being 'ever since' as you
would want.

I guess I should correct this. Could you please post the
original User-Agent header or navigator.userAgent property
value of the Mozilla/5.0 UA you have tested with?
<snip>

Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3) Gecko/20010801

Richard.
 
T

Thomas 'PointedEars' Lahn

Richard said:
Thomas said:
Michael said:
Thomas 'PointedEars' Lahn wrote:
VK wrote:
Uhmm... and who told you that [styleSheets and cssRules
collections] ever worked for Firefox at all?
[...]

I think it has been a Gecko DOM feature ever since.

The oldest Gecko browser I have that implements document.styleSheets
(with cssRules) is 0.9.3, which is as close to being 'ever since' as you
would want.
Thanks.

I guess I should correct this. Could you please post the
original User-Agent header or navigator.userAgent property
value of the Mozilla/5.0 UA you have tested with?
<snip>

Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3) Gecko/20010801

[x] done:
<URL:http://developer.mozilla.org/en/docs/Talk:DOM_Client_Object_Cross-Reference:document>


PointedEars
 
T

Thomas 'PointedEars' Lahn

Richard said:
Thomas said:
Michael said:
Thomas 'PointedEars' Lahn wrote:
VK wrote:
Uhmm... and who told you that [styleSheets and cssRules
collections] ever worked for Firefox at all?
[...]

I think it has been a Gecko DOM feature ever since.

The oldest Gecko browser I have that implements document.styleSheets
(with cssRules) is 0.9.3, which is as close to being 'ever since' as you
would want.
Thanks.

I guess I should correct this. Could you please post the
original User-Agent header or navigator.userAgent property
value of the Mozilla/5.0 UA you have tested with?
<snip>

Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.3) Gecko/20010801

[x] done:
<URL:http://developer.mozilla.org/en/docs/DOM_Client_Object_Cross-Reference:document>


PointedEars
 
V

VK

VK said:
as usual 2 months of experiments are defited by one specs reading...

"The Sleep of Reason Produces Monsters"
Francisco de Goya y Lucientes

document.styleSheets *is* supported by FF 1.5
 
T

Thomas 'PointedEars' Lahn

VK said:
"The Sleep of Reason Produces Monsters"
Francisco de Goya y Lucientes

You should not quote wisdom that you are incapable to understand.
document.styleSheets *is* supported by FF 1.5

_You_ stated that it is not:

,-[news:[email protected]]
|
| > var currStyleSheet = editor._doc.styleSheets[0];
|
| [...] and who told you that ever worked for Firefox at all?
|
| Presuming that your style sheet has an ID (the only way to work
| reliably with Firefox) [...]

And you have been disproven by me:

,-[news:[email protected]]
|
| > Presuming that your style sheet has an ID (the only way to work
| > reliably with Firefox)
|
| Nonsense, Firefox (i.e. the Gecko DOM) provides the document.styleSheets
| collection (a reference to a StyleSheetList object) accessed here as
| specified in W3C DOM Level 2 Style.

How more stupid can you possibly act?


PointedEars
 
V

VK

Thomas said:
You should not quote wisdom that you are incapable to understand.
How more stupid can you possibly act?

OK, document.styleSheets doesn't act as *I* would like it to act to,
but it does act somehow which is OK by me really.
Over the last 3 months JSONet project had been banned out of all public
incubators (like http://sourceforge.net/) as soon as I mentioned "Ajax
free solution". In case of any real or (my troubled mind produced)
imaginary troubles:

1) It is possible to transmit any proprietary data over the current CSS
standards.

2) Any transmission of such data over the current CSS rules is a public
domain free GNU-licensed exploit of currently existing public formats.

3) Anyone willing to copyright this GNU-announced format has to proove
that his/her idea of data trasmission over CSS took place time before
this announcement.
 
L

Lasse Reichstein Nielsen

VK said:
2) Any transmission of such data over the current CSS rules is a public
domain free GNU-licensed exploit of currently existing public formats.

That makes no sense, whatsoever.
The GNU license covers software covered by copyright.
The method of transmission is an idea, which can not be copyrighted.
It might be patentable, although I hope not.
3) Anyone willing to copyright this GNU-announced format has to proove
that his/her idea of data trasmission over CSS took place time before
this announcement.

As you say: "idea". Ideas are not copyrighted, they are patented.

/L
 
V

VK

Lasse said:
That makes no sense, whatsoever.
The GNU license covers software covered by copyright.
The method of transmission is an idea, which can not be copyrighted.
It might be patentable, although I hope not.

It is software, not hardware domain, where you need to make something
blinking and working for (c). In software an idea is often == solution.
And to destinguish between a bright (or not too much) idea and a
patentable algorythm is a real puzzle.

<http://patft.uspto.gov/netacgi/nph-...ript.TTL.&OS=TTL/javascript&RS=TTL/javascript>

Would you believe it? I wouldn't - and I still don't believe that the
above is practically applicable. But I don't want to repeat the story
in any shell perform form. It is not about personal benefits or glory -
the practical usability of what I am doing is a big question. But in
case if it is usable, I want to prevent any "smart people" like that
Honkong team from any attempt to take it out of public free domain.

1) Dynamic CSS file implant (using <LINK>)
2) CSS file like:
..data {
font-face: fantasy, "JSON%20URLEncoded%20data"
}
(there are 7 more style rules which can be used)

The rest are technical issues of threading and onload monitoring I'm
working on.

Cross-domain free.
Secure - data delivered and parsed as text, you have to explicetly
convert it into JavaScript
Support by any browser with full or partial CSS2 support (currently for
sure FF 1.x, IE 5.5, Camino 1.x)
As you say: "idea". Ideas are not copyrighted, they are patented.

Right, thank you. I have to intention to do neither of both, but terms
are important.
 
T

Thomas 'PointedEars' Lahn

VK said:
It is software, not hardware domain, where you need to make something
blinking and working for (c). In software an idea is often == solution.

Oh please read the GNU GPL and shut up. We (and I am sure I am not the
only one) had enough of your nonsense now.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top