Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / exclusions / parsing / script-tests / parsing-test-utils.js
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(property);
27     var childComputedValue = getComputedStyle(childElement).getPropertyValue(property);
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, childValue);
36     return "parent: " + styles.parent + ", child: " + styles.child;
37 }
38
39 function getChildComputedStyle(property, parentValue, childValue)
40 {
41     var styles = getParentAndChildComputedStyles(property, parentValue, childValue);
42     return styles.child;
43 }
44
45 function testExclusionSpecifiedProperty(property, value, expectedValue)
46 {
47     shouldBeEqualToString('getCSSText("' + property + '", "' + value + '")', expectedValue);
48 }
49
50 function testExclusionComputedProperty(property, value, expectedValue)
51 {
52     shouldBeEqualToString('getComputedStyleValue("' + property + '", "' + value + '")', expectedValue);
53 }
54
55 function testNotInheritedExclusionChildProperty(property, parentValue, childValue, expectedChildValue)
56 {
57     shouldBeEqualToString('getChildComputedStyle("' + property + '", "' + parentValue + '", "' + childValue + '")', expectedChildValue);
58 }
59
60 function testNotInheritedExclusionProperty(property, parentValue, childValue, expectedValue)
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 }