envjs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +113 -0
- data/bin/envjsrb +239 -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 +106 -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 +21549 -0
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +75 -0
- data/lib/envjs/net.rb +3 -0
- data/lib/envjs/options.rb +11 -0
- data/lib/envjs/runtime.rb +280 -0
- data/lib/envjs/tempfile.rb +24 -0
- data/lib/envjs.rb +23 -0
- data/test/call-load-test.js +15 -0
- data/test/debug.js +53 -0
- data/test/firebug/errorIcon.png +0 -0
- data/test/firebug/firebug.css +209 -0
- data/test/firebug/firebug.html +23 -0
- data/test/firebug/firebug.js +672 -0
- data/test/firebug/firebugx.js +10 -0
- data/test/firebug/infoIcon.png +0 -0
- data/test/firebug/warningIcon.png +0 -0
- data/test/fixtures/html/events.html +171 -0
- data/test/fixtures/html/iframe1.html +46 -0
- data/test/fixtures/html/iframe1a.html +46 -0
- data/test/fixtures/html/iframe2.html +45 -0
- data/test/fixtures/html/iframe3.html +28 -0
- data/test/fixtures/html/iframeN.html +57 -0
- data/test/fixtures/html/malformed.html +181 -0
- data/test/fixtures/html/scope.html +81 -0
- data/test/fixtures/html/trivial.html +19 -0
- data/test/fixtures/html/with_js.html +26 -0
- data/test/fixtures/images/icon-blue.png +0 -0
- data/test/fixtures/js/external_script.js +1 -0
- data/test/fixtures/js/script.js +1 -0
- data/test/fixtures/js/script_error.js +2 -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/malformed.html +181 -0
- data/test/html/scope.html +87 -0
- data/test/html/script.js +1 -0
- data/test/html/trivial.html +19 -0
- data/test/html/with_js.html +26 -0
- data/test/index.html +328 -0
- data/test/java-prototype.js +9 -0
- data/test/primary-tests.js +24 -0
- data/test/prototype-test.js +13 -0
- data/test/qunit/qunit/qunit.css +17 -0
- data/test/qunit/qunit/qunit.js +997 -0
- data/test/qunit.js +61 -0
- data/test/specs/dist/env.spec.js +1534 -0
- data/test/specs/envjs.spec.css +46 -0
- data/test/specs/parser/html.js +31 -0
- data/test/specs/parser/spec.html +40 -0
- data/test/specs/parser/xml.js +31 -0
- data/test/specs/qunit.bdd.js +210 -0
- data/test/specs/qunit.css +17 -0
- data/test/specs/qunit.js +997 -0
- data/test/specs/template/spec-0.js +31 -0
- data/test/specs/template/spec-1.js +31 -0
- data/test/specs/template/spec.html +40 -0
- data/test/specs/window/css.js +23 -0
- data/test/specs/window/dialog.js +25 -0
- data/test/specs/window/document.js +23 -0
- data/test/specs/window/event.js +25 -0
- data/test/specs/window/history.js +34 -0
- data/test/specs/window/location.js +34 -0
- data/test/specs/window/navigator.js +71 -0
- data/test/specs/window/screen.js +42 -0
- data/test/specs/window/spec.html +48 -0
- data/test/specs/window/timer.js +26 -0
- data/test/specs/window/window.js +53 -0
- data/test/specs/xhr/spec.html +47 -0
- data/test/specs/xhr/xhr.js +31 -0
- data/test/test.js +10 -0
- data/test/unit/dom.js +44 -0
- data/test/unit/elementmembers.js +60 -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/nu.validator.js +34 -0
- data/test/unit/onload.js +90 -0
- data/test/unit/parser.js +121 -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 +164 -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
|
+
});
|