jbarnette-johnson 1.0.0.20090326122910 → 1.0.0.20090326154650
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +26 -19
- data/Rakefile +16 -215
- data/{cross-compile.txt → docs/cross-compile.txt} +0 -0
- data/ext/spidermonkey/extconf.rb +20 -15
- data/johnson.gemspec +7 -5
- data/lib/tasks/gem.rake +9 -0
- data/lib/tasks/parsing.rake +37 -0
- data/lib/tasks/testing.rake +36 -0
- data/lib/tasks/vendor.rake +20 -0
- data/test/helper.rb +0 -3
- data/test/johnson/prelude_test.rb +7 -7
- metadata +22 -29
- data/MANIFEST.txt +0 -389
- data/js/johnson/browser/env.js +0 -705
- data/js/johnson/browser/jquery.js +0 -3446
- data/js/johnson/browser/xmlsax.js +0 -1564
- data/js/johnson/browser/xmlw3cdom.js +0 -4189
- data/js/johnson/browser.js +0 -9
- data/js/johnson/template.js +0 -29
- data/srcs/xmlparser-0.6.8.tar +0 -0
- data/test/assets/index.html +0 -38
- data/test/assets/jquery_test.html +0 -186
- data/test/jquery_units/simple.js +0 -12
- data/test/jquery_units/test.js +0 -31
- data/test/jquery_units/test_helper.js +0 -197
- data/test/jquery_units/units/ajax.js +0 -795
- data/test/jquery_units/units/core.js +0 -1571
- data/test/jquery_units/units/event.js +0 -299
- data/test/jquery_units/units/fx.js +0 -427
- data/test/jquery_units/units/offset.js +0 -112
- data/test/jquery_units/units/selector.js +0 -224
- data/test/jspec/helper.js +0 -7
- data/test/jspec/jspec.js +0 -192
- data/test/jspec/simple_spec.js +0 -68
data/js/johnson/browser.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
Ruby.require('net/http');
|
2
|
-
Johnson.require("johnson/browser/xmlw3cdom");
|
3
|
-
Johnson.require("johnson/browser/xmlsax");
|
4
|
-
Johnson.require("johnson/browser/env");
|
5
|
-
|
6
|
-
DOMElement.prototype.toString = function() {
|
7
|
-
return "<" + this.tagName + (this.className !== "" ? " class='" + this.className + "'" : "") +
|
8
|
-
(this.id !== "" ? " id='" + this.id + "'" : "") + ">";
|
9
|
-
};
|
data/js/johnson/template.js
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
Johnson.templatize = function (template, begin, end) {
|
2
|
-
var begin = begin || "<%"
|
3
|
-
var end = end || "%>"
|
4
|
-
var rebegin = begin.replace(/([\]{}[\\])/g, '\\$1');
|
5
|
-
var reend = end.replace(/([\]{}[\\])/g, '\\$1');
|
6
|
-
|
7
|
-
var code = "_context = _context || {}; with (_context) {" +
|
8
|
-
"var _result = '';" +
|
9
|
-
template
|
10
|
-
.replace(/[\t\r\n]/g, ' ')
|
11
|
-
.replace(/^(.*)$/, end + '$1' + begin)
|
12
|
-
.replace(new RegExp(reend + "(.*?)" + rebegin, "g"), function (text) {
|
13
|
-
return text
|
14
|
-
.replace(new RegExp("^" + reend + "(.*)" + rebegin + "$"), "$1")
|
15
|
-
.replace(/\\/g, "\\\\")
|
16
|
-
.replace(/'/g, "\\'")
|
17
|
-
.replace(/^(.*)$/,
|
18
|
-
function(sub, m) {
|
19
|
-
return end + (m == "" ? "" : "_result += '" + m + "';") + begin;
|
20
|
-
});
|
21
|
-
})
|
22
|
-
.replace(new RegExp(rebegin + "=(.*?)" + reend, "g"), "_result += ($1);")
|
23
|
-
.replace(new RegExp(rebegin + "(.*?)" + reend, "g"), ' $1 ')
|
24
|
-
.replace(new RegExp("^" + reend + "(.*)" + rebegin + "$"), '$1') +
|
25
|
-
"return _result;" +
|
26
|
-
"}";
|
27
|
-
|
28
|
-
return new Function("_context", code);
|
29
|
-
};
|
data/srcs/xmlparser-0.6.8.tar
DELETED
Binary file
|
data/test/assets/index.html
DELETED
@@ -1,38 +0,0 @@
|
|
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">
|
4
|
-
<head>
|
5
|
-
<title>Test Page for Apache Installation</title>
|
6
|
-
</head>
|
7
|
-
<!-- Background white, links blue (unvisited), navy (visited), red
|
8
|
-
(active) -->
|
9
|
-
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
|
10
|
-
vlink="#000080" alink="#FF0000">
|
11
|
-
<p>If you can see this, it means that the installation of the <a
|
12
|
-
href="http://www.apache.org/foundation/preFAQ.html">Apache web
|
13
|
-
server</a> software on this system was successful. You may now add
|
14
|
-
content to this directory and replace this page.</p>
|
15
|
-
|
16
|
-
<hr width="50%" size="8" id='test' />
|
17
|
-
<h2 align="center">Seeing this instead of the website you
|
18
|
-
expected?</h2>
|
19
|
-
|
20
|
-
<p>This page is here because the site administrator has changed the
|
21
|
-
configuration of this web server. Please <strong>contact the person
|
22
|
-
responsible for maintaining this server with questions.</strong>
|
23
|
-
The Apache Software Foundation, which wrote the web server software
|
24
|
-
this site administrator is using, has nothing to do with
|
25
|
-
maintaining this site and cannot help resolve configuration
|
26
|
-
issues.</p>
|
27
|
-
|
28
|
-
<hr width="50%" size="8" />
|
29
|
-
<p>The Apache <a href="manual/">documentation</a> has been included
|
30
|
-
with this distribution.</p>
|
31
|
-
|
32
|
-
<p>You are free to use the image below on an Apache-powered web
|
33
|
-
server. Thanks for using Apache!</p>
|
34
|
-
|
35
|
-
<div align="center"><img src="apache_pb.gif" alt="" /></div>
|
36
|
-
</body>
|
37
|
-
</html>
|
38
|
-
|
@@ -1,186 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
-
<title>jQuery Test Suite</title>
|
6
|
-
<link rel="Stylesheet" media="screen" href="data/testsuite.css" />
|
7
|
-
<script>var jQuery = "jQuery", $ = "$"; // For testing .noConflict()</script>
|
8
|
-
<script type="text/javascript" src="../dist/jquery.js"></script>
|
9
|
-
<script type="text/javascript" src="data/testrunner.js"></script>
|
10
|
-
<script type="text/javascript" src="unit/core.js"></script>
|
11
|
-
<script type="text/javascript" src="unit/selector.js"></script>
|
12
|
-
<script type="text/javascript" src="unit/event.js"></script>
|
13
|
-
<script type="text/javascript" src="unit/ajax.js"></script>
|
14
|
-
<script type="text/javascript" src="unit/fx.js"></script>
|
15
|
-
</head>
|
16
|
-
|
17
|
-
<body id="body">
|
18
|
-
<h1 id="header">jQuery Test Suite</h1>
|
19
|
-
<h2 id="banner"/>
|
20
|
-
<h2 id="userAgent"/>
|
21
|
-
|
22
|
-
<!-- Test HTML -->
|
23
|
-
<div id="nothiddendiv" style="height:1px;background:white;">
|
24
|
-
<div id="nothiddendivchild"/>
|
25
|
-
</div>
|
26
|
-
<!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
|
27
|
-
<iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"/>
|
28
|
-
<dl id="dl" style="display:none;">
|
29
|
-
<div id="main" style="display: none;">
|
30
|
-
<p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
|
31
|
-
<p id="ap">
|
32
|
-
Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
|
33
|
-
<a id="groups" href="http://groups.google.com/">Google Groups</a>.
|
34
|
-
This link has <code><a href="http://smin" id="anchor1">class="blog"</a></code>:
|
35
|
-
<a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a>
|
36
|
-
|
37
|
-
</p>
|
38
|
-
<div id="foo">
|
39
|
-
<p id="sndp">Everything inside the red border is inside a div with <code>id="foo"</code>.</p>
|
40
|
-
<p lang="en" id="en">This is a normal link: <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p>
|
41
|
-
<p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
|
42
|
-
|
43
|
-
</div>
|
44
|
-
<p id="first">Try them out:</p>
|
45
|
-
<ul id="firstUL"></ul>
|
46
|
-
<ol id="empty"></ol>
|
47
|
-
<form id="form" action="formaction">
|
48
|
-
<input type="text" name="action" value="Test" id="text1" maxlength="30"/>
|
49
|
-
<input type="text" name="text2" value="Test" id="text2" disabled="disabled"/>
|
50
|
-
<input type="radio" name="radio1" id="radio1" value="on"/>
|
51
|
-
|
52
|
-
<input type="radio" name="radio2" id="radio2" checked="checked"/>
|
53
|
-
<input type="checkbox" name="check" id="check1" checked="checked"/>
|
54
|
-
<input type="checkbox" id="check2" value="on"/>
|
55
|
-
|
56
|
-
<input type="hidden" name="hidden" id="hidden1"/>
|
57
|
-
<input type="text" style="display:none;" name="foo[bar]" id="hidden2"/>
|
58
|
-
|
59
|
-
<input type="text" id="name" name="name" value="name" />
|
60
|
-
|
61
|
-
<button id="button" name="button">Button</button>
|
62
|
-
|
63
|
-
<textarea id="area1" maxlength="30">foobar</textarea>
|
64
|
-
|
65
|
-
<select name="select1" id="select1">
|
66
|
-
<option id="option1a" class="emptyopt" value="">Nothing</option>
|
67
|
-
<option id="option1b" value="1">1</option>
|
68
|
-
<option id="option1c" value="2">2</option>
|
69
|
-
<option id="option1d" value="3">3</option>
|
70
|
-
</select>
|
71
|
-
<select name="select2" id="select2">
|
72
|
-
<option id="option2a" class="emptyopt" value="">Nothing</option>
|
73
|
-
<option id="option2b" value="1">1</option>
|
74
|
-
<option id="option2c" value="2">2</option>
|
75
|
-
<option id="option2d" selected="selected" value="3">3</option>
|
76
|
-
</select>
|
77
|
-
<select name="select3" id="select3" multiple="multiple">
|
78
|
-
<option id="option3a" class="emptyopt" value="">Nothing</option>
|
79
|
-
<option id="option3b" selected="selected" value="1">1</option>
|
80
|
-
<option id="option3c" selected="selected" value="2">2</option>
|
81
|
-
<option id="option3d" value="3">3</option>
|
82
|
-
</select>
|
83
|
-
|
84
|
-
<object id="object1" codebase="stupid">
|
85
|
-
<param name="p1" value="x1" />
|
86
|
-
<param name="p2" value="x2" />
|
87
|
-
</object>
|
88
|
-
|
89
|
-
<span id="台北Táiběi"/>
|
90
|
-
<span id="台北" lang="中文"/>
|
91
|
-
<span id="utf8class1" class="台北Táiběi 台北"/>
|
92
|
-
<span id="utf8class2" class="台北"/>
|
93
|
-
<span id="foo:bar" class="foo:bar"/>
|
94
|
-
<span id="test.foo[5]bar" class="test.foo[5]bar"/>
|
95
|
-
|
96
|
-
<foo_bar id="foobar">test element</foo_bar>
|
97
|
-
</form>
|
98
|
-
<b id="floatTest">Float test.</b>
|
99
|
-
<iframe id="iframe" name="iframe"></iframe>
|
100
|
-
<form id="lengthtest">
|
101
|
-
<input type="text" id="length" name="test"/>
|
102
|
-
<input type="text" id="idTest" name="id"/>
|
103
|
-
</form>
|
104
|
-
<table id="table"></table>
|
105
|
-
|
106
|
-
<div id="fx-queue">
|
107
|
-
<div id="fadein" class='chain test'>fadeIn<div>fadeIn</div></div>
|
108
|
-
<div id="fadeout" class='chain test out'>fadeOut<div>fadeOut</div></div>
|
109
|
-
|
110
|
-
<div id="show" class='chain test'>show<div>show</div></div>
|
111
|
-
<div id="hide" class='chain test out'>hide<div>hide</div></div>
|
112
|
-
|
113
|
-
<div id="togglein" class='chain test'>togglein<div>togglein</div></div>
|
114
|
-
<div id="toggleout" class='chain test out'>toggleout<div>toggleout</div></div>
|
115
|
-
|
116
|
-
|
117
|
-
<div id="slideup" class='chain test'>slideUp<div>slideUp</div></div>
|
118
|
-
<div id="slidedown" class='chain test out'>slideDown<div>slideDown</div></div>
|
119
|
-
|
120
|
-
<div id="slidetogglein" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>
|
121
|
-
<div id="slidetoggleout" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>
|
122
|
-
</div>
|
123
|
-
|
124
|
-
<div id="fx-tests"></div>
|
125
|
-
|
126
|
-
<form id="testForm" action="#" method="get">
|
127
|
-
<textarea name="T3" rows="2" cols="15">?
|
128
|
-
Z</textarea>
|
129
|
-
<input type="hidden" name="H1" value="x" />
|
130
|
-
<input type="hidden" name="H2" />
|
131
|
-
<input name="PWD" type="password" value="" />
|
132
|
-
<input name="T1" type="text" />
|
133
|
-
<input name="T2" type="text" value="YES" readonly="readonly" />
|
134
|
-
<input type="checkbox" name="C1" value="1" />
|
135
|
-
<input type="checkbox" name="C2" />
|
136
|
-
<input type="radio" name="R1" value="1" />
|
137
|
-
<input type="radio" name="R1" value="2" />
|
138
|
-
<input type="text" name="My Name" value="me" />
|
139
|
-
<input type="reset" name="reset" value="NO" />
|
140
|
-
<select name="S1">
|
141
|
-
<option value="abc">ABC</option>
|
142
|
-
<option value="abc">ABC</option>
|
143
|
-
<option value="abc">ABC</option>
|
144
|
-
</select>
|
145
|
-
<select name="S2" multiple="multiple" size="3">
|
146
|
-
<option value="abc">ABC</option>
|
147
|
-
<option value="abc">ABC</option>
|
148
|
-
<option value="abc">ABC</option>
|
149
|
-
</select>
|
150
|
-
<select name="S3">
|
151
|
-
<option selected="selected">YES</option>
|
152
|
-
</select>
|
153
|
-
<select name="S4">
|
154
|
-
<option value="" selected="selected">NO</option>
|
155
|
-
</select>
|
156
|
-
<input type="submit" name="sub1" value="NO" />
|
157
|
-
<input type="submit" name="sub2" value="NO" />
|
158
|
-
<input type="image" name="sub3" value="NO" />
|
159
|
-
<button name="sub4" type="submit" value="NO">NO</button>
|
160
|
-
<input name="D1" type="text" value="NO" disabled="disabled" />
|
161
|
-
<input type="checkbox" checked="checked" disabled="disabled" name="D2" value="NO" />
|
162
|
-
<input type="radio" name="D3" value="NO" checked="checked" disabled="disabled" />
|
163
|
-
<select name="D4" disabled="disabled">
|
164
|
-
<option selected="selected" value="NO">NO</option>
|
165
|
-
</select>
|
166
|
-
</form>
|
167
|
-
<div id="moretests">
|
168
|
-
<form>
|
169
|
-
<div id="checkedtest" style="display:none;">
|
170
|
-
<input type="radio" name="checkedtestradios" checked="checked"/>
|
171
|
-
<input type="radio" name="checkedtestradios" value="on"/>
|
172
|
-
<input type="checkbox" name="checkedtestcheckboxes" checked="checked"/>
|
173
|
-
<input type="checkbox" name="checkedtestcheckboxes" />
|
174
|
-
</div>
|
175
|
-
</form>
|
176
|
-
<div id="nonnodes"><span>hi</span> there <!-- mon ami --></div>
|
177
|
-
<div id="t2037">
|
178
|
-
<div><div class="hidden">hidden</div></div>
|
179
|
-
</div>
|
180
|
-
</div>
|
181
|
-
</div>
|
182
|
-
</dl>
|
183
|
-
|
184
|
-
<ol id="tests"></ol>
|
185
|
-
</body>
|
186
|
-
</html>
|
data/test/jquery_units/simple.js
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Johnson.require("johnson/browser");
|
2
|
-
Johnson.require("johnson/browser/jquery")
|
3
|
-
|
4
|
-
var doc = new DOMDocument(Ruby.File.read("/Users/yehuda/Code/johnson/test/assets/jquery_test.html"));
|
5
|
-
window.document = doc;
|
6
|
-
|
7
|
-
// document.getElementById("sndp") == document.getElementById("sndp")
|
8
|
-
Ruby.p(document.getElementById("sndp") == document.getElementById("sndp"));
|
9
|
-
|
10
|
-
$("#header").appendTo("#nothiddendiv").attr("foo", "bar");
|
11
|
-
|
12
|
-
Ruby.p($("#nothiddendiv").html())
|
data/test/jquery_units/test.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
// Init
|
2
|
-
Johnson.require("johnson/browser");
|
3
|
-
Johnson.require("johnson/browser/jquery");
|
4
|
-
|
5
|
-
Johnson.waitForThreads = function() {
|
6
|
-
// FIXME: This sucks ass
|
7
|
-
Ruby.eval("(Thread.list - [Thread.main]).each {|t| t.join}");
|
8
|
-
};
|
9
|
-
|
10
|
-
window.location = "file://" + Ruby.File.expand_path(Ruby.Dir.pwd()) + "/test/assets/jquery_test.html";
|
11
|
-
Ruby.eval("(Thread.list - [Thread.main]).each {|t| t.join}");
|
12
|
-
|
13
|
-
document = Ruby.Taka.DOM.send("HTML",
|
14
|
-
Ruby.File.open(Ruby.File.expand_path(Ruby.Dir.pwd()) + "/test/assets/jquery_test.html")
|
15
|
-
);
|
16
|
-
|
17
|
-
// Load the test runner
|
18
|
-
Johnson.require("test/jquery_units/test_helper.js");
|
19
|
-
|
20
|
-
Johnson.require("test/jquery_units/units/core.js");
|
21
|
-
// // Load the tests
|
22
|
-
// load(
|
23
|
-
// "test/unit/core.js",
|
24
|
-
// "test/unit/selector.js",
|
25
|
-
// "test/unit/event.js"
|
26
|
-
// //"test/unit/fx.js",
|
27
|
-
// //"test/unit/ajax.js"
|
28
|
-
// );
|
29
|
-
|
30
|
-
// Display the results
|
31
|
-
results();
|
@@ -1,197 +0,0 @@
|
|
1
|
-
function test(name, fn){
|
2
|
-
expected = -1;
|
3
|
-
numTests = 0;
|
4
|
-
reset();
|
5
|
-
|
6
|
-
fn();
|
7
|
-
|
8
|
-
if ( expected != -1 && expected != numTests )
|
9
|
-
log( false, "Wrong number of tests run. " + numTests + " ran, expected " + expected );
|
10
|
-
}
|
11
|
-
|
12
|
-
var orig = document.getElementById('main').innerHTML;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Resets the test setup. Useful for tests that modify the DOM.
|
16
|
-
*/
|
17
|
-
function reset() {
|
18
|
-
document.getElementById('main').innerHTML = orig;
|
19
|
-
}
|
20
|
-
|
21
|
-
var currentModule = "";
|
22
|
-
|
23
|
-
// call on start of module test to prepend name to all tests
|
24
|
-
function module(moduleName) {
|
25
|
-
currentModule = moduleName;
|
26
|
-
}
|
27
|
-
|
28
|
-
var expected = -1;
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
|
32
|
-
*/
|
33
|
-
function expect(asserts) {
|
34
|
-
expected = asserts;
|
35
|
-
}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Asserts true.
|
39
|
-
* @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
|
40
|
-
*/
|
41
|
-
function ok(a, msg) {
|
42
|
-
log( !!a, msg );
|
43
|
-
}
|
44
|
-
|
45
|
-
/**
|
46
|
-
* Asserts that two arrays are the same
|
47
|
-
*/
|
48
|
-
function isSet(a, b, msg) {
|
49
|
-
var ret = true;
|
50
|
-
if ( a && b && a.length != undefined && a.length == b.length ) {
|
51
|
-
for ( var i = 0; i < a.length; i++ ) {
|
52
|
-
if ( a[i] != b[i] )
|
53
|
-
ret = false;
|
54
|
-
}
|
55
|
-
} else
|
56
|
-
ret = false;
|
57
|
-
if ( !ret )
|
58
|
-
log( ret, msg + " expected: " + serialArray(b) + " result: " + serialArray(a) );
|
59
|
-
else
|
60
|
-
log( ret, msg );
|
61
|
-
}
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Asserts that two objects are equivalent
|
65
|
-
*/
|
66
|
-
function isObj(a, b, msg) {
|
67
|
-
var ret = true;
|
68
|
-
|
69
|
-
if ( a && b ) {
|
70
|
-
for ( var i in a )
|
71
|
-
if ( a[i] != b[i] )
|
72
|
-
ret = false;
|
73
|
-
|
74
|
-
for ( i in b )
|
75
|
-
if ( a[i] != b[i] )
|
76
|
-
ret = false;
|
77
|
-
} else
|
78
|
-
ret = false;
|
79
|
-
|
80
|
-
log( ret, msg );
|
81
|
-
}
|
82
|
-
|
83
|
-
function serialArray( a ) {
|
84
|
-
var r = [];
|
85
|
-
|
86
|
-
if ( a && a.length )
|
87
|
-
for ( var i = 0; i < a.length; i++ ) {
|
88
|
-
var str = a[i] ? a[i].nodeName : "";
|
89
|
-
if ( str ) {
|
90
|
-
str = str.toLowerCase();
|
91
|
-
if ( a[i].id )
|
92
|
-
str += "#" + a[i].id;
|
93
|
-
} else
|
94
|
-
str = a[i];
|
95
|
-
r.push( str );
|
96
|
-
}
|
97
|
-
|
98
|
-
return "[ " + r.join(", ") + " ]"
|
99
|
-
}
|
100
|
-
|
101
|
-
/**
|
102
|
-
* Returns an array of elements with the given IDs, eg.
|
103
|
-
* @example q("main", "foo", "bar")
|
104
|
-
* @result [<div id="main">, <span id="foo">, <input id="bar">]
|
105
|
-
*/
|
106
|
-
function q() {
|
107
|
-
var r = [];
|
108
|
-
for ( var i = 0; i < arguments.length; i++ )
|
109
|
-
r.push( document.getElementById( arguments[i] ) );
|
110
|
-
return r;
|
111
|
-
}
|
112
|
-
|
113
|
-
/**
|
114
|
-
* Asserts that a select matches the given IDs
|
115
|
-
* @example t("Check for something", "//[a]", ["foo", "baar"]);
|
116
|
-
* @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
|
117
|
-
*/
|
118
|
-
function t(a,b,c) {
|
119
|
-
var f = jQuery(b);
|
120
|
-
var s = "";
|
121
|
-
for ( var i = 0; i < f.length; i++ )
|
122
|
-
s += (s && ",") + '"' + f[i].id + '"';
|
123
|
-
isSet(f, q.apply(q,c), a + " (" + b + ")");
|
124
|
-
}
|
125
|
-
|
126
|
-
/**
|
127
|
-
* Checks that the first two arguments are equal, with an optional message.
|
128
|
-
* Prints out both expected and actual values on failure.
|
129
|
-
*
|
130
|
-
* Prefered to ok( expected == actual, message )
|
131
|
-
*
|
132
|
-
* @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) );
|
133
|
-
*
|
134
|
-
* @param Object expected
|
135
|
-
* @param Object actual
|
136
|
-
* @param String message (optional)
|
137
|
-
*/
|
138
|
-
function equals(expected, actual, message) {
|
139
|
-
var result = expected == actual;
|
140
|
-
message = message || (result ? "okay" : "failed");
|
141
|
-
log( result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual );
|
142
|
-
}
|
143
|
-
|
144
|
-
var numTests = 0, total = 0, pass = 0, fail = 0;
|
145
|
-
|
146
|
-
function log(state, msg){
|
147
|
-
print( (state ? "PASS" : "FAIL") + " (" + (++total) + ") " +
|
148
|
-
(currentModule ? "[" + currentModule + "] " : "") + msg );
|
149
|
-
|
150
|
-
numTests++;
|
151
|
-
|
152
|
-
if ( state )
|
153
|
-
pass++;
|
154
|
-
else
|
155
|
-
fail++;
|
156
|
-
}
|
157
|
-
|
158
|
-
function results(){
|
159
|
-
print( pass + " Passed, " + fail + " Failed" );
|
160
|
-
}
|
161
|
-
|
162
|
-
function start(){}
|
163
|
-
function stop(){}
|
164
|
-
|
165
|
-
/**
|
166
|
-
* Trigger an event on an element.
|
167
|
-
*
|
168
|
-
* @example triggerEvent( document.body, "click" );
|
169
|
-
*
|
170
|
-
* @param DOMElement elem
|
171
|
-
* @param String type
|
172
|
-
*/
|
173
|
-
function triggerEvent( elem, type, event ) {
|
174
|
-
/*
|
175
|
-
if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
|
176
|
-
event = document.createEvent("MouseEvents");
|
177
|
-
event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
|
178
|
-
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
179
|
-
elem.dispatchEvent( event );
|
180
|
-
} else if ( jQuery.browser.msie ) {
|
181
|
-
elem.fireEvent("on"+type);
|
182
|
-
}
|
183
|
-
*/
|
184
|
-
}
|
185
|
-
|
186
|
-
/**
|
187
|
-
* Add random number to url to stop IE from caching
|
188
|
-
*
|
189
|
-
* @example url("data/test.html")
|
190
|
-
* @result "data/test.html?10538358428943"
|
191
|
-
*
|
192
|
-
* @example url("data/test.php?foo=bar")
|
193
|
-
* @result "data/test.php?foo=bar&10538358345554"
|
194
|
-
*/
|
195
|
-
function url(value) {
|
196
|
-
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
|
197
|
-
}
|