Bug 1046140 - Bail if getSubpropertiesForCSSProperty param is a CSS variable. r=bz, a=sledru
authorPaul Rouget <paul@mozilla.com>
Thu, 31 Jul 2014 22:33:17 +1000
changeset 217334 2a4ae7cd64a170889c1f8b5bc0a419555e712d85
parent 217333 898849f4927785445181cafafaf6286e35caa959
child 217335 0b662794f7dcde27ca7cca412e718020d8054a2f
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sledru
bugs1046140
milestone33.0a2
Bug 1046140 - Bail if getSubpropertiesForCSSProperty param is a CSS variable. r=bz, a=sledru
layout/inspector/inDOMUtils.cpp
layout/inspector/tests/mochitest.ini
layout/inspector/tests/test_bug1046140.html
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -604,17 +604,18 @@ static void GetOtherValuesForProperty(co
 NS_IMETHODIMP
 inDOMUtils::GetSubpropertiesForCSSProperty(const nsAString& aProperty,
                                            uint32_t* aLength,
                                            char16_t*** aValues)
 {
   nsCSSProperty propertyID =
     nsCSSProps::LookupProperty(aProperty, nsCSSProps::eEnabledForAllContent);
 
-  if (propertyID == eCSSProperty_UNKNOWN) {
+  if (propertyID == eCSSProperty_UNKNOWN ||
+      propertyID == eCSSPropertyExtra_variable) {
     return NS_ERROR_FAILURE;
   }
 
   nsTArray<nsString> array;
   if (!nsCSSProps::IsShorthand(propertyID)) {
     *aValues = static_cast<char16_t**>(nsMemory::Alloc(sizeof(char16_t*)));
     (*aValues)[0] = ToNewUnicode(nsCSSProps::GetStringValue(propertyID));
     *aLength = 1;
--- a/layout/inspector/tests/mochitest.ini
+++ b/layout/inspector/tests/mochitest.ini
@@ -7,14 +7,15 @@ support-files = bug856317.css
 [test_bug536379.html]
 [test_bug536379-2.html]
 [test_bug557726.html]
 [test_bug609549.xhtml]
 [test_bug806192.html]
 [test_bug856317.html]
 [test_bug877690.html]
 [test_bug1006595.html]
+[test_bug1046140.html]
 [test_color_to_rgba.html]
 [test_css_property_is_valid.html]
 [test_get_all_style_sheets.html]
 [test_is_valid_css_color.html]
 [test_isinheritableproperty.html]
 [test_selectormatcheselement.html]
new file mode 100644
--- /dev/null
+++ b/layout/inspector/tests/test_bug1046140.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1046140
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1046140</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+  var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
+    .getService(SpecialPowers.Ci.inIDOMUtils);
+
+  try {
+    utils.getSubpropertiesForCSSProperty("--foo");
+    ok(false, "expected an exception");
+  } catch(e) {
+    ok(true, "getSubpropertiesForCSSProperty throws when passed a CSS variable");
+  }
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1046140">Mozilla Bug 1046140</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>