1 function getCSSText(property, value)
3 var element = document.createElement("div");
4 element.style.cssText = property + ": " + value;
5 return element.style[property];
8 function getComputedStyleValue(property, value)
10 var element = document.createElement("div");
11 document.body.appendChild(element);
12 element.style.setProperty(property, value);
13 var computedValue = getComputedStyle(element).getPropertyValue(property);
14 document.body.removeChild(element);
18 function getParentAndChildComputedStyles(property, parentValue, childValue)
20 var parentElement = document.createElement("div");
21 document.body.appendChild(parentElement);
22 parentElement.style.setProperty(property, parentValue);
23 var childElement = document.createElement("div");
24 parentElement.appendChild(childElement);
25 childElement.style.setProperty(property, childValue);
26 var parentComputedValue = getComputedStyle(parentElement).getPropertyValue(property);
27 var childComputedValue = getComputedStyle(childElement).getPropertyValue(property);
28 parentElement.removeChild(childElement);
29 document.body.removeChild(parentElement);
30 return {parent: parentComputedValue, child: childComputedValue};
33 function getParentAndChildComputedStylesString(property, parentValue, childValue)
35 var styles = getParentAndChildComputedStyles(property, parentValue, childValue);
36 return "parent: " + styles.parent + ", child: " + styles.child;
39 function getChildComputedStyle(property, parentValue, childValue)
41 var styles = getParentAndChildComputedStyles(property, parentValue, childValue);
45 function testExclusionSpecifiedProperty(property, value, expectedValue)
47 shouldBeEqualToString('getCSSText("' + property + '", "' + value + '")', expectedValue);
50 function testExclusionComputedProperty(property, value, expectedValue)
52 shouldBeEqualToString('getComputedStyleValue("' + property + '", "' + value + '")', expectedValue);
55 function testNotInheritedExclusionChildProperty(property, parentValue, childValue, expectedChildValue)
57 shouldBeEqualToString('getChildComputedStyle("' + property + '", "' + parentValue + '", "' + childValue + '")', expectedChildValue);
60 function testNotInheritedExclusionProperty(property, parentValue, childValue, expectedValue)
62 shouldBeEqualToString('getParentAndChildComputedStylesString("' + property + '", "' + parentValue + '", "' + childValue + '")', expectedValue);
65 function applyToEachArglist(testFunction, arglists)
67 arglists.forEach(function(arglist, i, a) {testFunction.apply(null, arglist);});