Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/cssom/css-rule-selector-text.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSSRule selectorText</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
a {
color: orangered;
text-decoration: underline dashed;
font-weight: bold;
}
svg|a {
fill: blueviolet;
text-decoration: underline solid;
text-transform: uppercase;
}
</style>
<p>
<a href="#">This is an ordinary HTML link</a>
</p>
<a href="#">
<text x="0" y="15">This is a link created in SVG</text>
</a>
</svg>
<script>
"use strict";
const { cssRules } = document.styleSheets[0];
test(() => {
assert_equals(cssRules.length, 3, "length should be 3");
}, "cssRules");
test(() => {
const expectedRules = [
{
selectorText: undefined,
type: 10
},
{
selectorText: "a",
type: 1
},
{
selectorText: "svg|a",
type: 1
}
];
for (let i = 0; i < cssRules.length; i++) {
const rule = cssRules[i];
const expected = expectedRules[i];
assert_equals(rule.selectorText, expected.selectorText, "selectorText matches");
assert_equals(rule.type, expected.type, "type matches");
}
}, "Each cssRule");
</script>