Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <html xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 2 | <!-- |
michael@0 | 3 | https://bugzilla.mozilla.org/show_bug.cgi?id=783415 |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <meta charset="utf-8"/> |
michael@0 | 7 | <title>Test "display" values of content in a flex container (Bug 783415)</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783415">Mozilla Bug 783415</a> |
michael@0 | 13 | <div id="display"> |
michael@0 | 14 | <div id="wrapper"></div> |
michael@0 | 15 | </div> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | <script type="application/javascript;version=1.7"> |
michael@0 | 18 | <![CDATA[ |
michael@0 | 19 | "use strict"; |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * Test "display" values of content in a flex container (Bug 783415) |
michael@0 | 23 | * ================================================================ |
michael@0 | 24 | * |
michael@0 | 25 | * This test creates content with a variety of specified "display" values |
michael@0 | 26 | * and checks what the computed "display" is when we put that content |
michael@0 | 27 | * in a flex container. (Generally, it'll be the "blockified" form of the |
michael@0 | 28 | * specified display-value.) |
michael@0 | 29 | */ |
michael@0 | 30 | |
michael@0 | 31 | /* |
michael@0 | 32 | * Utility function for getting computed style of "display". |
michael@0 | 33 | * |
michael@0 | 34 | * @arg aElem The element to query for its computed "display" value. |
michael@0 | 35 | * @return The computed display value |
michael@0 | 36 | */ |
michael@0 | 37 | function getComputedDisplay(aElem) { |
michael@0 | 38 | return window.getComputedStyle(aElem, "").display; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | /* |
michael@0 | 42 | * Function used for testing a given specified "display" value and checking |
michael@0 | 43 | * its computed value against expectations. |
michael@0 | 44 | * |
michael@0 | 45 | * @arg aSpecifiedDisplay |
michael@0 | 46 | * The specified value of "display" that we should test. |
michael@0 | 47 | * |
michael@0 | 48 | * @arg aExpectedDisplayAsFlexContainerChild |
michael@0 | 49 | * (optional) The expected computed "display" when an element with |
michael@0 | 50 | * aSpecifiedDisplay is a child of a flex container. If omitted, |
michael@0 | 51 | * this argument defaults to aSpecifiedDisplay. |
michael@0 | 52 | * |
michael@0 | 53 | * @arg aExpectedDisplayAsOutOfFlowFlexContainerChild |
michael@0 | 54 | * (optional) The expected computed "display" when an element with |
michael@0 | 55 | * aSpecifiedDisplay is a child of a flex container *and* has |
michael@0 | 56 | * position:[fixed|absolute] or float: [left|right] set. If omitted, |
michael@0 | 57 | * this argument defaults to aExpectedDisplayAsFlexContainerChild. |
michael@0 | 58 | */ |
michael@0 | 59 | function testDisplayValue(aSpecifiedDisplay, |
michael@0 | 60 | aExpectedDisplayAsFlexContainerChild, |
michael@0 | 61 | aExpectedDisplayAsOutOfFlowFlexContainerChild) { |
michael@0 | 62 | // DEFAULT-ARGUMENT-VALUES MAGIC: Make 2nd and 3rd args each default to |
michael@0 | 63 | // the preceding arg, if they're unspecified. |
michael@0 | 64 | if (typeof aExpectedDisplayAsFlexContainerChild == "undefined") { |
michael@0 | 65 | aExpectedDisplayAsFlexContainerChild = aSpecifiedDisplay; |
michael@0 | 66 | } |
michael@0 | 67 | if (typeof aExpectedDisplayAsOutOfFlowFlexContainerChild == "undefined") { |
michael@0 | 68 | aExpectedDisplayAsOutOfFlowFlexContainerChild = |
michael@0 | 69 | aExpectedDisplayAsFlexContainerChild; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | // FIRST: Create a node with display:aSpecifiedDisplay, and make sure that |
michael@0 | 73 | // this original display-type is honored in a non-flex-container context. |
michael@0 | 74 | let wrapper = document.getElementById("wrapper"); |
michael@0 | 75 | let node = document.createElement("div"); |
michael@0 | 76 | wrapper.appendChild(node); |
michael@0 | 77 | |
michael@0 | 78 | node.style.display = aSpecifiedDisplay; |
michael@0 | 79 | is(getComputedDisplay(node), aSpecifiedDisplay, |
michael@0 | 80 | "checking computed value of 'display: " + aSpecifiedDisplay + "' " + |
michael@0 | 81 | "should be the same as specified value, when parent is a block"); |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | // SECOND: We make our node's parent into a flex container, and make sure |
michael@0 | 85 | // that this produces the correct computed "display" value. |
michael@0 | 86 | wrapper.style.display = "flex"; |
michael@0 | 87 | is(getComputedDisplay(node), aExpectedDisplayAsFlexContainerChild, |
michael@0 | 88 | "checking computed value of 'display: " + aSpecifiedDisplay + "' " + |
michael@0 | 89 | "when parent is a flex container"); |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | // THIRD: We set "float" and "position" on our node (still inside of a |
michael@0 | 93 | // flex container), and make sure that this produces the correct computed |
michael@0 | 94 | // "display" value. |
michael@0 | 95 | node.style.cssFloat = "left"; |
michael@0 | 96 | is(getComputedDisplay(node), aExpectedDisplayAsOutOfFlowFlexContainerChild, |
michael@0 | 97 | "checking computed value of 'display: " + aSpecifiedDisplay + "' " + |
michael@0 | 98 | "when parent is a flex container and we're floated left"); |
michael@0 | 99 | node.style.cssFloat = ""; |
michael@0 | 100 | |
michael@0 | 101 | node.style.cssFloat = "right"; |
michael@0 | 102 | is(getComputedDisplay(node), aExpectedDisplayAsOutOfFlowFlexContainerChild, |
michael@0 | 103 | "checking computed value of 'display: " + aSpecifiedDisplay + "' " + |
michael@0 | 104 | "when parent is a flex container and we're floated right"); |
michael@0 | 105 | node.style.cssFloat = ""; |
michael@0 | 106 | |
michael@0 | 107 | node.style.position = "absolute"; |
michael@0 | 108 | is(getComputedDisplay(node), aExpectedDisplayAsOutOfFlowFlexContainerChild, |
michael@0 | 109 | "checking computed value of 'display: " + aSpecifiedDisplay + "' " + |
michael@0 | 110 | "when parent is a flex container and we're abs-pos"); |
michael@0 | 111 | node.style.position = ""; |
michael@0 | 112 | |
michael@0 | 113 | node.style.position = "fixed"; |
michael@0 | 114 | is(getComputedDisplay(node), aExpectedDisplayAsOutOfFlowFlexContainerChild, |
michael@0 | 115 | "checking computed value of 'display: " + aSpecifiedDisplay + "' " + |
michael@0 | 116 | "when parent is a flex container and we're fixed-pos"); |
michael@0 | 117 | node.style.position = ""; |
michael@0 | 118 | |
michael@0 | 119 | // FINALLY: Clean up -- remove the node we created, and turn the wrapper |
michael@0 | 120 | // back into its original display type (a block). |
michael@0 | 121 | wrapper.removeChild(node); |
michael@0 | 122 | wrapper.style.display = ""; |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | /* |
michael@0 | 126 | * Main test function |
michael@0 | 127 | */ |
michael@0 | 128 | function main() { |
michael@0 | 129 | testDisplayValue("none"); |
michael@0 | 130 | testDisplayValue("block"); |
michael@0 | 131 | testDisplayValue("flex"); |
michael@0 | 132 | testDisplayValue("inline-flex", "flex"); |
michael@0 | 133 | testDisplayValue("list-item"); |
michael@0 | 134 | testDisplayValue("table"); |
michael@0 | 135 | testDisplayValue("inline-table", "table"); |
michael@0 | 136 | |
michael@0 | 137 | // These values all compute to "block" in a flex container. Do them in a |
michael@0 | 138 | // loop, so that I don't have to type "block" a zillion times. |
michael@0 | 139 | var dispValsThatComputeToBlockInAFlexContainer = [ |
michael@0 | 140 | "inline", |
michael@0 | 141 | "inline-block", |
michael@0 | 142 | "-moz-box", |
michael@0 | 143 | "-moz-inline-box", |
michael@0 | 144 | "-moz-grid", |
michael@0 | 145 | "-moz-inline-grid", |
michael@0 | 146 | "-moz-grid-group", |
michael@0 | 147 | "-moz-grid-line", |
michael@0 | 148 | "-moz-stack", |
michael@0 | 149 | "-moz-inline-stack", |
michael@0 | 150 | "-moz-deck", |
michael@0 | 151 | "-moz-popup", |
michael@0 | 152 | "-moz-groupbox", |
michael@0 | 153 | ]; |
michael@0 | 154 | |
michael@0 | 155 | dispValsThatComputeToBlockInAFlexContainer.forEach( |
michael@0 | 156 | function(aSpecifiedDisplay) { |
michael@0 | 157 | testDisplayValue(aSpecifiedDisplay, "block"); |
michael@0 | 158 | }); |
michael@0 | 159 | |
michael@0 | 160 | // Table-parts are special. When they're a child of a flex container, |
michael@0 | 161 | // they normally don't get blockified -- instead, they trigger table-fixup |
michael@0 | 162 | // and get wrapped in a table. So, their expected display as the child of |
michael@0 | 163 | // a flex container is the same as their specified display. BUT, if |
michael@0 | 164 | // we apply out-of-flow styling, then *that* blockifies them before |
michael@0 | 165 | // we get to the table-fixup stage -- so then, their computed display |
michael@0 | 166 | // is "block". |
michael@0 | 167 | let tablePartsDispVals = [ |
michael@0 | 168 | "table-row-group", |
michael@0 | 169 | "table-column", |
michael@0 | 170 | "table-column-group", |
michael@0 | 171 | "table-header-group", |
michael@0 | 172 | "table-footer-group", |
michael@0 | 173 | "table-row", |
michael@0 | 174 | "table-cell", |
michael@0 | 175 | "table-caption" |
michael@0 | 176 | ]; |
michael@0 | 177 | |
michael@0 | 178 | tablePartsDispVals.forEach( |
michael@0 | 179 | function(aSpecifiedDisplay) { |
michael@0 | 180 | testDisplayValue(aSpecifiedDisplay, aSpecifiedDisplay, "block"); |
michael@0 | 181 | }); |
michael@0 | 182 | } |
michael@0 | 183 | |
michael@0 | 184 | main(); |
michael@0 | 185 | ]]> |
michael@0 | 186 | </script> |
michael@0 | 187 | </pre> |
michael@0 | 188 | </body> |
michael@0 | 189 | </html> |