1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <link id=
"sheet" rel=
"stylesheet" href=
"data:tex/css,#test-element{text-decoration:line-through}">
5 <link id=
"notsheet" rel=
"author" href=
"mailto:nosuch@webkit.org">
6 <link id=
"alt" rel=
"alternate stylesheet" title=
"altset" href=
"resources/green.css">
7 <script src=
"../../resources/js-test.js"></script>
11 <span id=
"test-element"></span>
15 description("Series of tests to validate behavior of getting/setting link.disabled and link.sheet.disabled.<br>" +
16 'Test for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=61400">61400</a>: REGRESSION(84329): Stylesheets on some pages do not load');
18 window
.jsTestIsAsync
= true;
20 function onSheetLoaded(f
, elem
, maxtime
) {
21 if (elem
.sheet
|| maxtime
<= 0)
24 setTimeout(function () { onSheetLoaded(f
, elem
, maxtime
- 25);}, 25);
29 // With a non-stylesheet <link>, 'disabled' is always false.
31 var testElement
= document
.getElementById("test-element");
32 var originalBG
= getComputedStyle(testElement
).backgroundColor
;
37 link
= document
.getElementById("notsheet");
38 shouldBeNull("link.sheet");
40 shouldBeFalse("link.disabled");
43 // With a stylesheet <link>, 'disabled' and 'link.style.disabled' should both
44 // work, and be consistent with each other.
48 link
= document
.getElementById("sheet");
49 shouldBeNonNull("link.sheet");
51 link
.sheet
.disabled
= true;
52 shouldBeTrue("link.disabled");
53 shouldBeTrue("link.sheet.disabled");
54 shouldBeEqualToString("getComputedStyle(testElement).textDecoration", "none solid rgb(0, 0, 0)");
56 link
.disabled
= false;
57 shouldBeFalse("link.disabled");
58 shouldBeFalse("link.sheet.disabled");
59 shouldBeEqualToString("getComputedStyle(testElement).textDecoration", "line-through");
61 link
.sheet
.disabled
= false;
64 // An alternate stylesheet defaults to disabled when its title does not
65 // match the preferred set.
68 link
= document
.getElementById("alt");
69 shouldBeTrue("link.disabled");
71 // Toggling link.disabled activates the stylesheet.
73 function altSheetLoaded(e
) {
75 shouldBeNonNull("link.sheet");
76 shouldBe("getComputedStyle(testElement).backgroundColor", "'rgb(0, 128, 0)'");
78 // Enabling a stylsheet set modifies disabled status of style sheets.
80 document
.selectedStyleSheetSet
= "nosuchset";
81 shouldBeTrue("link.disabled");
82 shouldBe("getComputedStyle(testElement).backgroundColor", "originalBG");
84 document
.selectedStyleSheetSet
= "altset";
85 shouldBeFalse("link.disabled");
86 shouldBe("getComputedStyle(testElement).backgroundColor", "'rgb(0, 128, 0)'");
88 // Disabling a stylesheet *after* its stylesheet set has been selected
92 shouldBe("getComputedStyle(testElement).backgroundColor", "originalBG");
97 link
.disabled
= false;
98 onSheetLoaded(altSheetLoaded
, link
, 500);