OLD | NEW |
| (Empty) |
1 function getCSSText(property, value) | |
2 { | |
3 var element = document.createElement("div"); | |
4 element.style.cssText = property + ": " + value; | |
5 return element.style[property]; | |
6 } | |
7 | |
8 function getComputedStyleValue(property, value) | |
9 { | |
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); | |
15 return computedValue; | |
16 } | |
17 | |
18 function getParentAndChildComputedStyles(property, parentValue, childValue) | |
19 { | |
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(p
roperty); | |
27 var childComputedValue = getComputedStyle(childElement).getPropertyValue(pro
perty); | |
28 parentElement.removeChild(childElement); | |
29 document.body.removeChild(parentElement); | |
30 return {parent: parentComputedValue, child: childComputedValue}; | |
31 } | |
32 | |
33 function getParentAndChildComputedStylesString(property, parentValue, childValue
) | |
34 { | |
35 var styles = getParentAndChildComputedStyles(property, parentValue, childVal
ue); | |
36 return "parent: " + styles.parent + ", child: " + styles.child; | |
37 } | |
38 | |
39 function getChildComputedStyle(property, parentValue, childValue) | |
40 { | |
41 var styles = getParentAndChildComputedStyles(property, parentValue, childVal
ue); | |
42 return styles.child; | |
43 } | |
44 | |
45 function testExclusionSpecifiedProperty(property, value, expectedValue) | |
46 { | |
47 shouldBeEqualToString('getCSSText("' + property + '", "' + value + '")', exp
ectedValue); | |
48 } | |
49 | |
50 function testExclusionComputedProperty(property, value, expectedValue) | |
51 { | |
52 shouldBeEqualToString('getComputedStyleValue("' + property + '", "' + value
+ '")', expectedValue); | |
53 } | |
54 | |
55 function testNotInheritedExclusionChildProperty(property, parentValue, childValu
e, expectedChildValue) | |
56 { | |
57 shouldBeEqualToString('getChildComputedStyle("' + property + '", "' + parent
Value + '", "' + childValue + '")', expectedChildValue); | |
58 } | |
59 | |
60 function testNotInheritedExclusionProperty(property, parentValue, childValue, ex
pectedValue) | |
61 { | |
62 shouldBeEqualToString('getParentAndChildComputedStylesString("' + property +
'", "' + parentValue + '", "' + childValue + '")', expectedValue); | |
63 } | |
64 | |
65 function applyToEachArglist(testFunction, arglists) | |
66 { | |
67 arglists.forEach(function(arglist, i, a) {testFunction.apply(null, arglist);
}); | |
68 } | |
OLD | NEW |