1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/ajax/scriptaculous/test/unit/position_clone_test.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,312 @@ 1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 1.5 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1.6 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 1.7 +<head> 1.8 + <title>script.aculo.us Unit test file</title> 1.9 + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 1.10 + <script src="../../lib/prototype.js" type="text/javascript"></script> 1.11 + <script src="../../src/scriptaculous.js" type="text/javascript"></script> 1.12 + <script src="../../src/unittest.js" type="text/javascript"></script> 1.13 + <link rel="stylesheet" href="../test.css" type="text/css" /> 1.14 +</head> 1.15 +<body> 1.16 +<h1>script.aculo.us Unit test file</h1> 1.17 +<p> 1.18 + Tests for Postion.clone (to be moved to Prototype) 1.19 +</p> 1.20 + 1.21 +<!-- Log output --> 1.22 +<div id="testlog"> </div> 1.23 + 1.24 +<!-- Tests follow --> 1.25 +<script type="text/javascript" language="javascript" charset="utf-8"> 1.26 +// <![CDATA[ 1.27 + 1.28 + function prepareTarget(contained, position1, position2) { 1.29 + var target; 1.30 + if($('target_div')) Element.remove('target_div'); 1.31 + if($('container_div')) Element.remove('container_div'); 1.32 + if(contained) { 1.33 + target = Builder.node('div', 1.34 + {id: 'container_div', style: 'position:' + position1}, 1.35 + [Builder.node('div', {id: 'target_div', style: 'position: ' +position2})]); 1.36 + } else { 1.37 + target = Builder.node('div', 1.38 + {id: 'target_div', style: 'position:' + position1}, '456'); 1.39 + } 1.40 + document.body.appendChild(target); 1.41 + Position.clone($('source_div'),$('target_div')); 1.42 + } 1.43 + 1.44 + function prepareTargetHidden(contained, position1, position2) { 1.45 + var target; 1.46 + if($('target_div')) Element.remove('target_div'); 1.47 + if($('container_div')) Element.remove('container_div'); 1.48 + if(contained) { 1.49 + target = Builder.node('div', 1.50 + {id: 'container_div', style: 'position:' + position1}, 1.51 + [Builder.node('div', {id: 'target_div', style: 'display:none; position: ' +position2})]); 1.52 + } else { 1.53 + target = Builder.node('div', 1.54 + {id: 'target_div', style: 'display:none; position:' + position1}, '456'); 1.55 + } 1.56 + document.body.appendChild(target); 1.57 + Position.clone($('source_div'),$('target_div')); 1.58 + Element.show($('target_div')); 1.59 + } 1.60 + 1.61 + new Test.Unit.Runner({ 1.62 + 1.63 + teardown: function() { 1.64 + Element.remove($('source_div')); 1.65 + }, 1.66 + 1.67 + testPositionCloneFromAbsolute: function() { with(this) { 1.68 + var source = Builder.node('div', 1.69 + {id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123'); 1.70 + document.body.appendChild(source); 1.71 + var expected = Object.inspect([120, 20]); 1.72 + assertEqual(expected, Object.inspect(Position.page($('source_div')))); 1.73 + 1.74 + prepareTarget(false, 'absolute'); 1.75 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.76 + "Clone to absolute BODY child"); 1.77 + 1.78 + prepareTarget(false, 'fixed'); 1.79 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.80 + "Clone to fixed BODY child"); 1.81 + 1.82 + prepareTarget(true, 'absolute', 'absolute'); 1.83 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.84 + "Clone to absolute child of absolute BODY child"); 1.85 + 1.86 + prepareTarget(true, 'absolute', 'fixed'); 1.87 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.88 + "Clone to fixed child of absolute BODY child"); 1.89 + 1.90 + prepareTarget(true, 'relative', 'absolute'); 1.91 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.92 + "Clone to absolute child of relative BODY child"); 1.93 + 1.94 + prepareTarget(true, 'relative', 'fixed'); 1.95 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.96 + "Clone to fixed child of relative BODY child"); 1.97 + 1.98 + prepareTarget(true, 'static', 'absolute'); 1.99 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.100 + "Clone to absolute child of static BODY child"); 1.101 + 1.102 + prepareTarget(true, 'static', 'fixed'); 1.103 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.104 + "Clone to fixed child of static BODY child"); 1.105 + }}, 1.106 + 1.107 + testPositionCloneFromRelative: function() { with(this) { 1.108 + var source = Builder.node('div', 1.109 + {id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123'); 1.110 + document.body.appendChild(source); 1.111 + var expected = Object.inspect(Position.page($('source_div'))); 1.112 + assertEqual(expected, Object.inspect(Position.page($('source_div')))); 1.113 + 1.114 + prepareTarget(false, 'absolute'); 1.115 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.116 + "Clone to absolute BODY child"); 1.117 + 1.118 + prepareTarget(false, 'fixed'); 1.119 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.120 + "Clone to fixed BODY child"); 1.121 + 1.122 + prepareTarget(true, 'absolute', 'absolute'); 1.123 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.124 + "Clone to absolute child of absolute BODY child"); 1.125 + 1.126 + prepareTarget(true, 'absolute', 'fixed'); 1.127 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.128 + "Clone to fixed child of absolute BODY child"); 1.129 + 1.130 + prepareTarget(true, 'relative', 'absolute'); 1.131 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.132 + "Clone to absolute child of relative BODY child"); 1.133 + 1.134 + prepareTarget(true, 'relative', 'fixed'); 1.135 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.136 + "Clone to fixed child of relative BODY child"); 1.137 + 1.138 + prepareTarget(true, 'static', 'absolute'); 1.139 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.140 + "Clone to absolute child of static BODY child"); 1.141 + 1.142 + prepareTarget(true, 'static', 'fixed'); 1.143 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.144 + "Clone to fixed child of static BODY child"); 1.145 + }}, 1.146 + 1.147 + testPositionCloneFromStatic: function() { with(this) { 1.148 + var source = Builder.node('div', 1.149 + {id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123'); 1.150 + document.body.appendChild(source); 1.151 + var expected = Object.inspect(Position.page($('source_div'))); 1.152 + assertEqual(expected, Object.inspect(Position.page($('source_div')))); 1.153 + 1.154 + prepareTarget(false, 'absolute'); 1.155 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.156 + "Clone to absolute BODY child"); 1.157 + 1.158 + prepareTarget(false, 'fixed'); 1.159 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.160 + "Clone to fixed BODY child"); 1.161 + 1.162 + prepareTarget(true, 'absolute', 'absolute'); 1.163 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.164 + "Clone to absolute child of absolute BODY child"); 1.165 + 1.166 + prepareTarget(true, 'absolute', 'fixed'); 1.167 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.168 + "Clone to fixed child of absolute BODY child"); 1.169 + 1.170 + prepareTarget(true, 'relative', 'absolute'); 1.171 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.172 + "Clone to absolute child of relative BODY child"); 1.173 + 1.174 + prepareTarget(true, 'relative', 'fixed'); 1.175 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.176 + "Clone to fixed child of relative BODY child"); 1.177 + 1.178 + prepareTarget(true, 'static', 'absolute'); 1.179 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.180 + "Clone to absolute child of static BODY child"); 1.181 + 1.182 + prepareTarget(true, 'static', 'fixed'); 1.183 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.184 + "Clone to fixed child of static BODY child"); 1.185 + }}, 1.186 + 1.187 + testPositionCloneFromAbsoluteWithHiddenTarget: function() { with(this) { 1.188 + var source = Builder.node('div', 1.189 + {id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123'); 1.190 + document.body.appendChild(source); 1.191 + var expected = Object.inspect([120, 20]); 1.192 + assertEqual(expected, Object.inspect(Position.page($('source_div')))); 1.193 + 1.194 + prepareTargetHidden(false, 'absolute'); 1.195 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.196 + "Clone to absolute BODY child"); 1.197 + 1.198 + prepareTargetHidden(false, 'fixed'); 1.199 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.200 + "Clone to fixed BODY child"); 1.201 + 1.202 + prepareTargetHidden(true, 'absolute', 'absolute'); 1.203 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.204 + "Clone to absolute child of absolute BODY child"); 1.205 + 1.206 + prepareTargetHidden(true, 'absolute', 'fixed'); 1.207 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.208 + "Clone to fixed child of absolute BODY child"); 1.209 + 1.210 + prepareTargetHidden(true, 'relative', 'absolute'); 1.211 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.212 + "Clone to absolute child of relative BODY child"); 1.213 + 1.214 + prepareTargetHidden(true, 'relative', 'fixed'); 1.215 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.216 + "Clone to fixed child of relative BODY child"); 1.217 + 1.218 + prepareTargetHidden(true, 'static', 'absolute'); 1.219 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.220 + "Clone to absolute child of static BODY child"); 1.221 + 1.222 + prepareTargetHidden(true, 'static', 'fixed'); 1.223 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.224 + "Clone to fixed child of static BODY child"); 1.225 + }}, 1.226 + 1.227 + testPositionCloneFromRelativeWithHiddenTarget: function() { with(this) { 1.228 + var source = Builder.node('div', 1.229 + {id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123'); 1.230 + document.body.appendChild(source); 1.231 + var expected = Object.inspect(Position.page($('source_div'))); 1.232 + assertEqual(expected, Object.inspect(Position.page($('source_div')))); 1.233 + 1.234 + prepareTargetHidden(false, 'absolute'); 1.235 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.236 + "Clone to absolute BODY child"); 1.237 + 1.238 + prepareTargetHidden(false, 'fixed'); 1.239 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.240 + "Clone to fixed BODY child"); 1.241 + 1.242 + prepareTargetHidden(true, 'absolute', 'absolute'); 1.243 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.244 + "Clone to absolute child of absolute BODY child"); 1.245 + 1.246 + prepareTargetHidden(true, 'absolute', 'fixed'); 1.247 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.248 + "Clone to fixed child of absolute BODY child"); 1.249 + 1.250 + prepareTargetHidden(true, 'relative', 'absolute'); 1.251 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.252 + "Clone to absolute child of relative BODY child"); 1.253 + 1.254 + prepareTargetHidden(true, 'relative', 'fixed'); 1.255 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.256 + "Clone to fixed child of relative BODY child"); 1.257 + 1.258 + prepareTargetHidden(true, 'static', 'absolute'); 1.259 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.260 + "Clone to absolute child of static BODY child"); 1.261 + 1.262 + prepareTargetHidden(true, 'static', 'fixed'); 1.263 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.264 + "Clone to fixed child of static BODY child"); 1.265 + }}, 1.266 + 1.267 + testPositionCloneFromStaticWithHiddenTarget: function() { with(this) { 1.268 + var source = Builder.node('div', 1.269 + {id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123'); 1.270 + document.body.appendChild(source); 1.271 + var expected = Object.inspect(Position.page($('source_div'))); 1.272 + assertEqual(expected, Object.inspect(Position.page($('source_div')))); 1.273 + 1.274 + prepareTargetHidden(false, 'absolute'); 1.275 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.276 + "Clone to absolute BODY child"); 1.277 + 1.278 + prepareTargetHidden(false, 'fixed'); 1.279 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.280 + "Clone to fixed BODY child"); 1.281 + 1.282 + prepareTargetHidden(true, 'absolute', 'absolute'); 1.283 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.284 + "Clone to absolute child of absolute BODY child"); 1.285 + 1.286 + prepareTargetHidden(true, 'absolute', 'fixed'); 1.287 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.288 + "Clone to fixed child of absolute BODY child"); 1.289 + 1.290 + prepareTargetHidden(true, 'relative', 'absolute'); 1.291 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.292 + "Clone to absolute child of relative BODY child"); 1.293 + 1.294 + prepareTargetHidden(true, 'relative', 'fixed'); 1.295 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.296 + "Clone to fixed child of relative BODY child"); 1.297 + 1.298 + prepareTargetHidden(true, 'static', 'absolute'); 1.299 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.300 + "Clone to absolute child of static BODY child"); 1.301 + 1.302 + prepareTargetHidden(true, 'static', 'fixed'); 1.303 + assertEqual(expected, Object.inspect(Position.page($('target_div'))), 1.304 + "Clone to fixed child of static BODY child"); 1.305 + }} 1.306 + 1.307 + }); 1.308 + 1.309 +// ]]> 1.310 +</script> 1.311 + 1.312 +<!-- Test elements will be inserted after this --> 1.313 + 1.314 +</body> 1.315 +</html> 1.316 \ No newline at end of file