blob: 7c24cdd1d19467bc9f4ca740413554aa1b26a89d [file] [log] [blame]
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +00001<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
arv@chromium.orgf728a632011-10-20 02:48:38 +00004<link id="sheet" rel="stylesheet" href="data:tex/css,#test-element{text-decoration:line-through}">
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +00005<link id="notsheet" rel="author" href="mailto:nosuch@webkit.org">
6<link id="alt" rel="alternate stylesheet" title="altset" href="resources/green.css">
mark.lam@apple.com104d9932013-09-07 22:20:15 +00007<script src="../../resources/js-test-pre.js"></script>
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +00008</head>
9<body>
arv@chromium.orgf728a632011-10-20 02:48:38 +000010
11<span id="test-element"></span>
12
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000013<script>
14
arv@chromium.orgf728a632011-10-20 02:48:38 +000015description("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');
17
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000018window.jsTestIsAsync = true;
19
20function onSheetLoaded(f, elem, maxtime) {
21 if (elem.sheet || maxtime <= 0)
22 f(elem);
23 else
24 setTimeout(function () { onSheetLoaded(f, elem, maxtime - 25);}, 25);
25}
26
27
28
29// With a non-stylesheet <link>, 'disabled' is always false.
30
arv@chromium.orgf728a632011-10-20 02:48:38 +000031var testElement = document.getElementById("test-element");
32var originalBG = getComputedStyle(testElement).backgroundColor;
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000033var link;
34
35debug("notsheet");
36
37link = document.getElementById("notsheet");
38shouldBeNull("link.sheet");
39link.disabled = true;
40shouldBeFalse("link.disabled");
41
42
43// With a stylesheet <link>, 'disabled' and 'link.style.disabled' should both
44// work, and be consistent with each other.
45
46debug("sheet");
47
48link = document.getElementById("sheet");
49shouldBeNonNull("link.sheet");
50
51link.sheet.disabled = true;
52shouldBeTrue("link.disabled");
53shouldBeTrue("link.sheet.disabled");
arv@chromium.orgf728a632011-10-20 02:48:38 +000054shouldBeEqualToString("getComputedStyle(testElement).textDecoration", "none");
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000055
56link.disabled = false;
57shouldBeFalse("link.disabled");
58shouldBeFalse("link.sheet.disabled");
arv@chromium.orgf728a632011-10-20 02:48:38 +000059shouldBeEqualToString("getComputedStyle(testElement).textDecoration", "line-through");
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000060
61link.sheet.disabled = false;
62
63
64// An alternate stylesheet defaults to disabled when its title does not
65// match the preferred set.
66
67debug("altsheet");
68link = document.getElementById("alt");
69shouldBeTrue("link.disabled");
70
71// Toggling link.disabled activates the stylesheet.
72
73function altSheetLoaded(e) {
74 link = e;
75 shouldBeNonNull("link.sheet");
arv@chromium.orgf728a632011-10-20 02:48:38 +000076 shouldBe("getComputedStyle(testElement).backgroundColor", "'rgb(0, 128, 0)'");
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000077
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000078 link.disabled = true;
arv@chromium.orgf728a632011-10-20 02:48:38 +000079 shouldBe("getComputedStyle(testElement).backgroundColor", "originalBG");
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000080
81 finishJSTest();
82}
83
84link.disabled = false;
85onSheetLoaded(altSheetLoaded, link, 500);
86
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000087</script>
mark.lam@apple.com104d9932013-09-07 22:20:15 +000088<script src="../../resources/js-test-post.js"></script>
commit-queue@webkit.orgbf3b1de2011-06-09 20:33:20 +000089</body></html>