Web Inspector: Add layout test for lowercase CSSProperty names
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Sep 2014 00:00:35 +0000 (00:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Sep 2014 00:00:35 +0000 (00:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135961

Patch by Matt Baker <mattbaker@apple.com> on 2014-09-08
Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

Modified test components to support testing CSSStyleManager and related classes:
- Added required models to Test.html
- Added CSSCompletions initialization to Test.js
- CSSCompletions doesn't assume presence of CodeMirror.

* UserInterface/Base/Test.js:
(WebInspector.loaded):
* UserInterface/Models/CSSCompletions.js:
* UserInterface/Test.html:

LayoutTests:

Added test to check that property names in matched CSS rules are returned in lowercase
when specified with upper or mixed case in the original CSS source.

* inspector/css/matched-style-properties-expected.txt: Added.
* inspector/css/matched-style-properties.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/inspector/css/matched-style-properties-expected.txt [new file with mode: 0644]
LayoutTests/inspector/css/matched-style-properties.html [new file with mode: 0644]
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Test.js
Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js
Source/WebInspectorUI/UserInterface/Test.html

index 3d4c382..f9166e3 100644 (file)
@@ -1,5 +1,18 @@
 2014-09-08  Matt Baker  <mattbaker@apple.com>
 
+        Web Inspector: Add layout test for lowercase CSSProperty names
+        https://bugs.webkit.org/show_bug.cgi?id=135961
+
+        Reviewed by Joseph Pecoraro.
+
+        Added test to check that property names in matched CSS rules are returned in lowercase
+        when specified with upper or mixed case in the original CSS source.
+
+        * inspector/css/matched-style-properties-expected.txt: Added.
+        * inspector/css/matched-style-properties.html: Added.
+
+2014-09-08  Matt Baker  <mattbaker@apple.com>
+
         Web Inspector: Fixes to layout test infrastructure
         https://bugs.webkit.org/show_bug.cgi?id=136360
 
diff --git a/LayoutTests/inspector/css/matched-style-properties-expected.txt b/LayoutTests/inspector/css/matched-style-properties-expected.txt
new file mode 100644 (file)
index 0000000..6ba2a87
--- /dev/null
@@ -0,0 +1,10 @@
+Testing that the author rules returned by CSSStyleManager.stylesForNode have lowercase property names regardless of CSS source formatting.
+
+Property valid: background-color
+Property valid: color
+Property valid: border-style
+Property valid: border-width
+Property valid: position
+Property valid: top
+Property valid: left
+
diff --git a/LayoutTests/inspector/css/matched-style-properties.html b/LayoutTests/inspector/css/matched-style-properties.html
new file mode 100644 (file)
index 0000000..fae20fe
--- /dev/null
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div#node1 {
+    BACKGROUND-COLOR:blue;
+    COLOR:white;
+    border-STYLE:solid;
+    BORDER-width:0;
+    position:absolute;
+    ToP:0;
+    lEfT:0;
+}
+</style>
+<script type="text/javascript" src="../../http/tests/inspector/inspector-test.js"></script>
+<script>
+function test() {
+    var nodeStyles;
+
+    function validatePropertyName(name)
+    {
+        if (typeof name != "string") {
+            InspectorTest.log("Unexpected property name type: " + typeof name);
+            return false;
+        }
+
+        if (name.toLowerCase() != name) {
+            InspectorTest.log("Property name contains uppercase characters: " + name);
+            return false;
+        }
+        return true;
+    }
+
+    function validateStyles()
+    {
+        for (var i = 0; i < nodeStyles.matchedRules.length; ++i) {
+            var rule = nodeStyles.matchedRules[i];
+            if (rule.type != WebInspector.CSSRule.Type.Author)
+                continue;
+
+            for (var j = 0; j < rule.style.properties.length; ++j) {
+                var property = rule.style.properties[j];
+
+                if (property.anonymous)
+                    continue;
+
+                if (validatePropertyName(property.name))
+                    InspectorTest.log("Property valid: " + property.name);
+            }
+        }
+
+        InspectorTest.completeTest();
+    }
+
+    function onStylesRefreshed()
+    {
+        nodeStyles.removeEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, onStylesRefreshed, this);
+        validateStyles();
+    }
+
+    WebInspector.domTreeManager.requestDocument(function(documentNode) {
+        WebInspector.domTreeManager.querySelector(documentNode.id, "#node1", function(contentNodeId) {
+            if (contentNodeId) {
+                var domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
+                nodeStyles = WebInspector.cssStyleManager.stylesForNode(domNode);
+
+                if (nodeStyles.needsRefresh)
+                    nodeStyles.addEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, onStylesRefreshed, this);
+                else
+                    validateStyles();
+            } else {
+                InspectorTest.log("DOM node not found.");
+                InspectorTest.completeTest();
+            }
+        });
+    });
+}
+</script>
+</head>
+<body onload="runTest()">
+    <p>Testing that the author rules returned by CSSStyleManager.stylesForNode have lowercase property names regardless of CSS source formatting.</p>
+
+    <div id="node1"></div>
+</body>
+</html>
index 07e6358..4548593 100644 (file)
@@ -1,5 +1,22 @@
 2014-09-08  Matt Baker  <mattbaker@apple.com>
 
