Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test for computation of CSS 'inherit' on all properties and 'unset' on inherited properties</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="text/javascript" src="property_database.js"></script> |
michael@0 | 9 | <style type="text/css" id="stylesheet"></style> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <p id="display"><span id="fparent"><span id="fchild"></span></span></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | <div id="testnode"><span id="nparent"><span id="nchild"></span></span></div> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for computation of CSS 'inherit' on all properties and 'unset' on |
michael@0 | 23 | inherited properties **/ |
michael@0 | 24 | |
michael@0 | 25 | // elements without a frame |
michael@0 | 26 | var gNParent = document.getElementById("nparent"); |
michael@0 | 27 | var gNChild = document.getElementById("nchild"); |
michael@0 | 28 | // elements with a frame |
michael@0 | 29 | var gFParent = document.getElementById("fparent"); |
michael@0 | 30 | var gFChild = document.getElementById("fchild"); |
michael@0 | 31 | |
michael@0 | 32 | var gStyleSheet = document.getElementById("stylesheet").sheet; |
michael@0 | 33 | var gChildRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)]; |
michael@0 | 34 | var gChildRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #fchild {}", gStyleSheet.cssRules.length)]; |
michael@0 | 35 | var gChildRule3 = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild.allother, #fchild.allother {}", gStyleSheet.cssRules.length)]; |
michael@0 | 36 | var gChildRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule("#nchild, #nchild.allother, #fchild, #fchild.allother {}", gStyleSheet.cssRules.length)]; |
michael@0 | 37 | var gParentRuleTop = gStyleSheet.cssRules[gStyleSheet.insertRule("#nparent, #fparent {}", gStyleSheet.cssRules.length)]; |
michael@0 | 38 | |
michael@0 | 39 | var gTestUnset = SpecialPowers.getBoolPref("layout.css.unset-value.enabled"); |
michael@0 | 40 | |
michael@0 | 41 | function get_computed_value_node(node, property) |
michael@0 | 42 | { |
michael@0 | 43 | var cs = getComputedStyle(node, ""); |
michael@0 | 44 | return get_computed_value(cs, property); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function test_property(property) |
michael@0 | 48 | { |
michael@0 | 49 | var info = gCSSProperties[property]; |
michael@0 | 50 | if (info.backend_only) |
michael@0 | 51 | return; |
michael@0 | 52 | |
michael@0 | 53 | var keywords = ["inherit"]; |
michael@0 | 54 | if (info.inherited && gTestUnset) |
michael@0 | 55 | keywords.push("unset"); |
michael@0 | 56 | |
michael@0 | 57 | keywords.forEach(function(keyword) { |
michael@0 | 58 | if ("prerequisites" in info) { |
michael@0 | 59 | var prereqs = info.prerequisites; |
michael@0 | 60 | for (var prereq in prereqs) { |
michael@0 | 61 | gParentRuleTop.style.setProperty(prereq, prereqs[prereq], ""); |
michael@0 | 62 | gChildRuleTop.style.setProperty(prereq, prereqs[prereq], ""); |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | if (info.inherited) { |
michael@0 | 67 | gParentRuleTop.style.setProperty(property, info.initial_values[0], ""); |
michael@0 | 68 | var initial_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 69 | var initial_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 70 | gChildRule1.style.setProperty(property, info.other_values[0], ""); |
michael@0 | 71 | var other_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 72 | var other_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 73 | isnot(other_computed_n, initial_computed_n, |
michael@0 | 74 | "should be testing with values that compute to different things " + |
michael@0 | 75 | "for '" + property + "'"); |
michael@0 | 76 | isnot(other_computed_f, initial_computed_f, |
michael@0 | 77 | "should be testing with values that compute to different things " + |
michael@0 | 78 | "for '" + property + "'"); |
michael@0 | 79 | gChildRule3.style.setProperty(property, keyword, ""); |
michael@0 | 80 | gFChild.className="allother"; |
michael@0 | 81 | gNChild.className="allother"; |
michael@0 | 82 | var inherit_initial_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 83 | var inherit_initial_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 84 | is(inherit_initial_computed_n, initial_computed_n, |
michael@0 | 85 | keyword + " should cause inheritance of initial value for '" + |
michael@0 | 86 | property + "'"); |
michael@0 | 87 | is(inherit_initial_computed_f, initial_computed_f, |
michael@0 | 88 | keyword + " should cause inheritance of initial value for '" + |
michael@0 | 89 | property + "'"); |
michael@0 | 90 | gParentRuleTop.style.setProperty(property, info.other_values[0], ""); |
michael@0 | 91 | var inherit_other_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 92 | var inherit_other_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 93 | is(inherit_other_computed_n, other_computed_n, |
michael@0 | 94 | keyword + " should cause inheritance of other value for '" + |
michael@0 | 95 | property + "'"); |
michael@0 | 96 | is(inherit_other_computed_f, other_computed_f, |
michael@0 | 97 | keyword + " should cause inheritance of other value for '" + |
michael@0 | 98 | property + "'"); |
michael@0 | 99 | gParentRuleTop.style.removeProperty(property); |
michael@0 | 100 | gChildRule1.style.removeProperty(property); |
michael@0 | 101 | gChildRule3.style.setProperty(property, info.other_values[0], ""); |
michael@0 | 102 | gFChild.className=""; |
michael@0 | 103 | gNChild.className=""; |
michael@0 | 104 | } else { |
michael@0 | 105 | gParentRuleTop.style.setProperty(property, info.other_values[0], ""); |
michael@0 | 106 | var initial_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 107 | var initial_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 108 | var other_computed_n = get_computed_value_node(gNParent, property); |
michael@0 | 109 | var other_computed_f = get_computed_value_node(gFParent, property); |
michael@0 | 110 | isnot(other_computed_n, initial_computed_n, |
michael@0 | 111 | "should be testing with values that compute to different things " + |
michael@0 | 112 | "for '" + property + "'"); |
michael@0 | 113 | isnot(other_computed_f, initial_computed_f, |
michael@0 | 114 | "should be testing with values that compute to different things " + |
michael@0 | 115 | "for '" + property + "'"); |
michael@0 | 116 | gChildRule2.style.setProperty(property, keyword, ""); |
michael@0 | 117 | var inherit_other_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 118 | var inherit_other_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 119 | is(inherit_other_computed_n, other_computed_n, |
michael@0 | 120 | keyword + " should cause inheritance of other value for '" + |
michael@0 | 121 | property + "'"); |
michael@0 | 122 | is(inherit_other_computed_f, other_computed_f, |
michael@0 | 123 | keyword + " should cause inheritance of other value for '" + |
michael@0 | 124 | property + "'"); |
michael@0 | 125 | gParentRuleTop.style.removeProperty(property); |
michael@0 | 126 | gChildRule1.style.setProperty(property, info.other_values[0], ""); |
michael@0 | 127 | var inherit_initial_computed_n = get_computed_value_node(gNChild, property); |
michael@0 | 128 | var inherit_initial_computed_f = get_computed_value_node(gFChild, property); |
michael@0 | 129 | is(inherit_initial_computed_n, initial_computed_n, |
michael@0 | 130 | keyword + " should cause inheritance of initial value for '" + |
michael@0 | 131 | property + "'"); |
michael@0 | 132 | is(inherit_initial_computed_f, initial_computed_f, |
michael@0 | 133 | keyword + " should cause inheritance of initial value for '" + |
michael@0 | 134 | property + "'"); |
michael@0 | 135 | gParentRuleTop.style.removeProperty(property); |
michael@0 | 136 | gChildRule1.style.removeProperty(property); |
michael@0 | 137 | gChildRule2.style.removeProperty(property); |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | if ("prerequisites" in info) { |
michael@0 | 141 | var prereqs = info.prerequisites; |
michael@0 | 142 | for (var prereq in prereqs) { |
michael@0 | 143 | gParentRuleTop.style.removeProperty(prereq); |
michael@0 | 144 | gChildRuleTop.style.removeProperty(prereq); |
michael@0 | 145 | } |
michael@0 | 146 | } |
michael@0 | 147 | }); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | for (var prop in gCSSProperties) { |
michael@0 | 151 | var info = gCSSProperties[prop]; |
michael@0 | 152 | gChildRule3.style.setProperty(prop, info.other_values[0], ""); |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | for (var prop in gCSSProperties) |
michael@0 | 156 | test_property(prop); |
michael@0 | 157 | |
michael@0 | 158 | </script> |
michael@0 | 159 | </pre> |
michael@0 | 160 | </body> |
michael@0 | 161 | </html> |