commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 4 | <link id="sheet" rel="stylesheet" href="data:tex/css,#test-element{text-decoration:line-through}"> |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 5 | <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.com | 104d993 | 2013-09-07 22:20:15 +0000 | [diff] [blame] | 7 | <script src="../../resources/js-test-pre.js"></script> |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 8 | </head> |
| 9 | <body> |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 10 | |
| 11 | <span id="test-element"></span> |
| 12 | |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 13 | <script> |
| 14 | |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 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'); |
| 17 | |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 18 | window.jsTestIsAsync = true; |
| 19 | |
| 20 | function 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.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 31 | var testElement = document.getElementById("test-element"); |
| 32 | var originalBG = getComputedStyle(testElement).backgroundColor; |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 33 | var link; |
| 34 | |
| 35 | debug("notsheet"); |
| 36 | |
| 37 | link = document.getElementById("notsheet"); |
| 38 | shouldBeNull("link.sheet"); |
| 39 | link.disabled = true; |
| 40 | shouldBeFalse("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 | |
| 46 | debug("sheet"); |
| 47 | |
| 48 | link = document.getElementById("sheet"); |
| 49 | shouldBeNonNull("link.sheet"); |
| 50 | |
| 51 | link.sheet.disabled = true; |
| 52 | shouldBeTrue("link.disabled"); |
| 53 | shouldBeTrue("link.sheet.disabled"); |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 54 | shouldBeEqualToString("getComputedStyle(testElement).textDecoration", "none"); |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 55 | |
| 56 | link.disabled = false; |
| 57 | shouldBeFalse("link.disabled"); |
| 58 | shouldBeFalse("link.sheet.disabled"); |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 59 | shouldBeEqualToString("getComputedStyle(testElement).textDecoration", "line-through"); |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 60 | |
| 61 | link.sheet.disabled = false; |
| 62 | |
| 63 | |
| 64 | // An alternate stylesheet defaults to disabled when its title does not |
| 65 | // match the preferred set. |
| 66 | |
| 67 | debug("altsheet"); |
| 68 | link = document.getElementById("alt"); |
| 69 | shouldBeTrue("link.disabled"); |
| 70 | |
| 71 | // Toggling link.disabled activates the stylesheet. |
| 72 | |
| 73 | function altSheetLoaded(e) { |
| 74 | link = e; |
| 75 | shouldBeNonNull("link.sheet"); |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 76 | shouldBe("getComputedStyle(testElement).backgroundColor", "'rgb(0, 128, 0)'"); |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 77 | |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 78 | link.disabled = true; |
arv@chromium.org | f728a63 | 2011-10-20 02:48:38 +0000 | [diff] [blame] | 79 | shouldBe("getComputedStyle(testElement).backgroundColor", "originalBG"); |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 80 | |
| 81 | finishJSTest(); |
| 82 | } |
| 83 | |
| 84 | link.disabled = false; |
| 85 | onSheetLoaded(altSheetLoaded, link, 500); |
| 86 | |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 87 | </script> |
mark.lam@apple.com | 104d993 | 2013-09-07 22:20:15 +0000 | [diff] [blame] | 88 | <script src="../../resources/js-test-post.js"></script> |
commit-queue@webkit.org | bf3b1de | 2011-06-09 20:33:20 +0000 | [diff] [blame] | 89 | </body></html> |