Alternate xml-stylesheets with no title are loaded, in violation of the CSSOM draft
authortomz@codeaurora.org <tomz@codeaurora.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 23:00:15 +0000 (23:00 +0000)
committertomz@codeaurora.org <tomz@codeaurora.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 23:00:15 +0000 (23:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77549

Patch by Dave Tharp <dtharp@codeaurora.org> on 2012-03-13
Reviewed by David Hyatt.

Source/WebCore:

Amended code to ignore alternate stylesheets that do not have a title attribute.

Test: fast/css/xml-stylesheet-alternate-no-title.xhtml

* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):

LayoutTests:

Added new text test, modified existing test: added title attribute to alternate stylesheet.

* fast/css/xml-stylesheet-alternate-no-title-expected.txt: Added.
* fast/css/xml-stylesheet-alternate-no-title.xhtml: Added.
* fast/css/xml-stylesheet-alternate-processing.xhtml:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@110632 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css/xml-stylesheet-alternate-no-title-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/xml-stylesheet-alternate-no-title.xhtml [new file with mode: 0644]
LayoutTests/fast/css/xml-stylesheet-alternate-processing.xhtml
Source/WebCore/ChangeLog
Source/WebCore/dom/ProcessingInstruction.cpp

index ccff821..0e1c563 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-13  Dave Tharp  <dtharp@codeaurora.org>
+
+        Alternate xml-stylesheets with no title are loaded, in violation of the CSSOM draft
+        https://bugs.webkit.org/show_bug.cgi?id=77549
+
+        Reviewed by David Hyatt.
+
+        Added new text test, modified existing test: added title attribute to alternate stylesheet.
+
+        * fast/css/xml-stylesheet-alternate-no-title-expected.txt: Added.
+        * fast/css/xml-stylesheet-alternate-no-title.xhtml: Added.
+        * fast/css/xml-stylesheet-alternate-processing.xhtml:
+
 2012-03-13  Alexey Proskuryakov  <ap@apple.com>
 
         Adding missing results.
diff --git a/LayoutTests/fast/css/xml-stylesheet-alternate-no-title-expected.txt b/LayoutTests/fast/css/xml-stylesheet-alternate-no-title-expected.txt
new file mode 100644 (file)
index 0000000..fc52965
--- /dev/null
@@ -0,0 +1,10 @@
+xml alternate stylesheet with no title test
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS getComputedStyle(element).getPropertyValue('color') is 'rgb(0, 128, 0)'
+This text should be green
diff --git a/LayoutTests/fast/css/xml-stylesheet-alternate-no-title.xhtml b/LayoutTests/fast/css/xml-stylesheet-alternate-no-title.xhtml
new file mode 100644 (file)
index 0000000..e0b85be
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml-stylesheet type="text/css" href="data:text/css,root { color: green; }"?>
+<?xml-stylesheet alternate="yes" type="text/css" href="data:text/css,root { color: red; }"?>
+<!DOCTYPE html>
+<root xmlns="http://www.w3.org/1999/xhtml" >
+    <head>
+        <meta charset="utf-8"/>
+        <script src="../js/resources/js-test-pre.js"></script>
+        <script>
+
+            description("xml alternate stylesheet with no title test");
+
+            window.onload = function() {
+
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+
+                if (document.styleSheets.length > 1)
+                    document.styleSheets[1].disabled = false;
+
+                element = document.getElementById("sampleText") ;
+                shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(0, 128, 0)'");
+            }
+
+        </script>
+    </head>
+
+    <body>
+        <div id="sampleText">This text should be green</div>
+
+        <script src="../js/resources/js-test-post.js"></script>
+    </body>
+</root>
index 88fd14e..a80b64b 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="resources/xml-stylesheet-pi-not-in-prolog.css" type="text/css" alternate="yes"?>
+<?xml-stylesheet href="resources/xml-stylesheet-pi-not-in-prolog.css" type="text/css" alternate="yes" title="alt1"?>
 <?xml-stylesheet href="resources/xml-stylesheet-pi-not-in-prolog.css" type="text/css" alternate="no"?>
 <?xml-stylesheet href="resources/xml-stylesheet-pi-not-in-prolog.css" type="text/css"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
index 4ef8703..3f20c85 100644 (file)
@@ -1,3 +1,17 @@
+2012-03-13  Dave Tharp  <dtharp@codeaurora.org>
+
+        Alternate xml-stylesheets with no title are loaded, in violation of the CSSOM draft
+        https://bugs.webkit.org/show_bug.cgi?id=77549
+
+        Reviewed by David Hyatt.
+
+        Amended code to ignore alternate stylesheets that do not have a title attribute.
+
+        Test: fast/css/xml-stylesheet-alternate-no-title.xhtml
+
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+
 2012-03-13  Levi Weintraub  <leviw@chromium.org>
 
         Revert RenderLayer::absoluteBoundingBox to an IntRect
index 3817279..98808d6 100644 (file)
@@ -134,6 +134,9 @@ void ProcessingInstruction::checkStyleSheet()
         m_title = attrs.get("title");
         m_media = attrs.get("media");
 
+        if (m_alternate && m_title.isEmpty())
+            return;
+
         if (href.length() > 1 && href[0] == '#') {
             m_localHref = href.substring(1);
 #if ENABLE(XSLT)