Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=696253 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test behavior of 'align-self:auto' (Bug 696253)</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
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 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=696253">Mozilla Bug 696253</a> |
michael@0 | 14 | <div id="display"> |
michael@0 | 15 | <div id="myDiv"></div> |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | "use strict"; |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * Test behavior of 'align-self:auto' (Bug 696253) |
michael@0 | 23 | * =============================================== |
michael@0 | 24 | * |
michael@0 | 25 | * The value "align-self: auto" is special. It's the initial value for |
michael@0 | 26 | * "align-self", and it's supposed to compute to the parent's "align-items" value. |
michael@0 | 27 | * |
michael@0 | 28 | * However, to allow its style-struct to be shared by default, we internally |
michael@0 | 29 | * make it compute to a special "auto" enumerated value, and then we resolve that |
michael@0 | 30 | * to the correct value by examining the parent's style struct whenever we actually |
michael@0 | 31 | * need to use it. |
michael@0 | 32 | * |
michael@0 | 33 | * This test makes sure that optimization isn't detectable to content. |
michael@0 | 34 | * |
michael@0 | 35 | * One special case of this is inheritance -- e.g.: |
michael@0 | 36 | * |
michael@0 | 37 | * <html style="align-items: baseline"> |
michael@0 | 38 | * <body style="align-self: auto; align-items: center"> |
michael@0 | 39 | * <div style="align-self: inherit"> |
michael@0 | 40 | * |
michael@0 | 41 | * In that example, the child div's "inherit" should get the _computed_ value |
michael@0 | 42 | * of "align-self" on the body. That, in turn, is "auto", so it should compute to |
michael@0 | 43 | * its parent's "align-items" value, which is "baseline". So we need to end up |
michael@0 | 44 | * with a computed "align-self" value of "baseline" on the child. |
michael@0 | 45 | * |
michael@0 | 46 | * (NOTE: if we instead allowed the child div to directly inherit the value "auto" |
michael@0 | 47 | * from its parent, then we'd get different & incorrect behavior. The div would |
michael@0 | 48 | * resolve that inherited "auto" value to its own parent's "align-items" value, |
michael@0 | 49 | * which is "center" -- not "baseline".) |
michael@0 | 50 | * |
michael@0 | 51 | * This mochitest tests that situation and a few other similar tricky situations. |
michael@0 | 52 | */ |
michael@0 | 53 | |
michael@0 | 54 | /* |
michael@0 | 55 | * Utility function for getting computed style of "align-self": |
michael@0 | 56 | */ |
michael@0 | 57 | function getComputedAlignSelf(elem) { |
michael@0 | 58 | return window.getComputedStyle(elem, "").alignSelf; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /* |
michael@0 | 62 | * Tests that are useful regardless of whether we have a parent node: |
michael@0 | 63 | */ |
michael@0 | 64 | function testGeneralNode(elem) { |
michael@0 | 65 | // Test initial computed style |
michael@0 | 66 | // (Initial value should be 'auto', which should compute to 'stretch') |
michael@0 | 67 | is(getComputedAlignSelf(elem), "stretch", |
michael@0 | 68 | "initial computed value of 'align-self' should be 'stretch', " + |
michael@0 | 69 | "if we haven't explicitly set any style on the parent"); |
michael@0 | 70 | |
michael@0 | 71 | // Test value after setting align-self explicitly to "auto" |
michael@0 | 72 | elem.style.alignSelf = "auto"; |
michael@0 | 73 | is(getComputedAlignSelf(elem), "stretch", |
michael@0 | 74 | "computed value of 'align-self: auto' should be 'stretch', " + |
michael@0 | 75 | "if we haven't explicitly set any style on the parent"); |
michael@0 | 76 | elem.style.alignSelf = ""; // clean up |
michael@0 | 77 | |
michael@0 | 78 | // Test value after setting align-self explicitly to "inherit" |
michael@0 | 79 | elem.style.alignSelf = "inherit"; |
michael@0 | 80 | is(getComputedAlignSelf(elem), "stretch", |
michael@0 | 81 | "computed value of 'align-self: inherit' should be 'stretch', " + |
michael@0 | 82 | "if we haven't explicitly set any style on the parent"); |
michael@0 | 83 | elem.style.alignSelf = ""; // clean up |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | /* |
michael@0 | 87 | * Tests that depend on us having a parent node: |
michael@0 | 88 | */ |
michael@0 | 89 | function testNodeThatHasParent(elem) { |
michael@0 | 90 | // Sanity-check that we actually do have a styleable parent: |
michael@0 | 91 | ok(elem.parentNode && elem.parentNode.style, |
michael@0 | 92 | "bug in test -- expecting caller to pass us a node with a parent"); |
michael@0 | 93 | |
michael@0 | 94 | // Test initial computed style when "align-items" has been set on our parent. |
michael@0 | 95 | // (elem's initial "align-self" value should be "auto", which should compute |
michael@0 | 96 | // to its parent's "align-items" value, which in this case is "center".) |
michael@0 | 97 | elem.parentNode.style.alignItems = "center"; |
michael@0 | 98 | is(getComputedAlignSelf(elem), "center", |
michael@0 | 99 | "initial computed value of 'align-self' should match parent's " + |
michael@0 | 100 | "specified 'align-items' value"); |
michael@0 | 101 | |
michael@0 | 102 | // ...and now test computed style after setting "align-self" explicitly to |
michael@0 | 103 | // "auto" (with parent "align-items" still at "center") |
michael@0 | 104 | elem.style.alignSelf = "auto"; |
michael@0 | 105 | is(getComputedAlignSelf(elem), "center", |
michael@0 | 106 | "computed value of 'align-self: auto' should match parent's " + |
michael@0 | 107 | "specified 'align-items' value"); |
michael@0 | 108 | |
michael@0 | 109 | elem.style.alignSelf = ""; // clean up |
michael@0 | 110 | elem.parentNode.style.alignItems = ""; // clean up |
michael@0 | 111 | |
michael@0 | 112 | // Finally: test computed style after setting "align-self" to "inherit" |
michael@0 | 113 | // and leaving parent at its initial value (which should be "auto", which |
michael@0 | 114 | // should compute to "stretch") |
michael@0 | 115 | elem.style.alignSelf = "inherit"; |
michael@0 | 116 | is(getComputedAlignSelf(elem), "stretch", |
michael@0 | 117 | "computed value of 'align-self: inherit' should take parent's " + |
michael@0 | 118 | "computed 'align-self' value (which should be 'stretch', " + |
michael@0 | 119 | "if we haven't explicitly set any other style"); |
michael@0 | 120 | elem.style.alignSelf = ""; // clean up |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | /* |
michael@0 | 124 | * Tests that depend on us having a grandparent node: |
michael@0 | 125 | */ |
michael@0 | 126 | function testNodeThatHasGrandparent(elem) { |
michael@0 | 127 | // Sanity-check that we actually do have a styleable grandparent: |
michael@0 | 128 | ok(elem.parentNode && elem.parentNode.parentNode && |
michael@0 | 129 | elem.parentNode.parentNode.style, |
michael@0 | 130 | "bug in test -- should be getting a node with a grandparent"); |
michael@0 | 131 | |
michael@0 | 132 | // Test computed "align-self" after we set "align-self" to "inherit" on our elem |
michael@0 | 133 | // and to "auto" on its parent, and "align-items" to "baseline" on its |
michael@0 | 134 | // grandparent. The parent's "auto" value should resolve to "baseline", and |
michael@0 | 135 | // that's what our elem should inherit. |
michael@0 | 136 | |
michael@0 | 137 | elem.style.alignSelf = "inherit"; |
michael@0 | 138 | elem.parentNode.style.alignSelf = "auto"; |
michael@0 | 139 | elem.parentNode.parentNode.style.alignItems = "baseline"; |
michael@0 | 140 | |
michael@0 | 141 | is(getComputedAlignSelf(elem), "baseline", |
michael@0 | 142 | "computed value of 'align-self:inherit' on node when parent has " + |
michael@0 | 143 | "'align-self:auto' and grandparent has 'align-items:baseline'") |
michael@0 | 144 | |
michael@0 | 145 | // clean up: |
michael@0 | 146 | elem.style.alignSelf = ""; |
michael@0 | 147 | elem.parentNode.style.alignSelf = ""; |
michael@0 | 148 | elem.parentNode.parentNode.style.alignItems = ""; |
michael@0 | 149 | |
michael@0 | 150 | // Test computed "align-self" after we set it to "auto" on our node, set |
michael@0 | 151 | // "align-items" to "inherit" on its parent, and "align-items" to "baseline" |
michael@0 | 152 | // on its grandparent. The parent's "inherit" should compute to "baseline", |
michael@0 | 153 | // and our elem's "auto" value should resolve to that. |
michael@0 | 154 | elem.style.alignSelf = "auto"; |
michael@0 | 155 | elem.parentNode.style.alignItems = "inherit"; |
michael@0 | 156 | elem.parentNode.parentNode.style.alignItems = "baseline"; |
michael@0 | 157 | is(getComputedAlignSelf(elem), "baseline", |
michael@0 | 158 | "computed value of 'align-self:auto on node when parent has " + |
michael@0 | 159 | "'align-items:inherit' and grandparent has 'align-items:baseline'") |
michael@0 | 160 | |
michael@0 | 161 | // clean up: |
michael@0 | 162 | elem.style.alignSelf = ""; |
michael@0 | 163 | elem.parentNode.style.alignItems = ""; |
michael@0 | 164 | elem.parentNode.parentNode.style.alignItems = ""; |
michael@0 | 165 | } |
michael@0 | 166 | |
michael@0 | 167 | /* |
michael@0 | 168 | * Main test function |
michael@0 | 169 | */ |
michael@0 | 170 | function main() { |
michael@0 | 171 | // Test the root node |
michael@0 | 172 | // ================== |
michael@0 | 173 | // (It's special because it has no parent style context.) |
michael@0 | 174 | |
michael@0 | 175 | var rootNode = document.documentElement; |
michael@0 | 176 | |
michael@0 | 177 | // Sanity-check that we actually have the root node, as far as CSS is concerned. |
michael@0 | 178 | // (Note: rootNode.parentNode is a HTMLDocument object -- not an element that |
michael@0 | 179 | // we inherit style from.) |
michael@0 | 180 | ok(!rootNode.parentNode.style, |
michael@0 | 181 | "expecting root node to have no node to inherit style from"); |
michael@0 | 182 | |
michael@0 | 183 | testGeneralNode(rootNode); |
michael@0 | 184 | |
michael@0 | 185 | // Test the body node |
michael@0 | 186 | // ================== |
michael@0 | 187 | // (It's special because it has no grandparent style context.) |
michael@0 | 188 | |
michael@0 | 189 | var body = document.getElementsByTagName("body")[0]; |
michael@0 | 190 | is(body.parentNode, document.documentElement, |
michael@0 | 191 | "expecting body element's parent to be the root node"); |
michael@0 | 192 | |
michael@0 | 193 | testGeneralNode(body); |
michael@0 | 194 | testNodeThatHasParent(body); |
michael@0 | 195 | |
michael@0 | 196 | // Test the <div id="display"> node |
michael@0 | 197 | // ================================ |
michael@0 | 198 | // (It has both a parent and a grandparent style context.) |
michael@0 | 199 | |
michael@0 | 200 | var displayNode = document.getElementById("display"); |
michael@0 | 201 | is(displayNode.parentNode.parentNode, document.documentElement, |
michael@0 | 202 | "expecting 'display' node's grandparent to be the root node"); |
michael@0 | 203 | |
michael@0 | 204 | testGeneralNode(displayNode); |
michael@0 | 205 | testNodeThatHasParent(displayNode); |
michael@0 | 206 | testNodeThatHasGrandparent(displayNode); |
michael@0 | 207 | } |
michael@0 | 208 | |
michael@0 | 209 | main(); |
michael@0 | 210 | |
michael@0 | 211 | </script> |
michael@0 | 212 | </pre> |
michael@0 | 213 | </body> |
michael@0 | 214 | </html> |