+        Web Inspector: Add layout test for lowercase CSSProperty names
+        https://bugs.webkit.org/show_bug.cgi?id=135961
+
+        Reviewed by Joseph Pecoraro.
+
+        Modified test components to support testing CSSStyleManager and related classes:
+        - Added required models to Test.html
+        - Added CSSCompletions initialization to Test.js
+        - CSSCompletions doesn't assume presence of CodeMirror.
+
+        * UserInterface/Base/Test.js:
+        (WebInspector.loaded):
+        * UserInterface/Models/CSSCompletions.js:
+        * UserInterface/Test.html:
+
+2014-09-08  Matt Baker  <mattbaker@apple.com>
+
         Web Inspector: Fixes to layout test infrastructure
         https://bugs.webkit.org/show_bug.cgi?id=136360
 
index b407692..742075a 100644 (file)
@@ -53,6 +53,9 @@ WebInspector.loaded = function()
     // Enable agents.
     InspectorAgent.enable();
 
+    // Perform one-time tasks.
+    WebInspector.CSSCompletions.requestCSSNameCompletions();
+
     // Establish communication with the InspectorBackend.
     InspectorFrontendHost.loaded();
 }
index 59650b1..aeafe67 100644 (file)
@@ -83,6 +83,11 @@ WebInspector.CSSCompletions.requestCSSNameCompletions = function()
 
         WebInspector.CSSCompletions.cssNameCompletions = new WebInspector.CSSCompletions(names, false);
 
+        // CodeMirror is not included by tests so we shouldn't assume it always exists.
+        // If it isn't available we skip MIME type associations.
+        if (!window.CodeMirror)
+            return;
+
         var propertyNamesForCodeMirror = {};
         var valueKeywordsForCodeMirror = {"inherit": true, "initial": true};
         var colorKeywordsForCodeMirror = {};
index c191bf9..fa90950 100644 (file)
     <script src="Models/CallFrame.js"></script>
     <script src="Models/Color.js"></script>
     <script src="Models/ContentFlow.js"></script>
+    <script src="Models/CSSCompletions.js"></script>
+    <script src="Models/CSSKeywordCompletions.js"></script>
+    <script src="Models/CSSProperty.js"></script>
+    <script src="Models/CSSRule.js"></script>
+    <script src="Models/CSSStyleDeclaration.js"></script>
+    <script src="Models/CSSStyleSheet.js"></script>
     <script src="Models/DOMNode.js"></script>
+    <script src="Models/DOMNodeStyles.js"></script>
     <script src="Models/DOMStorageObject.js"></script>
     <script src="Models/DOMTree.js"></script>
     <script src="Models/ExecutionContext.js"></script>