mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 13:58:49 +00:00
40 lines
1.2 KiB
HTML
40 lines
1.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test CSSStyleSheet constructor</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
|
</head>
|
|
<body>
|
|
<pre id="test"></pre>
|
|
<script type="application/javascript">
|
|
"use strict";
|
|
|
|
let sheet;
|
|
|
|
try {
|
|
sheet = new CSSStyleSheet();
|
|
ok(true, "CSSStyleSheet constructor should not throw");
|
|
} catch (e) {
|
|
ok(false, "CSSStyleSheet constructor should not throw: " + e);
|
|
}
|
|
|
|
if (sheet) {
|
|
ok(sheet instanceof CSSStyleSheet, "Constructor should create a CSSStyleSheet");
|
|
is(sheet.type, "text/css", "Constructed sheet should have CSS type");
|
|
is(sheet.href, null, "Constructed sheet should not have an href");
|
|
is(sheet.cssRules.length, 0, "Constructed sheet should start with no rules");
|
|
|
|
is(sheet.insertRule("#test { color: rgb(1, 2, 3); }", 0), 0,
|
|
"insertRule should work on a constructed sheet");
|
|
is(sheet.cssRules.length, 1, "insertRule should append a rule");
|
|
is(sheet.cssRules[0].selectorText, "#test", "Inserted rule should be readable");
|
|
|
|
sheet.deleteRule(0);
|
|
is(sheet.cssRules.length, 0, "deleteRule should remove the rule");
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|