Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
michael@0 | 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
michael@0 | 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
michael@0 | 4 | <head> |
michael@0 | 5 | <title>script.aculo.us Unit test file</title> |
michael@0 | 6 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
michael@0 | 7 | <script src="../../lib/prototype.js" type="text/javascript"></script> |
michael@0 | 8 | <script src="../../src/scriptaculous.js" type="text/javascript"></script> |
michael@0 | 9 | <script src="../../src/unittest.js" type="text/javascript"></script> |
michael@0 | 10 | <link rel="stylesheet" href="../test.css" type="text/css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <h1>script.aculo.us Unit test file</h1> |
michael@0 | 14 | <p> |
michael@0 | 15 | Tests for Postion.clone (to be moved to Prototype) |
michael@0 | 16 | </p> |
michael@0 | 17 | |
michael@0 | 18 | <!-- Log output --> |
michael@0 | 19 | <div id="testlog"> </div> |
michael@0 | 20 | |
michael@0 | 21 | <!-- Tests follow --> |
michael@0 | 22 | <script type="text/javascript" language="javascript" charset="utf-8"> |
michael@0 | 23 | // <![CDATA[ |
michael@0 | 24 | |
michael@0 | 25 | function prepareTarget(contained, position1, position2) { |
michael@0 | 26 | var target; |
michael@0 | 27 | if($('target_div')) Element.remove('target_div'); |
michael@0 | 28 | if($('container_div')) Element.remove('container_div'); |
michael@0 | 29 | if(contained) { |
michael@0 | 30 | target = Builder.node('div', |
michael@0 | 31 | {id: 'container_div', style: 'position:' + position1}, |
michael@0 | 32 | [Builder.node('div', {id: 'target_div', style: 'position: ' +position2})]); |
michael@0 | 33 | } else { |
michael@0 | 34 | target = Builder.node('div', |
michael@0 | 35 | {id: 'target_div', style: 'position:' + position1}, '456'); |
michael@0 | 36 | } |
michael@0 | 37 | document.body.appendChild(target); |
michael@0 | 38 | Position.clone($('source_div'),$('target_div')); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function prepareTargetHidden(contained, position1, position2) { |
michael@0 | 42 | var target; |
michael@0 | 43 | if($('target_div')) Element.remove('target_div'); |
michael@0 | 44 | if($('container_div')) Element.remove('container_div'); |
michael@0 | 45 | if(contained) { |
michael@0 | 46 | target = Builder.node('div', |
michael@0 | 47 | {id: 'container_div', style: 'position:' + position1}, |
michael@0 | 48 | [Builder.node('div', {id: 'target_div', style: 'display:none; position: ' +position2})]); |
michael@0 | 49 | } else { |
michael@0 | 50 | target = Builder.node('div', |
michael@0 | 51 | {id: 'target_div', style: 'display:none; position:' + position1}, '456'); |
michael@0 | 52 | } |
michael@0 | 53 | document.body.appendChild(target); |
michael@0 | 54 | Position.clone($('source_div'),$('target_div')); |
michael@0 | 55 | Element.show($('target_div')); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | new Test.Unit.Runner({ |
michael@0 | 59 | |
michael@0 | 60 | teardown: function() { |
michael@0 | 61 | Element.remove($('source_div')); |
michael@0 | 62 | }, |
michael@0 | 63 | |
michael@0 | 64 | testPositionCloneFromAbsolute: function() { with(this) { |
michael@0 | 65 | var source = Builder.node('div', |
michael@0 | 66 | {id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123'); |
michael@0 | 67 | document.body.appendChild(source); |
michael@0 | 68 | var expected = Object.inspect([120, 20]); |
michael@0 | 69 | assertEqual(expected, Object.inspect(Position.page($('source_div')))); |
michael@0 | 70 | |
michael@0 | 71 | prepareTarget(false, 'absolute'); |
michael@0 | 72 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 73 | "Clone to absolute BODY child"); |
michael@0 | 74 | |
michael@0 | 75 | prepareTarget(false, 'fixed'); |
michael@0 | 76 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 77 | "Clone to fixed BODY child"); |
michael@0 | 78 | |
michael@0 | 79 | prepareTarget(true, 'absolute', 'absolute'); |
michael@0 | 80 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 81 | "Clone to absolute child of absolute BODY child"); |
michael@0 | 82 | |
michael@0 | 83 | prepareTarget(true, 'absolute', 'fixed'); |
michael@0 | 84 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 85 | "Clone to fixed child of absolute BODY child"); |
michael@0 | 86 | |
michael@0 | 87 | prepareTarget(true, 'relative', 'absolute'); |
michael@0 | 88 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 89 | "Clone to absolute child of relative BODY child"); |
michael@0 | 90 | |
michael@0 | 91 | prepareTarget(true, 'relative', 'fixed'); |
michael@0 | 92 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 93 | "Clone to fixed child of relative BODY child"); |
michael@0 | 94 | |
michael@0 | 95 | prepareTarget(true, 'static', 'absolute'); |
michael@0 | 96 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 97 | "Clone to absolute child of static BODY child"); |
michael@0 | 98 | |
michael@0 | 99 | prepareTarget(true, 'static', 'fixed'); |
michael@0 | 100 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 101 | "Clone to fixed child of static BODY child"); |
michael@0 | 102 | }}, |
michael@0 | 103 | |
michael@0 | 104 | testPositionCloneFromRelative: function() { with(this) { |
michael@0 | 105 | var source = Builder.node('div', |
michael@0 | 106 | {id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123'); |
michael@0 | 107 | document.body.appendChild(source); |
michael@0 | 108 | var expected = Object.inspect(Position.page($('source_div'))); |
michael@0 | 109 | assertEqual(expected, Object.inspect(Position.page($('source_div')))); |
michael@0 | 110 | |
michael@0 | 111 | prepareTarget(false, 'absolute'); |
michael@0 | 112 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 113 | "Clone to absolute BODY child"); |
michael@0 | 114 | |
michael@0 | 115 | prepareTarget(false, 'fixed'); |
michael@0 | 116 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 117 | "Clone to fixed BODY child"); |
michael@0 | 118 | |
michael@0 | 119 | prepareTarget(true, 'absolute', 'absolute'); |
michael@0 | 120 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 121 | "Clone to absolute child of absolute BODY child"); |
michael@0 | 122 | |
michael@0 | 123 | prepareTarget(true, 'absolute', 'fixed'); |
michael@0 | 124 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 125 | "Clone to fixed child of absolute BODY child"); |
michael@0 | 126 | |
michael@0 | 127 | prepareTarget(true, 'relative', 'absolute'); |
michael@0 | 128 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 129 | "Clone to absolute child of relative BODY child"); |
michael@0 | 130 | |
michael@0 | 131 | prepareTarget(true, 'relative', 'fixed'); |
michael@0 | 132 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 133 | "Clone to fixed child of relative BODY child"); |
michael@0 | 134 | |
michael@0 | 135 | prepareTarget(true, 'static', 'absolute'); |
michael@0 | 136 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 137 | "Clone to absolute child of static BODY child"); |
michael@0 | 138 | |
michael@0 | 139 | prepareTarget(true, 'static', 'fixed'); |
michael@0 | 140 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 141 | "Clone to fixed child of static BODY child"); |
michael@0 | 142 | }}, |
michael@0 | 143 | |
michael@0 | 144 | testPositionCloneFromStatic: function() { with(this) { |
michael@0 | 145 | var source = Builder.node('div', |
michael@0 | 146 | {id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123'); |
michael@0 | 147 | document.body.appendChild(source); |
michael@0 | 148 | var expected = Object.inspect(Position.page($('source_div'))); |
michael@0 | 149 | assertEqual(expected, Object.inspect(Position.page($('source_div')))); |
michael@0 | 150 | |
michael@0 | 151 | prepareTarget(false, 'absolute'); |
michael@0 | 152 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 153 | "Clone to absolute BODY child"); |
michael@0 | 154 | |
michael@0 | 155 | prepareTarget(false, 'fixed'); |
michael@0 | 156 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 157 | "Clone to fixed BODY child"); |
michael@0 | 158 | |
michael@0 | 159 | prepareTarget(true, 'absolute', 'absolute'); |
michael@0 | 160 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 161 | "Clone to absolute child of absolute BODY child"); |
michael@0 | 162 | |
michael@0 | 163 | prepareTarget(true, 'absolute', 'fixed'); |
michael@0 | 164 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 165 | "Clone to fixed child of absolute BODY child"); |
michael@0 | 166 | |
michael@0 | 167 | prepareTarget(true, 'relative', 'absolute'); |
michael@0 | 168 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 169 | "Clone to absolute child of relative BODY child"); |
michael@0 | 170 | |
michael@0 | 171 | prepareTarget(true, 'relative', 'fixed'); |
michael@0 | 172 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 173 | "Clone to fixed child of relative BODY child"); |
michael@0 | 174 | |
michael@0 | 175 | prepareTarget(true, 'static', 'absolute'); |
michael@0 | 176 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 177 | "Clone to absolute child of static BODY child"); |
michael@0 | 178 | |
michael@0 | 179 | prepareTarget(true, 'static', 'fixed'); |
michael@0 | 180 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 181 | "Clone to fixed child of static BODY child"); |
michael@0 | 182 | }}, |
michael@0 | 183 | |
michael@0 | 184 | testPositionCloneFromAbsoluteWithHiddenTarget: function() { with(this) { |
michael@0 | 185 | var source = Builder.node('div', |
michael@0 | 186 | {id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123'); |
michael@0 | 187 | document.body.appendChild(source); |
michael@0 | 188 | var expected = Object.inspect([120, 20]); |
michael@0 | 189 | assertEqual(expected, Object.inspect(Position.page($('source_div')))); |
michael@0 | 190 | |
michael@0 | 191 | prepareTargetHidden(false, 'absolute'); |
michael@0 | 192 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 193 | "Clone to absolute BODY child"); |
michael@0 | 194 | |
michael@0 | 195 | prepareTargetHidden(false, 'fixed'); |
michael@0 | 196 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 197 | "Clone to fixed BODY child"); |
michael@0 | 198 | |
michael@0 | 199 | prepareTargetHidden(true, 'absolute', 'absolute'); |
michael@0 | 200 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 201 | "Clone to absolute child of absolute BODY child"); |
michael@0 | 202 | |
michael@0 | 203 | prepareTargetHidden(true, 'absolute', 'fixed'); |
michael@0 | 204 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 205 | "Clone to fixed child of absolute BODY child"); |
michael@0 | 206 | |
michael@0 | 207 | prepareTargetHidden(true, 'relative', 'absolute'); |
michael@0 | 208 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 209 | "Clone to absolute child of relative BODY child"); |
michael@0 | 210 | |
michael@0 | 211 | prepareTargetHidden(true, 'relative', 'fixed'); |
michael@0 | 212 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 213 | "Clone to fixed child of relative BODY child"); |
michael@0 | 214 | |
michael@0 | 215 | prepareTargetHidden(true, 'static', 'absolute'); |
michael@0 | 216 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 217 | "Clone to absolute child of static BODY child"); |
michael@0 | 218 | |
michael@0 | 219 | prepareTargetHidden(true, 'static', 'fixed'); |
michael@0 | 220 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 221 | "Clone to fixed child of static BODY child"); |
michael@0 | 222 | }}, |
michael@0 | 223 | |
michael@0 | 224 | testPositionCloneFromRelativeWithHiddenTarget: function() { with(this) { |
michael@0 | 225 | var source = Builder.node('div', |
michael@0 | 226 | {id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123'); |
michael@0 | 227 | document.body.appendChild(source); |
michael@0 | 228 | var expected = Object.inspect(Position.page($('source_div'))); |
michael@0 | 229 | assertEqual(expected, Object.inspect(Position.page($('source_div')))); |
michael@0 | 230 | |
michael@0 | 231 | prepareTargetHidden(false, 'absolute'); |
michael@0 | 232 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 233 | "Clone to absolute BODY child"); |
michael@0 | 234 | |
michael@0 | 235 | prepareTargetHidden(false, 'fixed'); |
michael@0 | 236 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 237 | "Clone to fixed BODY child"); |
michael@0 | 238 | |
michael@0 | 239 | prepareTargetHidden(true, 'absolute', 'absolute'); |
michael@0 | 240 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 241 | "Clone to absolute child of absolute BODY child"); |
michael@0 | 242 | |
michael@0 | 243 | prepareTargetHidden(true, 'absolute', 'fixed'); |
michael@0 | 244 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 245 | "Clone to fixed child of absolute BODY child"); |
michael@0 | 246 | |
michael@0 | 247 | prepareTargetHidden(true, 'relative', 'absolute'); |
michael@0 | 248 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 249 | "Clone to absolute child of relative BODY child"); |
michael@0 | 250 | |
michael@0 | 251 | prepareTargetHidden(true, 'relative', 'fixed'); |
michael@0 | 252 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 253 | "Clone to fixed child of relative BODY child"); |
michael@0 | 254 | |
michael@0 | 255 | prepareTargetHidden(true, 'static', 'absolute'); |
michael@0 | 256 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 257 | "Clone to absolute child of static BODY child"); |
michael@0 | 258 | |
michael@0 | 259 | prepareTargetHidden(true, 'static', 'fixed'); |
michael@0 | 260 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 261 | "Clone to fixed child of static BODY child"); |
michael@0 | 262 | }}, |
michael@0 | 263 | |
michael@0 | 264 | testPositionCloneFromStaticWithHiddenTarget: function() { with(this) { |
michael@0 | 265 | var source = Builder.node('div', |
michael@0 | 266 | {id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123'); |
michael@0 | 267 | document.body.appendChild(source); |
michael@0 | 268 | var expected = Object.inspect(Position.page($('source_div'))); |
michael@0 | 269 | assertEqual(expected, Object.inspect(Position.page($('source_div')))); |
michael@0 | 270 | |
michael@0 | 271 | prepareTargetHidden(false, 'absolute'); |
michael@0 | 272 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 273 | "Clone to absolute BODY child"); |
michael@0 | 274 | |
michael@0 | 275 | prepareTargetHidden(false, 'fixed'); |
michael@0 | 276 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 277 | "Clone to fixed BODY child"); |
michael@0 | 278 | |
michael@0 | 279 | prepareTargetHidden(true, 'absolute', 'absolute'); |
michael@0 | 280 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 281 | "Clone to absolute child of absolute BODY child"); |
michael@0 | 282 | |
michael@0 | 283 | prepareTargetHidden(true, 'absolute', 'fixed'); |
michael@0 | 284 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 285 | "Clone to fixed child of absolute BODY child"); |
michael@0 | 286 | |
michael@0 | 287 | prepareTargetHidden(true, 'relative', 'absolute'); |
michael@0 | 288 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 289 | "Clone to absolute child of relative BODY child"); |
michael@0 | 290 | |
michael@0 | 291 | prepareTargetHidden(true, 'relative', 'fixed'); |
michael@0 | 292 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 293 | "Clone to fixed child of relative BODY child"); |
michael@0 | 294 | |
michael@0 | 295 | prepareTargetHidden(true, 'static', 'absolute'); |
michael@0 | 296 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 297 | "Clone to absolute child of static BODY child"); |
michael@0 | 298 | |
michael@0 | 299 | prepareTargetHidden(true, 'static', 'fixed'); |
michael@0 | 300 | assertEqual(expected, Object.inspect(Position.page($('target_div'))), |
michael@0 | 301 | "Clone to fixed child of static BODY child"); |
michael@0 | 302 | }} |
michael@0 | 303 | |
michael@0 | 304 | }); |
michael@0 | 305 | |
michael@0 | 306 | // ]]> |
michael@0 | 307 | </script> |
michael@0 | 308 | |
michael@0 | 309 | <!-- Test elements will be inserted after this --> |
michael@0 | 310 | |
michael@0 | 311 | </body> |
michael@0 | 312 | </html> |