smparkes-envjs 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +101 -0
- data/bin/envjsrb +147 -0
- data/bin/jquery-1.2.6-test.js +33 -0
- data/bin/jquery-1.3.1-test.js +33 -0
- data/bin/jquery-1.3.2-test.js +98 -0
- data/bin/prototype-1.6.0.3-test.js +82 -0
- data/bin/prototype_1.6.0.3_tmpl.txt +27 -0
- data/bin/test-jquery.sh +58 -0
- data/bin/test-prototype.sh +54 -0
- data/bin/tidy +0 -0
- data/lib/envjs/env.js +10423 -0
- data/lib/envjs/net/file.rb +71 -0
- data/lib/envjs/net.rb +3 -0
- data/lib/envjs/runtime.rb +132 -0
- data/lib/envjs/runtime.rb.smp +133 -0
- data/lib/envjs/tempfile.rb +24 -0
- data/lib/envjs.rb +23 -0
- data/test/call-load-test.js +17 -0
- data/test/debug.js +53 -0
- data/test/envjs-call-load-test.js +3 -0
- data/test/envjs-prototype.js +3 -0
- data/test/html/events.html +171 -0
- data/test/html/iframe1.html +46 -0
- data/test/html/iframe1a.html +46 -0
- data/test/html/iframe2.html +45 -0
- data/test/html/iframe3.html +30 -0
- data/test/html/iframeN.html +57 -0
- data/test/html/scope.html +87 -0
- data/test/html/trivial.html +19 -0
- data/test/html/with_js.html +26 -0
- data/test/index.html +304 -0
- data/test/java-prototype.js +9 -0
- data/test/primaryTests.js +26 -0
- data/test/prototype.js +15 -0
- data/test/qunit/package.json +21 -0
- data/test/qunit/qunit/qunit.css +17 -0
- data/test/qunit/qunit/qunit.js +997 -0
- data/test/qunit/qunit/qunit.js.smp +1002 -0
- data/test/qunit/test/index.html +17 -0
- data/test/qunit/test/same.js +1368 -0
- data/test/qunit/test/test.js +136 -0
- data/test/qunit.js +61 -0
- data/test/qunit.smp/package.json +21 -0
- data/test/qunit.smp/qunit/qunit.css +17 -0
- data/test/qunit.smp/qunit/qunit.js +997 -0
- data/test/qunit.smp/test/index.html +17 -0
- data/test/qunit.smp/test/same.js +1368 -0
- data/test/qunit.smp/test/test.js +136 -0
- data/test/rhino-call-load-test.js +5 -0
- data/test/test-with-envs-jar.js +8 -0
- data/test/test-with-rhino-jar.js +9 -0
- data/test/unit/dom.js +43 -0
- data/test/unit/elementmembers.js +29 -0
- data/test/unit/events.js +195 -0
- data/test/unit/fixtures/external_script.js +1 -0
- data/test/unit/iframe.js +234 -0
- data/test/unit/multi-window.js +212 -0
- data/test/unit/onload.js +82 -0
- data/test/unit/parser.js +113 -0
- data/test/unit/prototypecompat.js +22 -0
- data/test/unit/proxy.js +6 -0
- data/test/unit/scope.js +209 -0
- data/test/unit/timer.js +115 -0
- data/test/unit/window.js +41 -0
- data/test/vendor/jQuery/README +2 -0
- data/test/vendor/prototype-1.6.0.3.js +4320 -0
- metadata +130 -0
data/test/unit/timer.js
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
module("timer");
|
2
|
+
|
3
|
+
test("runnable callbacks are run later with timeout of 0", function() {
|
4
|
+
expect(2);
|
5
|
+
var occurred = 0;
|
6
|
+
setTimeout(function(){
|
7
|
+
occurred = Date.now();
|
8
|
+
}, 0);
|
9
|
+
ok( occurred === 0, "Timeout callback was not executed immediatly" );
|
10
|
+
setTimeout(function(){
|
11
|
+
ok( occurred !== 0, "Timeout callback executed" );
|
12
|
+
start();
|
13
|
+
},100);
|
14
|
+
stop();
|
15
|
+
});
|
16
|
+
|
17
|
+
test("runnable callbacks are run later with timeout more than 0", function() {
|
18
|
+
expect(3);
|
19
|
+
var occurred = 0;
|
20
|
+
setTimeout(function(){
|
21
|
+
occurred = Date.now();
|
22
|
+
}, 1000);
|
23
|
+
ok( occurred === 0, "Timeout callback was not executed immediatly" );
|
24
|
+
var now = Date.now();
|
25
|
+
setTimeout(function(){
|
26
|
+
ok( occurred !== 0, "Timeout callback was executed" );
|
27
|
+
ok( Date.now()-now >= 1500, "Timeout callback was not executed too early" );
|
28
|
+
start();
|
29
|
+
},1500);
|
30
|
+
stop();
|
31
|
+
});
|
32
|
+
|
33
|
+
test("clearTimeout cancels execution of setTimeout callback", function() {
|
34
|
+
expect(2);
|
35
|
+
var occurred = 0;
|
36
|
+
var id = setTimeout(function(){
|
37
|
+
occurred = Date.now();
|
38
|
+
ok( false, "callback should not executed after clearTimeout" );
|
39
|
+
}, 1000);
|
40
|
+
ok( occurred === 0, "Timeout callback was not executed immediatly" );
|
41
|
+
clearTimeout(id);
|
42
|
+
setTimeout(function(){
|
43
|
+
ok( occurred === 0, "Timeout callback was not executed" );
|
44
|
+
start();
|
45
|
+
},3000);
|
46
|
+
stop();
|
47
|
+
});
|
48
|
+
|
49
|
+
test("setTimeout callbacks that throw run once", function() {
|
50
|
+
expect(2);
|
51
|
+
stop();
|
52
|
+
var called = 0;
|
53
|
+
var id = setTimeout(function(){
|
54
|
+
ok( called == 0, "timeout called once" );
|
55
|
+
called++;
|
56
|
+
throw "an expected error";
|
57
|
+
}, 10);
|
58
|
+
setTimeout(function(){
|
59
|
+
ok( called == 1, "called timeout once double checked" );
|
60
|
+
clearTimeout(id);
|
61
|
+
start();
|
62
|
+
},100);
|
63
|
+
});
|
64
|
+
|
65
|
+
test("setInterval callbacks that are delayed execute immediately", function() {
|
66
|
+
expect(3);
|
67
|
+
stop();
|
68
|
+
var iteration = 0;
|
69
|
+
var last = Date.now();
|
70
|
+
var id = setInterval(function(){
|
71
|
+
var now = Date.now();
|
72
|
+
var since_last = now - last;
|
73
|
+
switch(iteration) {
|
74
|
+
case 0:
|
75
|
+
ok( since_last > 60 && since_last < 140, "first interval was correct" );
|
76
|
+
while( (Date.now() - last ) < 400 ) {}
|
77
|
+
break;
|
78
|
+
case 1:
|
79
|
+
ok( since_last < 40, "second interval was correct" );
|
80
|
+
break;
|
81
|
+
default:
|
82
|
+
ok( since_last > 60 && since_last < 140, "third interval was correct" );
|
83
|
+
clearInterval(id);
|
84
|
+
start();
|
85
|
+
}
|
86
|
+
last = Date.now();
|
87
|
+
iteration++;
|
88
|
+
}, 100);
|
89
|
+
});
|
90
|
+
|
91
|
+
test("wait(n) waits at least n and then continues with nothing in the future", function() {
|
92
|
+
stop();
|
93
|
+
expect(1);
|
94
|
+
var now = Date.now();
|
95
|
+
Envjs.wait(1000);
|
96
|
+
ok( Date.now() - now > 1000, "wait waited long enough" );
|
97
|
+
start();
|
98
|
+
});
|
99
|
+
|
100
|
+
test("wait(n) waits at least n and then continues with stuff in the future", function() {
|
101
|
+
stop();
|
102
|
+
expect(2);
|
103
|
+
var now = Date.now();
|
104
|
+
var t = setTimeout(function(){
|
105
|
+
},2000);
|
106
|
+
Envjs.wait(1000);
|
107
|
+
ok( Date.now() - now > 1000, "wait waited long enough" );
|
108
|
+
ok( Date.now() - now < 2000, "wait didn't wait too long" );
|
109
|
+
start();
|
110
|
+
});
|
111
|
+
|
112
|
+
// Local Variables:
|
113
|
+
// espresso-indent-level:4
|
114
|
+
// c-basic-offset:4
|
115
|
+
// End:
|
data/test/unit/window.js
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module("window");
|
2
|
+
|
3
|
+
test("Window Global Scope Equivalence", function() {
|
4
|
+
expect(7);
|
5
|
+
|
6
|
+
window.foo = "abc";
|
7
|
+
ok( window.foo == foo, "Property created on the window is available in global scope." );
|
8
|
+
delete window.foo;
|
9
|
+
|
10
|
+
try{
|
11
|
+
$$$$$;
|
12
|
+
}catch(e){
|
13
|
+
ok( true, "Property is not in global scope." );
|
14
|
+
}
|
15
|
+
ok( window.$$$$$ === undefined, "Property is not in window scope." );
|
16
|
+
load("test/unit/fixtures/external_script.js");
|
17
|
+
ok( $$$$$ === "12345", "Property is in global scope." );
|
18
|
+
ok( window.$$$$$ === "12345", "Property is in window scope." );
|
19
|
+
|
20
|
+
try{ ok(window.Math === Math,
|
21
|
+
"'window' object provides common global object facilities");
|
22
|
+
}catch(e){print(e);}
|
23
|
+
try{ ok(Math.sqrt(4) == 2,
|
24
|
+
"'window' provides Math.* when referenced implicitly/global");
|
25
|
+
}catch(e){print(e);}
|
26
|
+
});
|
27
|
+
|
28
|
+
|
29
|
+
test("References to the window object", function() {
|
30
|
+
expect(3);
|
31
|
+
|
32
|
+
try{ ok(window == window.window,
|
33
|
+
"'window' is property of the window object");
|
34
|
+
}catch(e){print(e);}
|
35
|
+
try{ ok(window == self,
|
36
|
+
"'self' refers to the current window");
|
37
|
+
}catch(e){print(e);}
|
38
|
+
try{ ok(window == window.top,
|
39
|
+
"for top-level document 'window.top' refers to itself");
|
40
|
+
}catch(e){print(e);}
|
41
|
+
});
|