2011-06-09 Julien Chaffraix <jchaffraix@codeaurora.org>
Reviewed by Antti Koivisto.
REGRESSION(84329): Stylesheets on some pages do not load
https://bugs.webkit.org/show_bug.cgi?id=61400
Adding test to cover the regression. The test actually uncovered
a bug in the way we handle alternate stylesheet and thus is
failing some parts.
* fast/css/link-disabled-attr-expected.txt: Added.
* fast/css/link-disabled-attr.html: Added.
2011-06-09 Julien Chaffraix <jchaffraix@codeaurora.org>
Reviewed by Antti Koivisto.
REGRESSION(84329): Stylesheets on some pages do not load
https://bugs.webkit.org/show_bug.cgi?id=61400
Test: fast/css/link-disabled-attr.html
Fixed r84329: the change did not take into account the fact
that HTMLLinkElement did already contain the disabled information
and the 2 information were not linked as they should have!
The new logic pushes the information to the stylesheet as this
is what the spec mandates and what FF is doing. Also it keeps
one bit of information (that JS enabled the stylesheet) as it
is needed for the recalcStyleSelector logic.
* dom/Document.cpp:
(WebCore::Document::recalcStyleSelector): s/isDisabled/disabled.
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::HTMLLinkElement): Removed m_disabledState,
replaced by m_isEnabledViaScript.
(WebCore::HTMLLinkElement::setDisabled): Updated the logic after
m_disabledState removal. It also matches the spec by forwarding
the disabled state to our stylesheet if we have one.
(WebCore::HTMLLinkElement::parseMappedAttribute): Removed harmful
handling of the disabledAttr.
(WebCore::HTMLLinkElement::process): Updated after m_disabledState removal.
* html/HTMLLinkElement.h:
(WebCore::HTMLLinkElement::isEnabledViaScript): Ditto.
(WebCore::HTMLLinkElement::isAlternate): Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@88479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/css/link-disabled-attr.html b/LayoutTests/fast/css/link-disabled-attr.html
new file mode 100644
index 0000000..d6f3e82
--- /dev/null
+++ b/LayoutTests/fast/css/link-disabled-attr.html
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link id="sheet" rel="stylesheet" href="../js/resources/js-test-style.css">
+<link id="notsheet" rel="author" href="mailto:nosuch@webkit.org">
+<link id="alt" rel="alternate stylesheet" title="altset" href="resources/green.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description">
+Series of tests to validate behavior of getting/setting link.disabled and link.sheet.disabled.<br>
+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
+</p>
+<div id="console"></div>
+<script>
+
+window.jsTestIsAsync = true;
+
+function onSheetLoaded(f, elem, maxtime) {
+ if (elem.sheet || maxtime <= 0)
+ f(elem);
+ else
+ setTimeout(function () { onSheetLoaded(f, elem, maxtime - 25);}, 25);
+}
+
+
+
+// With a non-stylesheet <link>, 'disabled' is always false.
+
+var console = document.getElementById("console");
+var originalBG = getComputedStyle(console).backgroundColor;
+var link;
+
+debug("notsheet");
+
+link = document.getElementById("notsheet");
+shouldBeNull("link.sheet");
+link.disabled = true;
+shouldBeFalse("link.disabled");
+
+
+// With a stylesheet <link>, 'disabled' and 'link.style.disabled' should both
+// work, and be consistent with each other.
+
+debug("sheet");
+
+link = document.getElementById("sheet");
+shouldBeNonNull("link.sheet");
+
+link.sheet.disabled = true;
+shouldBeTrue("link.disabled");
+shouldBeTrue("link.sheet.disabled");
+shouldBe("getComputedStyle(console).whiteSpace", "'normal'");
+
+link.disabled = false;
+shouldBeFalse("link.disabled");
+shouldBeFalse("link.sheet.disabled");
+shouldBe("getComputedStyle(console).whiteSpace", "'pre-wrap'");
+
+link.sheet.disabled = false;
+
+
+// An alternate stylesheet defaults to disabled when its title does not
+// match the preferred set.
+
+debug("altsheet");
+link = document.getElementById("alt");
+shouldBeTrue("link.disabled");
+
+// Toggling link.disabled activates the stylesheet.
+
+function altSheetLoaded(e) {
+ link = e;
+ shouldBeNonNull("link.sheet");
+ shouldBe("getComputedStyle(console).backgroundColor", "'rgb(0, 128, 0)'");
+
+ // Enabling a stylsheet set modifies disabled status of style sheets.
+
+ document.selectedStyleSheetSet = "nosuchset";
+ shouldBeTrue("link.disabled");
+ shouldBe("getComputedStyle(console).backgroundColor", "originalBG");
+
+ document.selectedStyleSheetSet = "altset";
+ shouldBeFalse("link.disabled");
+ shouldBe("getComputedStyle(console).backgroundColor", "'rgb(0, 128, 0)'");
+
+ // Disabling a stylesheet *after* its stylesheet set has been selected
+ // de-activates it.
+
+ link.disabled = true;
+ shouldBe("getComputedStyle(console).backgroundColor", "originalBG");
+
+ finishJSTest();
+}
+
+link.disabled = false;
+onSheetLoaded(altSheetLoaded, link, 500);
+
+successfullyParsed = true;
+
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body></html>