headless-squirrel 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +55 -0
- data/Rakefile +27 -0
- data/bin/jstest +10 -0
- data/lib/headless_squirrel.rb +2 -0
- data/lib/headless_squirrel/console.rb +24 -0
- data/lib/headless_squirrel/runner.rb +70 -0
- data/lib/headless_squirrel/test.rb +17 -0
- data/lib/headless_squirrel/test_case.rb +158 -0
- data/test/fixtures/a_unit_test.html +27 -0
- data/test/fixtures/a_unit_test.js +22 -0
- data/test/fixtures/syntax_error.html +27 -0
- data/test/fixtures/syntax_error.js +5 -0
- data/test/fixtures/type_error.html +27 -0
- data/test/fixtures/type_error.js +1 -0
- data/test/regression/prototype/unit/ajax_test.html +29 -0
- data/test/regression/prototype/unit/array_test.html +28 -0
- data/test/regression/prototype/unit/assets/prototype.js +4900 -0
- data/test/regression/prototype/unit/assets/unittest.css +50 -0
- data/test/regression/prototype/unit/assets/unittest.js +615 -0
- data/test/regression/prototype/unit/assets/unittest_transport.js +1 -0
- data/test/regression/prototype/unit/base_test.html +27 -0
- data/test/regression/prototype/unit/class_test.html +27 -0
- data/test/regression/prototype/unit/date_test.html +27 -0
- data/test/regression/prototype/unit/dom_test.html +304 -0
- data/test/regression/prototype/unit/element_mixins_test.html +30 -0
- data/test/regression/prototype/unit/enumerable_test.html +35 -0
- data/test/regression/prototype/unit/event_test.html +31 -0
- data/test/regression/prototype/unit/fixtures/ajax.html +2 -0
- data/test/regression/prototype/unit/fixtures/ajax.js +42 -0
- data/test/regression/prototype/unit/fixtures/array.html +1 -0
- data/test/regression/prototype/unit/fixtures/class.js +83 -0
- data/test/regression/prototype/unit/fixtures/content.html +1 -0
- data/test/regression/prototype/unit/fixtures/data.json +1 -0
- data/test/regression/prototype/unit/fixtures/dom.css +84 -0
- data/test/regression/prototype/unit/fixtures/dom.html +278 -0
- data/test/regression/prototype/unit/fixtures/dom.js +17 -0
- data/test/regression/prototype/unit/fixtures/element_mixins.html +4 -0
- data/test/regression/prototype/unit/fixtures/element_mixins.js +2 -0
- data/test/regression/prototype/unit/fixtures/empty.html +0 -0
- data/test/regression/prototype/unit/fixtures/empty.js +1 -0
- data/test/regression/prototype/unit/fixtures/enumerable.html +8 -0
- data/test/regression/prototype/unit/fixtures/enumerable.js +23 -0
- data/test/regression/prototype/unit/fixtures/event.html +4 -0
- data/test/regression/prototype/unit/fixtures/form.html +108 -0
- data/test/regression/prototype/unit/fixtures/function.js +13 -0
- data/test/regression/prototype/unit/fixtures/hash.js +25 -0
- data/test/regression/prototype/unit/fixtures/hello.js +1 -0
- data/test/regression/prototype/unit/fixtures/logo.gif +0 -0
- data/test/regression/prototype/unit/fixtures/object.html +6 -0
- data/test/regression/prototype/unit/fixtures/object.js +7 -0
- data/test/regression/prototype/unit/fixtures/position.html +9 -0
- data/test/regression/prototype/unit/fixtures/selector.html +71 -0
- data/test/regression/prototype/unit/fixtures/string.js +8 -0
- data/test/regression/prototype/unit/fixtures/unittest.html +18 -0
- data/test/regression/prototype/unit/form_test.html +135 -0
- data/test/regression/prototype/unit/function_test.html +27 -0
- data/test/regression/prototype/unit/hash_test.html +27 -0
- data/test/regression/prototype/unit/number_test.html +27 -0
- data/test/regression/prototype/unit/object_test.html +32 -0
- data/test/regression/prototype/unit/periodical_executer_test.html +27 -0
- data/test/regression/prototype/unit/position_test.html +36 -0
- data/test/regression/prototype/unit/prototype_test.html +27 -0
- data/test/regression/prototype/unit/range_test.html +27 -0
- data/test/regression/prototype/unit/regexp_test.html +27 -0
- data/test/regression/prototype/unit/selector_test.html +98 -0
- data/test/regression/prototype/unit/string_test.html +27 -0
- data/test/regression/prototype/unit/tests/ajax_test.js +379 -0
- data/test/regression/prototype/unit/tests/array_test.js +186 -0
- data/test/regression/prototype/unit/tests/base_test.js +43 -0
- data/test/regression/prototype/unit/tests/class_test.js +136 -0
- data/test/regression/prototype/unit/tests/date_test.js +5 -0
- data/test/regression/prototype/unit/tests/dom_test.js +1493 -0
- data/test/regression/prototype/unit/tests/element_mixins_test.js +32 -0
- data/test/regression/prototype/unit/tests/enumerable_test.js +271 -0
- data/test/regression/prototype/unit/tests/event_test.js +235 -0
- data/test/regression/prototype/unit/tests/form_test.js +382 -0
- data/test/regression/prototype/unit/tests/function_test.js +133 -0
- data/test/regression/prototype/unit/tests/hash_test.js +178 -0
- data/test/regression/prototype/unit/tests/number_test.js +44 -0
- data/test/regression/prototype/unit/tests/object_test.js +180 -0
- data/test/regression/prototype/unit/tests/periodical_executer_test.js +15 -0
- data/test/regression/prototype/unit/tests/position_test.js +44 -0
- data/test/regression/prototype/unit/tests/prototype_test.js +43 -0
- data/test/regression/prototype/unit/tests/range_test.js +58 -0
- data/test/regression/prototype/unit/tests/regexp_test.js +42 -0
- data/test/regression/prototype/unit/tests/selector_test.js +408 -0
- data/test/regression/prototype/unit/tests/string_test.js +548 -0
- data/test/regression/prototype/unit/tests/unittest_test.js +148 -0
- data/test/regression/prototype/unit/unittest_test.html +45 -0
- data/test/regression/prototype/upstream +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_alt_text.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_collection.js +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result2.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_tagged.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_text.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_updater_result.html +20 -0
- data/test/regression/scriptaculous/unit/_autocomplete_result.html +11 -0
- data/test/regression/scriptaculous/unit/_autocomplete_result_nobr.html +1 -0
- data/test/regression/scriptaculous/unit/ajax_autocompleter_test.html +243 -0
- data/test/regression/scriptaculous/unit/ajax_inplaceeditor_test.html +895 -0
- data/test/regression/scriptaculous/unit/assets/builder.js +134 -0
- data/test/regression/scriptaculous/unit/assets/controls.js +963 -0
- data/test/regression/scriptaculous/unit/assets/dragdrop.js +973 -0
- data/test/regression/scriptaculous/unit/assets/effects.js +1122 -0
- data/test/regression/scriptaculous/unit/assets/javascripttest.rb +203 -0
- data/test/regression/scriptaculous/unit/assets/prototype.js +4320 -0
- data/test/regression/scriptaculous/unit/assets/scriptaculous.js +66 -0
- data/test/regression/scriptaculous/unit/assets/slider.js +273 -0
- data/test/regression/scriptaculous/unit/assets/sound.js +57 -0
- data/test/regression/scriptaculous/unit/assets/unittest.js +566 -0
- data/test/regression/scriptaculous/unit/bdd_test.html +150 -0
- data/test/regression/scriptaculous/unit/builder_test.html +262 -0
- data/test/regression/scriptaculous/unit/dragdrop_test.html +131 -0
- data/test/regression/scriptaculous/unit/effects_test.html +547 -0
- data/test/regression/scriptaculous/unit/element_test.html +116 -0
- data/test/regression/scriptaculous/unit/icon.png +0 -0
- data/test/regression/scriptaculous/unit/index.html +70 -0
- data/test/regression/scriptaculous/unit/loading_test.html +41 -0
- data/test/regression/scriptaculous/unit/position_clone_test.html +312 -0
- data/test/regression/scriptaculous/unit/slider_test.html +437 -0
- data/test/regression/scriptaculous/unit/sortable_test.html +205 -0
- data/test/regression/scriptaculous/unit/string_test.html +71 -0
- data/test/regression/scriptaculous/unit/unittest_test.html +154 -0
- data/test/regression/scriptaculous/upstream +1 -0
- data/test/test_helper.rb +20 -0
- data/test/unit/runner_test.rb +165 -0
- data/test/unit/test_case_test.rb +207 -0
- data/test/unit/test_test.rb +24 -0
- metadata +209 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
<style type="text/css" media="screen">
|
12
|
+
#style_test_1 { color:rgb(0, 0, 255); background-color: rgb(0, 0, 255); }
|
13
|
+
blah { color:rgb(0, 255, 0); }
|
14
|
+
#op2 { opacity:0.5;filter:alpha(opacity=50)progid:DXImageTransform.Microsoft.Blur(strength=10);}
|
15
|
+
#allStyles_1 {font-size: 12px;}
|
16
|
+
#allStyles_2 {opacity:0.5; filter:alpha(opacity=50);}
|
17
|
+
#allStyles_3 {opacity:0.5;}
|
18
|
+
</style>
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<h1>script.aculo.us Unit test file</h1>
|
22
|
+
<p>
|
23
|
+
Tests for Element extensions in effects.js
|
24
|
+
</p>
|
25
|
+
|
26
|
+
<!-- Log output -->
|
27
|
+
<div id="testlog"> </div>
|
28
|
+
|
29
|
+
<!-- Test elements follow -->
|
30
|
+
<div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div>
|
31
|
+
|
32
|
+
<div id="test_2" class="classA-foobar classB-foobar"> </div> <span> </span>
|
33
|
+
|
34
|
+
<div id="style_test_1" style="display:none;"></div>
|
35
|
+
<div id="style_test_2" class="blah" style="font-size:11px;"></div>
|
36
|
+
|
37
|
+
<div id="style_test_3">blah</div>
|
38
|
+
|
39
|
+
<div id="test_whitespace"> <span> </span>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
<div><div></div> </div><span> </span>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<!-- Test Element opacity functions -->
|
47
|
+
<img id="op1" alt="op2" src="icon.png" style="opacity:0.5;filter:alpha(opacity=50)" />
|
48
|
+
<img id="op2" alt="op2" src="icon.png"/>
|
49
|
+
<img id="op3" alt="op3" src="icon.png"/>
|
50
|
+
<img id="op4-ie" alt="op3" src="icon.png" style="filter:alpha(opacity=30)" />
|
51
|
+
|
52
|
+
<!-- Test Element.childrenWithClassName -->
|
53
|
+
<div id="Container" class="moo hoo">
|
54
|
+
<span id="1" class="firstClass">First class</span>
|
55
|
+
<span id="2" class="secondClass">Second class</span>
|
56
|
+
<span id="3" class="firstClass secondClass">First and Second class</span>
|
57
|
+
<span id="4" class="thirdClass">Third class <span id="5" class="firstClass">Nested First class</span></span>
|
58
|
+
|
59
|
+
<div id="collect">1<span class="ignore"><span class="someclass">2</span>3</span><ul><li class="ignore">4</li></ul></div>
|
60
|
+
|
61
|
+
</div>
|
62
|
+
|
63
|
+
<div id="perftest1"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div>
|
64
|
+
<div id="allStyles_1"></div>
|
65
|
+
<div id="allStyles_2"></div>
|
66
|
+
<div id="allStyles_3"></div>
|
67
|
+
<!-- Tests follow -->
|
68
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
69
|
+
// <![CDATA[
|
70
|
+
|
71
|
+
new Test.Unit.Runner({
|
72
|
+
|
73
|
+
testElementCollectTextNodes: function() { with(this) {
|
74
|
+
assertEqual('1234', Element.collectTextNodes('collect'));
|
75
|
+
assert(benchmark(function(){
|
76
|
+
Element.collectTextNodes('collect')
|
77
|
+
},50) < 1000);
|
78
|
+
|
79
|
+
benchmark(function(){
|
80
|
+
Element.collectTextNodes('collect')
|
81
|
+
},10,'Element.collectTextNodes');
|
82
|
+
|
83
|
+
assertEqual('1234', Element.collectTextNodesIgnoreClass('collect', 'somethingcompletelydifferent'));
|
84
|
+
assertEqual('1', $('collect').collectTextNodesIgnoreClass('ignore'));
|
85
|
+
benchmark(function(){
|
86
|
+
Element.collectTextNodesIgnoreClass('collect','ignore')
|
87
|
+
},10,'Element.collectTextNodesIgnoreClass');
|
88
|
+
|
89
|
+
assertEqual('134', Element.collectTextNodesIgnoreClass('collect', 'someclass'));
|
90
|
+
}},
|
91
|
+
|
92
|
+
testVisualEffect: function() { with(this) {
|
93
|
+
assert($('style_test_3') == $('style_test_3').visualEffect('fade'));
|
94
|
+
wait(1500,function(){
|
95
|
+
assert(!$('style_test_3').visible())
|
96
|
+
});
|
97
|
+
}},
|
98
|
+
|
99
|
+
testParseStylePerformance: function() { with(this) {
|
100
|
+
benchmark(function(){
|
101
|
+
"font:12px/15pt Verdana;opacity:0.4;border:4px dotted red".parseStyle();
|
102
|
+
},100);
|
103
|
+
}},
|
104
|
+
|
105
|
+
testGetStyles: function() { with(this) {
|
106
|
+
assertEqual('12px', $('allStyles_1').getStyles().fontSize);
|
107
|
+
assertEqual(1, parseFloat($('allStyles_1').getStyles().opacity));
|
108
|
+
assertEqual(0.5, parseFloat($('allStyles_2').getStyles().opacity));
|
109
|
+
assertEqual(0.5, parseFloat($('allStyles_3').getStyles().opacity));
|
110
|
+
}}
|
111
|
+
|
112
|
+
}, "testlog");
|
113
|
+
// ]]>
|
114
|
+
</script>
|
115
|
+
</body>
|
116
|
+
</html>
|
Binary file
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body class="navigation">
|
13
|
+
|
14
|
+
<h1>script.aculo.us<br/>Unit Tests</h1>
|
15
|
+
|
16
|
+
<p id="version"></p>
|
17
|
+
|
18
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
19
|
+
// <![CDATA[
|
20
|
+
$('version').innerHTML = 'script.aculo.us version '+Scriptaculous.Version+'<br/>Prototype version ' + Prototype.Version;
|
21
|
+
// ]]>
|
22
|
+
</script>
|
23
|
+
|
24
|
+
<p><a href="http://wiki.script.aculo.us/scriptaculous/show/UnitTesting" target="test">Documentation</a></p>
|
25
|
+
|
26
|
+
<h2>scriptaculous.js</h2>
|
27
|
+
<ul>
|
28
|
+
<li><a href="loading_test.html" target="test">Dynamic loading test</a></li>
|
29
|
+
</ul>
|
30
|
+
|
31
|
+
<h2>effects.js</h2>
|
32
|
+
<ul>
|
33
|
+
<li><a href="effects_test.html" target="test">Effects test</a></li>
|
34
|
+
<li><a href="string_test.html" target="test">String test</a></li>
|
35
|
+
<li><a href="element_test.html" target="test">Element extensions test</a></li>
|
36
|
+
<li><a href="position_clone_test.html" target="test">Position.clone test</a></li>
|
37
|
+
</ul>
|
38
|
+
|
39
|
+
<h2>dragdrop.js</h2>
|
40
|
+
<ul>
|
41
|
+
<li><a href="dragdrop_test.html" target="test">Drag & Drop test</a></li>
|
42
|
+
<li><a href="sortable_test.html" target="test">Sortable test</a></li>
|
43
|
+
</ul>
|
44
|
+
|
45
|
+
<h2>builder.js</h2>
|
46
|
+
<ul>
|
47
|
+
<li><a href="builder_test.html" target="test">Builder test</a></li>
|
48
|
+
</ul>
|
49
|
+
|
50
|
+
<h2>controls.js</h2>
|
51
|
+
<ul>
|
52
|
+
<li><a href="ajax_autocompleter_test.html" target="test">Ajax.Autocompleter test</a></li>
|
53
|
+
<li><a href="ajax_inplaceeditor_test.html" target="test">Ajax.InPlaceEditor test</a></li>
|
54
|
+
<li>Note: unit tests work on Firefox only. The controls themselves are fully supported on IE6+, Firefox and Safari.</li>
|
55
|
+
</ul>
|
56
|
+
|
57
|
+
<h2>slider.js</h2>
|
58
|
+
<ul>
|
59
|
+
<li><a href="slider_test.html" target="test">Control.Slider test</a></li>
|
60
|
+
</ul>
|
61
|
+
|
62
|
+
|
63
|
+
<h2>unittest.js</h2>
|
64
|
+
<ul>
|
65
|
+
<li><a href="unittest_test.html" target="test">Unittest test</a></li>
|
66
|
+
<li><a href="bdd_test.html" target="test">BDD test</a></li>
|
67
|
+
</ul>
|
68
|
+
|
69
|
+
</body>
|
70
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js?load=effects,dragdrop" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>script.aculo.us Unit test file</h1>
|
14
|
+
<p>
|
15
|
+
Test dynamic loading in scriptaculous.js
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<!-- Log output -->
|
19
|
+
<div id="testlog"> </div>
|
20
|
+
|
21
|
+
<!-- Tests follow -->
|
22
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
23
|
+
// <![CDATA[
|
24
|
+
|
25
|
+
new Test.Unit.Runner({
|
26
|
+
|
27
|
+
testDynamicLoading: function() { with(this) {
|
28
|
+
|
29
|
+
// not loaded: controls
|
30
|
+
assertNull(Ajax.Autocompleter || null);
|
31
|
+
assertNull(Form.Element.DelayedObserver || null);
|
32
|
+
|
33
|
+
// we loading dragdrop
|
34
|
+
assertNotNull(Draggable || null);
|
35
|
+
}}
|
36
|
+
|
37
|
+
}, "testlog");
|
38
|
+
// ]]>
|
39
|
+
</script>
|
40
|
+
</body>
|
41
|
+
</html>
|
@@ -0,0 +1,312 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>script.aculo.us Unit test file</h1>
|
14
|
+
<p>
|
15
|
+
Tests for Postion.clone (to be moved to Prototype)
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<!-- Log output -->
|
19
|
+
<div id="testlog"> </div>
|
20
|
+
|
21
|
+
<!-- Tests follow -->
|
22
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
23
|
+
// <![CDATA[
|
24
|
+
|
25
|
+
function prepareTarget(contained, position1, position2) {
|
26
|
+
var target;
|
27
|
+
if($('target_div')) Element.remove('target_div');
|
28
|
+
if($('container_div')) Element.remove('container_div');
|
29
|
+
if(contained) {
|
30
|
+
target = Builder.node('div',
|
31
|
+
{id: 'container_div', style: 'position:' + position1},
|
32
|
+
[Builder.node('div', {id: 'target_div', style: 'position: ' +position2})]);
|
33
|
+
} else {
|
34
|
+
target = Builder.node('div',
|
35
|
+
{id: 'target_div', style: 'position:' + position1}, '456');
|
36
|
+
}
|
37
|
+
document.body.appendChild(target);
|
38
|
+
Position.clone($('source_div'),$('target_div'));
|
39
|
+
}
|
40
|
+
|
41
|
+
function prepareTargetHidden(contained, position1, position2) {
|
42
|
+
var target;
|
43
|
+
if($('target_div')) Element.remove('target_div');
|
44
|
+
if($('container_div')) Element.remove('container_div');
|
45
|
+
if(contained) {
|
46
|
+
target = Builder.node('div',
|
47
|
+
{id: 'container_div', style: 'position:' + position1},
|
48
|
+
[Builder.node('div', {id: 'target_div', style: 'display:none; position: ' +position2})]);
|
49
|
+
} else {
|
50
|
+
target = Builder.node('div',
|
51
|
+
{id: 'target_div', style: 'display:none; position:' + position1}, '456');
|
52
|
+
}
|
53
|
+
document.body.appendChild(target);
|
54
|
+
Position.clone($('source_div'),$('target_div'));
|
55
|
+
Element.show($('target_div'));
|
56
|
+
}
|
57
|
+
|
58
|
+
new Test.Unit.Runner({
|
59
|
+
|
60
|
+
teardown: function() {
|
61
|
+
Element.remove($('source_div'));
|
62
|
+
},
|
63
|
+
|
64
|
+
testPositionCloneFromAbsolute: function() { with(this) {
|
65
|
+
var source = Builder.node('div',
|
66
|
+
{id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123');
|
67
|
+
document.body.appendChild(source);
|
68
|
+
var expected = Object.inspect([120, 20]);
|
69
|
+
assertEqual(expected, Object.inspect(Position.page($('source_div'))));
|
70
|
+
|
71
|
+
prepareTarget(false, 'absolute');
|
72
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
73
|
+
"Clone to absolute BODY child");
|
74
|
+
|
75
|
+
prepareTarget(false, 'fixed');
|
76
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
77
|
+
"Clone to fixed BODY child");
|
78
|
+
|
79
|
+
prepareTarget(true, 'absolute', 'absolute');
|
80
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
81
|
+
"Clone to absolute child of absolute BODY child");
|
82
|
+
|
83
|
+
prepareTarget(true, 'absolute', 'fixed');
|
84
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
85
|
+
"Clone to fixed child of absolute BODY child");
|
86
|
+
|
87
|
+
prepareTarget(true, 'relative', 'absolute');
|
88
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
89
|
+
"Clone to absolute child of relative BODY child");
|
90
|
+
|
91
|
+
prepareTarget(true, 'relative', 'fixed');
|
92
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
93
|
+
"Clone to fixed child of relative BODY child");
|
94
|
+
|
95
|
+
prepareTarget(true, 'static', 'absolute');
|
96
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
97
|
+
"Clone to absolute child of static BODY child");
|
98
|
+
|
99
|
+
prepareTarget(true, 'static', 'fixed');
|
100
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
101
|
+
"Clone to fixed child of static BODY child");
|
102
|
+
}},
|
103
|
+
|
104
|
+
testPositionCloneFromRelative: function() { with(this) {
|
105
|
+
var source = Builder.node('div',
|
106
|
+
{id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123');
|
107
|
+
document.body.appendChild(source);
|
108
|
+
var expected = Object.inspect(Position.page($('source_div')));
|
109
|
+
assertEqual(expected, Object.inspect(Position.page($('source_div'))));
|
110
|
+
|
111
|
+
prepareTarget(false, 'absolute');
|
112
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
113
|
+
"Clone to absolute BODY child");
|
114
|
+
|
115
|
+
prepareTarget(false, 'fixed');
|
116
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
117
|
+
"Clone to fixed BODY child");
|
118
|
+
|
119
|
+
prepareTarget(true, 'absolute', 'absolute');
|
120
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
121
|
+
"Clone to absolute child of absolute BODY child");
|
122
|
+
|
123
|
+
prepareTarget(true, 'absolute', 'fixed');
|
124
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
125
|
+
"Clone to fixed child of absolute BODY child");
|
126
|
+
|
127
|
+
prepareTarget(true, 'relative', 'absolute');
|
128
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
129
|
+
"Clone to absolute child of relative BODY child");
|
130
|
+
|
131
|
+
prepareTarget(true, 'relative', 'fixed');
|
132
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
133
|
+
"Clone to fixed child of relative BODY child");
|
134
|
+
|
135
|
+
prepareTarget(true, 'static', 'absolute');
|
136
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
137
|
+
"Clone to absolute child of static BODY child");
|
138
|
+
|
139
|
+
prepareTarget(true, 'static', 'fixed');
|
140
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
141
|
+
"Clone to fixed child of static BODY child");
|
142
|
+
}},
|
143
|
+
|
144
|
+
testPositionCloneFromStatic: function() { with(this) {
|
145
|
+
var source = Builder.node('div',
|
146
|
+
{id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123');
|
147
|
+
document.body.appendChild(source);
|
148
|
+
var expected = Object.inspect(Position.page($('source_div')));
|
149
|
+
assertEqual(expected, Object.inspect(Position.page($('source_div'))));
|
150
|
+
|
151
|
+
prepareTarget(false, 'absolute');
|
152
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
153
|
+
"Clone to absolute BODY child");
|
154
|
+
|
155
|
+
prepareTarget(false, 'fixed');
|
156
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
157
|
+
"Clone to fixed BODY child");
|
158
|
+
|
159
|
+
prepareTarget(true, 'absolute', 'absolute');
|
160
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
161
|
+
"Clone to absolute child of absolute BODY child");
|
162
|
+
|
163
|
+
prepareTarget(true, 'absolute', 'fixed');
|
164
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
165
|
+
"Clone to fixed child of absolute BODY child");
|
166
|
+
|
167
|
+
prepareTarget(true, 'relative', 'absolute');
|
168
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
169
|
+
"Clone to absolute child of relative BODY child");
|
170
|
+
|
171
|
+
prepareTarget(true, 'relative', 'fixed');
|
172
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
173
|
+
"Clone to fixed child of relative BODY child");
|
174
|
+
|
175
|
+
prepareTarget(true, 'static', 'absolute');
|
176
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
177
|
+
"Clone to absolute child of static BODY child");
|
178
|
+
|
179
|
+
prepareTarget(true, 'static', 'fixed');
|
180
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
181
|
+
"Clone to fixed child of static BODY child");
|
182
|
+
}},
|
183
|
+
|
184
|
+
testPositionCloneFromAbsoluteWithHiddenTarget: function() { with(this) {
|
185
|
+
var source = Builder.node('div',
|
186
|
+
{id: 'source_div', style: 'position:absolute; top:20px; left:120px; width:100px; height:50px;'}, '123');
|
187
|
+
document.body.appendChild(source);
|
188
|
+
var expected = Object.inspect([120, 20]);
|
189
|
+
assertEqual(expected, Object.inspect(Position.page($('source_div'))));
|
190
|
+
|
191
|
+
prepareTargetHidden(false, 'absolute');
|
192
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
193
|
+
"Clone to absolute BODY child");
|
194
|
+
|
195
|
+
prepareTargetHidden(false, 'fixed');
|
196
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
197
|
+
"Clone to fixed BODY child");
|
198
|
+
|
199
|
+
prepareTargetHidden(true, 'absolute', 'absolute');
|
200
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
201
|
+
"Clone to absolute child of absolute BODY child");
|
202
|
+
|
203
|
+
prepareTargetHidden(true, 'absolute', 'fixed');
|
204
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
205
|
+
"Clone to fixed child of absolute BODY child");
|
206
|
+
|
207
|
+
prepareTargetHidden(true, 'relative', 'absolute');
|
208
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
209
|
+
"Clone to absolute child of relative BODY child");
|
210
|
+
|
211
|
+
prepareTargetHidden(true, 'relative', 'fixed');
|
212
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
213
|
+
"Clone to fixed child of relative BODY child");
|
214
|
+
|
215
|
+
prepareTargetHidden(true, 'static', 'absolute');
|
216
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
217
|
+
"Clone to absolute child of static BODY child");
|
218
|
+
|
219
|
+
prepareTargetHidden(true, 'static', 'fixed');
|
220
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
221
|
+
"Clone to fixed child of static BODY child");
|
222
|
+
}},
|
223
|
+
|
224
|
+
testPositionCloneFromRelativeWithHiddenTarget: function() { with(this) {
|
225
|
+
var source = Builder.node('div',
|
226
|
+
{id: 'source_div', style: 'position:relative; top:20px; left:120px; width:100px; height:50px;'}, '123');
|
227
|
+
document.body.appendChild(source);
|
228
|
+
var expected = Object.inspect(Position.page($('source_div')));
|
229
|
+
assertEqual(expected, Object.inspect(Position.page($('source_div'))));
|
230
|
+
|
231
|
+
prepareTargetHidden(false, 'absolute');
|
232
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
233
|
+
"Clone to absolute BODY child");
|
234
|
+
|
235
|
+
prepareTargetHidden(false, 'fixed');
|
236
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
237
|
+
"Clone to fixed BODY child");
|
238
|
+
|
239
|
+
prepareTargetHidden(true, 'absolute', 'absolute');
|
240
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
241
|
+
"Clone to absolute child of absolute BODY child");
|
242
|
+
|
243
|
+
prepareTargetHidden(true, 'absolute', 'fixed');
|
244
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
245
|
+
"Clone to fixed child of absolute BODY child");
|
246
|
+
|
247
|
+
prepareTargetHidden(true, 'relative', 'absolute');
|
248
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
249
|
+
"Clone to absolute child of relative BODY child");
|
250
|
+
|
251
|
+
prepareTargetHidden(true, 'relative', 'fixed');
|
252
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
253
|
+
"Clone to fixed child of relative BODY child");
|
254
|
+
|
255
|
+
prepareTargetHidden(true, 'static', 'absolute');
|
256
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
257
|
+
"Clone to absolute child of static BODY child");
|
258
|
+
|
259
|
+
prepareTargetHidden(true, 'static', 'fixed');
|
260
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
261
|
+
"Clone to fixed child of static BODY child");
|
262
|
+
}},
|
263
|
+
|
264
|
+
testPositionCloneFromStaticWithHiddenTarget: function() { with(this) {
|
265
|
+
var source = Builder.node('div',
|
266
|
+
{id: 'source_div', style: 'top:20px; left:120px; width:100px; height:50px;'}, '123');
|
267
|
+
document.body.appendChild(source);
|
268
|
+
var expected = Object.inspect(Position.page($('source_div')));
|
269
|
+
assertEqual(expected, Object.inspect(Position.page($('source_div'))));
|
270
|
+
|
271
|
+
prepareTargetHidden(false, 'absolute');
|
272
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
273
|
+
"Clone to absolute BODY child");
|
274
|
+
|
275
|
+
prepareTargetHidden(false, 'fixed');
|
276
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
277
|
+
"Clone to fixed BODY child");
|
278
|
+
|
279
|
+
prepareTargetHidden(true, 'absolute', 'absolute');
|
280
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
281
|
+
"Clone to absolute child of absolute BODY child");
|
282
|
+
|
283
|
+
prepareTargetHidden(true, 'absolute', 'fixed');
|
284
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
285
|
+
"Clone to fixed child of absolute BODY child");
|
286
|
+
|
287
|
+
prepareTargetHidden(true, 'relative', 'absolute');
|
288
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
289
|
+
"Clone to absolute child of relative BODY child");
|
290
|
+
|
291
|
+
prepareTargetHidden(true, 'relative', 'fixed');
|
292
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
293
|
+
"Clone to fixed child of relative BODY child");
|
294
|
+
|
295
|
+
prepareTargetHidden(true, 'static', 'absolute');
|
296
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
297
|
+
"Clone to absolute child of static BODY child");
|
298
|
+
|
299
|
+
prepareTargetHidden(true, 'static', 'fixed');
|
300
|
+
assertEqual(expected, Object.inspect(Position.page($('target_div'))),
|
301
|
+
"Clone to fixed child of static BODY child");
|
302
|
+
}}
|
303
|
+
|
304
|
+
});
|
305
|
+
|
306
|
+
// ]]>
|
307
|
+
</script>
|
308
|
+
|
309
|
+
<!-- Test elements will be inserted after this -->
|
310
|
+
|
311
|
+
</body>
|
312
|
+
</html>
|