Title: [109741] trunk
Revision
109741
Author
pfeld...@chromium.org
Date
2012-03-05 07:07:50 -0800 (Mon, 05 Mar 2012)

Log Message

Web Inspector: check for the number of parsed css properties.
https://bugs.webkit.org/show_bug.cgi?id=80268

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Test: inspector/styles/set-property-boundaries.html

* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::didRemoveDOMNode):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::setPropertyText):

LayoutTests:

* inspector/styles/set-property-boundaries-expected.txt: Added.
* inspector/styles/set-property-boundaries.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109740 => 109741)


--- trunk/LayoutTests/ChangeLog	2012-03-05 15:00:52 UTC (rev 109740)
+++ trunk/LayoutTests/ChangeLog	2012-03-05 15:07:50 UTC (rev 109741)
@@ -1,3 +1,13 @@
+2012-03-05  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: check for the number of parsed css properties.
+        https://bugs.webkit.org/show_bug.cgi?id=80268
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/styles/set-property-boundaries-expected.txt: Added.
+        * inspector/styles/set-property-boundaries.html: Added.
+
 2012-03-02  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: [Styles] [CRASH] Handle rule addition and inline style editing failure due to Content-Security-Policy in the page

Added: trunk/LayoutTests/inspector/styles/set-property-boundaries-expected.txt (0 => 109741)


--- trunk/LayoutTests/inspector/styles/set-property-boundaries-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/set-property-boundaries-expected.txt	2012-03-05 15:07:50 UTC (rev 109741)
@@ -0,0 +1,5 @@
+Tests that setting CSS property text out of boundaries does not crash.
+
+color: red;
+Server error(-32000): INDEX_SIZE_ERR.
+
Property changes on: trunk/LayoutTests/inspector/styles/set-property-boundaries-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/styles/set-property-boundaries.html (0 => 109741)


--- trunk/LayoutTests/inspector/styles/set-property-boundaries.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/set-property-boundaries.html	2012-03-05 15:07:50 UTC (rev 109741)
@@ -0,0 +1,64 @@
+<html>
+<head>
+
+<style>
+h1 {
+    color: red;
+}
+</style>
+
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    CSSAgent.getAllStyleSheets(styleSheetInfosLoaded);
+
+    function styleSheetInfosLoaded(error, infos)
+    {
+        if (error) {
+            InspectorTest.addResult("error: " + error);
+            InspectorTest.completeTest();
+            return;
+        }
+
+        for (var i = 0; i < infos.length; ++i)
+            CSSAgent.getStyleSheet(infos[i].styleSheetId, styleSheetLoaded);
+    }
+
+    function styleSheetLoaded(error, styleSheet)
+    {
+        if (error) {
+            InspectorTest.addResult("error: " + error);
+            InspectorTest.completeTest();
+            return;
+        }
+        editRule(styleSheet.rules[0]);
+    }
+
+    function editRule(rule)
+    {
+        var style = rule.style;
+        InspectorTest.addResult(style.cssProperties[0].text);
+
+        const outOfBOundsRuleIndex = 10;
+        CSSAgent.setPropertyText(style.styleId, outOfBOundsRuleIndex, "color:blue;", true, dumpErrorMessage);
+    }
+
+    function dumpErrorMessage(error)
+    {
+        InspectorTest.addResult(error);
+        InspectorTest.completeTest();
+    }   
+}
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that setting CSS property text out of boundaries does not crash.
+</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/styles/set-property-boundaries.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (109740 => 109741)


--- trunk/Source/WebCore/ChangeLog	2012-03-05 15:00:52 UTC (rev 109740)
+++ trunk/Source/WebCore/ChangeLog	2012-03-05 15:07:50 UTC (rev 109741)
@@ -1,3 +1,17 @@
+2012-03-05  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: check for the number of parsed css properties.
+        https://bugs.webkit.org/show_bug.cgi?id=80268
+
+        Reviewed by Vsevolod Vlasov.
+
+        Test: inspector/styles/set-property-boundaries.html
+
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::didRemoveDOMNode):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::setPropertyText):
+
 2012-03-05  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: Tabbed pane should redraw tab elements when tab is closed.

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (109740 => 109741)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2012-03-05 15:00:52 UTC (rev 109740)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2012-03-05 15:07:50 UTC (rev 109741)
@@ -988,10 +988,8 @@
     if (!node)
         return;
 
-    if (m_lastElementWithPseudoState.get() == node) {
+    if (m_lastElementWithPseudoState.get() == node)
         clearPseudoState(false);
-        return;
-    }
 
     NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(node);
     if (it == m_nodeToInspectorStyleSheet.end())

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (109740 => 109741)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2012-03-05 15:00:52 UTC (rev 109740)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2012-03-05 15:07:50 UTC (rev 109741)
@@ -331,6 +331,10 @@
 
     InspectorStyleTextEditor editor(&allProperties, &m_disabledProperties, text, newLineAndWhitespaceDelimiters());
     if (overwrite) {
+        if (index >= allProperties.size()) {
+            ec = INDEX_SIZE_ERR;
+            return false;
+        }
         *oldText = allProperties.at(index).rawText;
         editor.replaceProperty(index, propertyText);
     } else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to