Closed Bug 285478 Opened 20 years ago Closed 20 years ago

Cannot access document.styleSheets[0].cssRules in XHTML

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: aaronlev, Unassigned)

Details

(Whiteboard: dhtml-access)

Attachments

(2 files)

NS_DOM_ERROR_BAD_URI exception for
javascript:alert(document.styleSheets[0].cssRules);

Steps:
1. Load HTML document, execute
javascript:alert(document.styleSheets[0].cssRules);
The alert should say [object CSSRuleList]

2. Load XHTML document, execute same JS rule
No alert will show up. The JavaScript console reports NS_ERROR_DOM_BAD_URI
Whiteboard: dhtml-access
This fails because in the XHTML document document.styleSheets[0] seems to be
coming from "http://www.w3.org/StyleSheets/TR/base", so our security checks
block access (from bugzilla).
The source has:

 <?xml-stylesheet type="text/css" href="http://www.w3.org/StyleSheets/TR/base"?>

In XHTML that means a stylesheet to be loaded, and we can't allow access to that
sheet for security reasons, as you pointed out.

In HTML it means absolutely nothing (and isn't even included in the testcase),
so the [0] element of styleSheets comes from the <style>.  Accessing that is fine.

Sounds like everything is working correctly.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: