Bug 731271 - Part 7: Test. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Mon, 16 Sep 2013 09:35:49 +1000
changeset 162034 d3286418ea27adbb6df5748bbcb11b5452f1046d
parent 162033 85ce5e760457df235f5e16dc7488ac66c6c976aa
child 162035 247d083cf4ddc57b2da693a7c09bc4950fe9f881
push id38063
push usercmccormack@mozilla.com
push dateFri, 03 Jan 2014 07:05:22 +0000
treeherdermozilla-inbound@d3286418ea27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs731271
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 731271 - Part 7: Test. r=dbaron
layout/style/test/chrome/chrome.ini
layout/style/test/chrome/test_author_specified_style.html
--- a/layout/style/test/chrome/chrome.ini
+++ b/layout/style/test/chrome/chrome.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 support-files =
   bug535806-css.css
   bug535806-html.html
   bug535806-xul.xul
   hover_helper.html
 
 [test_additional_sheets.html]
+[test_author_specified_style.html]
 [test_bug535806.xul]
 [test_hover.html]
 [test_moz_document_rules.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/chrome/test_author_specified_style.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<title>Test for CSSStyleDeclaration.getAuthoredPropertyValue()</title>
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+<script>
+var values = [
+  // specified value         // returned from getAuthoredPropertyValue()
+  "#12F",                    "#12f",
+  "#1122FF",                 "#1122ff",
+  "rgb(10,20,30)",           "rgb(10, 20, 30)",
+  "Rgb(300,20,30)",          "rgb(255, 20, 30)",
+  "rgba(10,20,30,0.250)",    "rgba(10, 20, 30, 0.25)",
+  "OrangeRed",               "OrangeRed",
+  "rgb(10%,25%,99%)",        "rgb(10%, 25%, 99%)",
+  "rgb(6.66667%,0%,0.0%)",   "rgb(6.66667%, 0%, 0%)",
+  "HSL(0,25%,75%)",          "hsl(0, 25%, 75%)",
+  "hsl(60,0%,0%)",           "hsl(60, 0%, 0%)",
+  "hsla(60,50%,50%,0.1250)", "hsla(60, 50%, 50%, 0.125)",
+  "rgba(0,0,0,0)",           "rgba(0, 0, 0, 0)"
+];
+
+var properties = [
+  // property to test with  // fixed prefix to ignore from getAuthoredPropertyValue()
+  "color",                  "",
+  "background-color",       "",
+  "background",             "none repeat scroll 0% 0% "
+];
+
+var span = document.createElement("span");
+for (var j = 0; j < properties.length; j += 2) {
+  var propertyName = properties[j];
+  var expectedPrefix = properties[j + 1];
+  for (var i = 0; i < values.length; i += 2) {
+    var value = values[i];
+    var expected = values[i + 1];
+    span.setAttribute("style", propertyName + ": " + value);
+    is(span.style.getAuthoredPropertyValue(propertyName), expectedPrefix + expected, "specified " + value);
+  }
+}
+
+// also test a custom property
+span.setAttribute("style", "var-color: rgb(10%,25%,99%)");
+is(span.style.getAuthoredPropertyValue("var-color"), " rgb(10%,25%,99%)", "specified var-color");
+</script>