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.
Files changed (101) hide show
  1. data/README +113 -0
  2. data/bin/envjsrb +239 -0
  3. data/bin/jquery-1.2.6-test.js +33 -0
  4. data/bin/jquery-1.3.1-test.js +33 -0
  5. data/bin/jquery-1.3.2-test.js +106 -0
  6. data/bin/prototype-1.6.0.3-test.js +82 -0
  7. data/bin/prototype_1.6.0.3_tmpl.txt +27 -0
  8. data/bin/test-jquery.sh +58 -0
  9. data/bin/test-prototype.sh +54 -0
  10. data/bin/tidy +0 -0
  11. data/lib/envjs/env.js +21549 -0
  12. data/lib/envjs/net/cgi.rb +94 -0
  13. data/lib/envjs/net/file.rb +75 -0
  14. data/lib/envjs/net.rb +3 -0
  15. data/lib/envjs/options.rb +11 -0
  16. data/lib/envjs/runtime.rb +280 -0
  17. data/lib/envjs/tempfile.rb +24 -0
  18. data/lib/envjs.rb +23 -0
  19. data/test/call-load-test.js +15 -0
  20. data/test/debug.js +53 -0
  21. data/test/firebug/errorIcon.png +0 -0
  22. data/test/firebug/firebug.css +209 -0
  23. data/test/firebug/firebug.html +23 -0
  24. data/test/firebug/firebug.js +672 -0
  25. data/test/firebug/firebugx.js +10 -0
  26. data/test/firebug/infoIcon.png +0 -0
  27. data/test/firebug/warningIcon.png +0 -0
  28. data/test/fixtures/html/events.html +171 -0
  29. data/test/fixtures/html/iframe1.html +46 -0
  30. data/test/fixtures/html/iframe1a.html +46 -0
  31. data/test/fixtures/html/iframe2.html +45 -0
  32. data/test/fixtures/html/iframe3.html +28 -0
  33. data/test/fixtures/html/iframeN.html +57 -0
  34. data/test/fixtures/html/malformed.html +181 -0
  35. data/test/fixtures/html/scope.html +81 -0
  36. data/test/fixtures/html/trivial.html +19 -0
  37. data/test/fixtures/html/with_js.html +26 -0
  38. data/test/fixtures/images/icon-blue.png +0 -0
  39. data/test/fixtures/js/external_script.js +1 -0
  40. data/test/fixtures/js/script.js +1 -0
  41. data/test/fixtures/js/script_error.js +2 -0
  42. data/test/html/events.html +171 -0
  43. data/test/html/iframe1.html +46 -0
  44. data/test/html/iframe1a.html +46 -0
  45. data/test/html/iframe2.html +45 -0
  46. data/test/html/iframe3.html +30 -0
  47. data/test/html/iframeN.html +57 -0
  48. data/test/html/malformed.html +181 -0
  49. data/test/html/scope.html +87 -0
  50. data/test/html/script.js +1 -0
  51. data/test/html/trivial.html +19 -0
  52. data/test/html/with_js.html +26 -0
  53. data/test/index.html +328 -0
  54. data/test/java-prototype.js +9 -0
  55. data/test/primary-tests.js +24 -0
  56. data/test/prototype-test.js +13 -0
  57. data/test/qunit/qunit/qunit.css +17 -0
  58. data/test/qunit/qunit/qunit.js +997 -0
  59. data/test/qunit.js +61 -0
  60. data/test/specs/dist/env.spec.js +1534 -0
  61. data/test/specs/envjs.spec.css +46 -0
  62. data/test/specs/parser/html.js +31 -0
  63. data/test/specs/parser/spec.html +40 -0
  64. data/test/specs/parser/xml.js +31 -0
  65. data/test/specs/qunit.bdd.js +210 -0
  66. data/test/specs/qunit.css +17 -0
  67. data/test/specs/qunit.js +997 -0
  68. data/test/specs/template/spec-0.js +31 -0
  69. data/test/specs/template/spec-1.js +31 -0
  70. data/test/specs/template/spec.html +40 -0
  71. data/test/specs/window/css.js +23 -0
  72. data/test/specs/window/dialog.js +25 -0
  73. data/test/specs/window/document.js +23 -0
  74. data/test/specs/window/event.js +25 -0
  75. data/test/specs/window/history.js +34 -0
  76. data/test/specs/window/location.js +34 -0
  77. data/test/specs/window/navigator.js +71 -0
  78. data/test/specs/window/screen.js +42 -0
  79. data/test/specs/window/spec.html +48 -0
  80. data/test/specs/window/timer.js +26 -0
  81. data/test/specs/window/window.js +53 -0
  82. data/test/specs/xhr/spec.html +47 -0
  83. data/test/specs/xhr/xhr.js +31 -0
  84. data/test/test.js +10 -0
  85. data/test/unit/dom.js +44 -0
  86. data/test/unit/elementmembers.js +60 -0
  87. data/test/unit/events.js +195 -0
  88. data/test/unit/fixtures/external_script.js +1 -0
  89. data/test/unit/iframe.js +234 -0
  90. data/test/unit/multi-window.js +212 -0
  91. data/test/unit/nu.validator.js +34 -0
  92. data/test/unit/onload.js +90 -0
  93. data/test/unit/parser.js +121 -0
  94. data/test/unit/prototypecompat.js +22 -0
  95. data/test/unit/proxy.js +6 -0
  96. data/test/unit/scope.js +209 -0
  97. data/test/unit/timer.js +115 -0
  98. data/test/unit/window.js +41 -0
  99. data/test/vendor/jQuery/README +2 -0
  100. data/test/vendor/prototype-1.6.0.3.js +4320 -0
  101. metadata +164 -0
@@ -0,0 +1,46 @@
1
+ html{
2
+ background-color:#333;
3
+ }
4
+ body.container{
5
+ margin-top:20px;
6
+ border:none;
7
+ background-color:#333;
8
+ }
9
+ body.container strong {
10
+ text-transform:none;
11
+ }
12
+ h2#qunit-banner {
13
+ -moz-border-radius:30px;
14
+ padding:10px 10px 50px 10px;
15
+ text-align:center;
16
+ }
17
+ h2#qunit-banner.pass {
18
+ background-color:#66BB66;
19
+ text-align:center;
20
+ }
21
+ h2#qunit-banner #envjs-icon{
22
+ margin:5px 5px 0 20px;
23
+ }
24
+ h2#qunit-userAgent {
25
+ -moz-border-radius:0px;
26
+ background-color:#111;
27
+ color:white;
28
+ text-align:center;
29
+ margin:-40px 0 0 0;
30
+ padding:10px;
31
+ }
32
+ #qunit-test-summary{
33
+ -moz-border-radius-bottomleft:30px;
34
+ -moz-border-radius-bottomright:30px;
35
+ background-color:#338;
36
+ color:#99FFFF;
37
+ }
38
+ #qunit-tests{
39
+ background-color:#fff;
40
+ margin:0 0 40px;
41
+ padding:15px 60px;
42
+ }
43
+ p#qunit-testresult {
44
+ text-align:center;
45
+ padding:0 0 20px;
46
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @author thatcher
3
+ */
4
+ (function(Q){
5
+
6
+ Q.describe('TEMPLATE Spec',{
7
+ before:function(){
8
+ //setup
9
+ },
10
+ after:function(){
11
+ //tear down
12
+ }
13
+
14
+ }).should('do something', function(){
15
+
16
+ expect(1);
17
+ ok(true, 'good job');
18
+
19
+ }).should('do something else', function(){
20
+
21
+ expect(1);
22
+ ok(true, 'good job');
23
+
24
+ }).pending('should do something new soon', function(){
25
+
26
+ expect(1);
27
+ ok(false, 'todo');
28
+ });
29
+
30
+ })(QUnit);
31
+
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Envjs HTML5 Parser Spec</title>
6
+ <link rel="stylesheet" media="screen" href="../qunit.css"/>
7
+ <link rel="stylesheet" media="screen" href="../envjs.spec.css"/>
8
+ <link rel="stylesheet" media="screen" href="http://www.envjs.com/css/blueprint/screen.css"/>
9
+ <link rel="stylesheet" media="screen" href="http://www.envjs.com/css/site.css"/>
10
+ <script type='text/javascript' src='../qunit.js'></script>
11
+ <script type='text/javascript' src='../qunit.bdd.js'></script>
12
+
13
+ <!-- specs for this general api 'module' -->
14
+ <script type='text/javascript' src='spec-0.js'></script>
15
+ <script type='text/javascript' src='spec-1.js'></script>
16
+ </head>
17
+ <body class='container'>
18
+ <h2 id="qunit-banner">
19
+ <img id="envjs-icon"
20
+ src="../../fixtures/images/icon-blue.png"
21
+ height='40'/>
22
+ <span id="spec-title">Envjs HTML5 Parser Spec</span>
23
+ </h2>
24
+ <h2 id="qunit-userAgent"></h2>
25
+ <div id='qunit-testrunner-toolbar'></div>
26
+ <div id='qunit-test-summary'>
27
+ <ol id='qunit-tests'></ol>
28
+ </div>
29
+ <div id="qunit-main" style="display:none;">
30
+ <!--
31
+ Test HTML here:
32
+
33
+ not required to be in here but it makes it convenient
34
+ by convention to avoid having to look at the html
35
+ artifacts the test may require or have generated as
36
+ a side effect.
37
+ -->
38
+ </div>
39
+ </body>
40
+ </html>
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @author thatcher
3
+ */
4
+
5
+ (function(Q){
6
+
7
+ Q.describe('Another TEMPLATE Spec',{
8
+ before:function(){
9
+ //setup
10
+ },
11
+ after:function(){
12
+ //tear down
13
+ }
14
+
15
+ }).should('do something', function(){
16
+
17
+ expect(1);
18
+ ok(true, 'good job');
19
+
20
+ }).should('do something else', function(){
21
+
22
+ expect(1);
23
+ ok(true, 'good job');
24
+
25
+ }).pending('should do something new soon', function(){
26
+
27
+ expect(1);
28
+ ok(false, 'todo');
29
+ });
30
+
31
+ })(QUnit);
@@ -0,0 +1,210 @@
1
+
2
+ (function(Q){
3
+
4
+ Q.Spec = function(name){
5
+ this.before = false;
6
+ this.after = false;
7
+ this.assigns = {};
8
+ this.name = name;
9
+ Q.module(name);
10
+ };
11
+ Q.Spec.reminders = {};
12
+
13
+
14
+ // RSpec style describe
15
+ // takes an arbitrary number of arguments that are contactenated as strings
16
+ // the last argument is the configuration object
17
+ // which can have before: after: callbacks
18
+ function describe(){
19
+ var args = [].splice.call(arguments, 0);
20
+ // configuration function
21
+ var bddconfig = (args[args.length - 1].constructor == Object) ? args.pop() : {};
22
+ var spec = new Q.Spec(args.join(' '));
23
+ spec.before = bddconfig['before'] || bddconfig['setup'];
24
+ spec.after = bddconfig['after'] || bddconfig['teardown'];
25
+ return spec;
26
+ };
27
+
28
+
29
+
30
+
31
+ // RSpec style test definition
32
+ Q.Spec.prototype.it = function(name, callback ){
33
+ var spec = this;
34
+ if (spec.before)
35
+ spec.before.apply(spec.assigns);
36
+ Q.test(spec.name+" : "+name, function(){
37
+ callback.apply(spec);
38
+ });
39
+ if (spec.after)
40
+ spec.after.apply(spec.assigns);
41
+ return spec;
42
+ };
43
+
44
+ // Shoulda style test definition
45
+ Q.Spec.prototype.should = function(name, callback){
46
+ name = 'should ' + name;
47
+ return this.it.apply(this, [name, callback]);
48
+ };
49
+
50
+ Q.Spec.prototype.pending = function(name, callback, nowait){
51
+ name = '<span style="color: #EB8531;" class="pending">deferred: ' + name + '</span>';
52
+ Q.test(name, function(){
53
+ Q.ok(true,'behavior pending');
54
+ });
55
+ return this;
56
+ };
57
+
58
+ Q.Spec.prototype.should_eventually = function(name, callback, nowait){
59
+ return this.pending(name, callback);
60
+ };
61
+
62
+ Q.Spec.prototype.a = function(key){
63
+ if (typeof key == 'undefined') {
64
+ return this.assigns;
65
+ }
66
+ else {
67
+ return this.assigns[key];
68
+ }
69
+ };
70
+
71
+ // aliases for describe
72
+ Q.describe = describe;
73
+ Q.context = describe;
74
+
75
+ // asserts that the method is defined (like respond_to?)
76
+ Q.defined = function(object, method){
77
+ return Q.ok(typeof object[method] == 'function', method + 'is not defined on' + object);
78
+ };
79
+
80
+ // asserts that the object is of a certain type
81
+ Q.isType = function(object, type){
82
+ return Q.ok(object.constructor === type, object.toString() + ' is not of type ' + type + ', is ' + object.constructor);
83
+ };
84
+
85
+ // assert a string matches a regex
86
+ Q.match = function(matcher, string, message){
87
+ return Q.ok(string.match(matcher), message);
88
+ };
89
+
90
+ // assert that a matching error is raised
91
+ // expected can be a regex, a string, or an object
92
+ Q.raised = function(expected_error, callback){
93
+ var error = '';
94
+ try {
95
+ callback.apply(this);
96
+ }
97
+ catch (e) {
98
+ error = e;
99
+ }
100
+ message = "Expected error to match " + expected_error + " but was " + error.toString();
101
+ if (expected_error.constructor == RegExp) {
102
+ return Q.match(expected_error, error.toString(), message);
103
+ }
104
+ else
105
+ if (expected_error.constructor == String) {
106
+ return Q.equals(expected_error, error.toString(), message);
107
+ }
108
+ else {
109
+ return Q.equals(expected_error, error, message);
110
+ }
111
+ };
112
+
113
+
114
+ var log;
115
+ try{
116
+ if(Envjs)
117
+ log = Envjs.log;
118
+ }catch(e){
119
+ try{
120
+ log = console.log;
121
+ }catch(e){
122
+ log=function(){};
123
+ }
124
+
125
+ }
126
+ var assertion_index = 0;
127
+
128
+ var module_index = 0;
129
+ var module;
130
+
131
+ var test_index = 0;
132
+ var test;
133
+
134
+ Q._moduleStart = Q.moduleStart;
135
+ Q.moduleStart = function(m, te){
136
+ Q._moduleStart.apply(this, arguments);
137
+ module = m;
138
+ module_index++;
139
+ };
140
+
141
+ Q._moduleDone = Q.moduleDone;
142
+ Q.moduleDone = function(t, f, tx){
143
+ Q._moduleDone.apply(this, arguments);
144
+ var s = module_index + ". module " + t + ": ";
145
+ if (f) {
146
+ s += f + " failure(s) in " + tx + " tests";
147
+ }
148
+ else {
149
+ s += "all " + tx + " tests successful";
150
+ }
151
+ // print(s);
152
+ module = undefined;
153
+ };
154
+
155
+ Q._testStart = Q.testStart;
156
+ Q.testStart = function(t){
157
+ Q._testStart.apply(this, arguments);
158
+ test = t;
159
+ test_index++;
160
+ };
161
+
162
+ Q._testDone = Q.testDone;
163
+ Q.testDone = function(t){
164
+ Q._testDone.apply(this, arguments);
165
+ test = undefined;
166
+ }
167
+
168
+ Q._log = Q.log;
169
+ Q.log = function(r, m){
170
+ Q._log.apply(this, arguments);
171
+ assertion_index++;
172
+ var test_string = "";
173
+ if (module || test) {
174
+ var test_string = "[";
175
+ if (module) {
176
+ test_string += module;
177
+ if (test) {
178
+ test_string += ": ";
179
+ }
180
+ }
181
+ if (test) {
182
+ test_string += test;
183
+ }
184
+ test_string += "] ";
185
+ }
186
+ var s = (r ? "PASS (" : "FAIL (") + assertion_index + ") " + test_string + m;
187
+ log(s);
188
+ };
189
+
190
+ Q._done = Q.done;
191
+ Q.done = function(f, t){
192
+ Q._done.apply(this, arguments);
193
+ log((t - f) + " Passed, " + f + " Failed, " + t + " Total Tests");
194
+ try{
195
+ if(Envjs){
196
+ var scripts = document.getElementsByTagName('script');
197
+ for(var i = 0;i<scripts.length;i++){
198
+ //prevents scripts from being re-run when
199
+ //we look at the results in the browser
200
+ scripts[i].type='text/envjs';
201
+ }
202
+ Envjs.writeToFile(document.xml, Envjs.location('results.html'));
203
+ }
204
+ }catch(e){
205
+ log('failed to print results to file.\n'+e);
206
+ }
207
+ };
208
+
209
+ })(QUnit);
210
+
@@ -0,0 +1,17 @@
1
+ h1#qunit-header { padding: 15px; font-size: large; background-color: #06b; color: white; font-family: 'trebuchet ms', verdana, arial; margin: 0; }
2
+ h1#qunit-header a { color: white; }
3
+
4
+ h2#qunit-banner { height: 2em; border-bottom: 1px solid white; background-color: #eee; margin: 0; font-family: 'trebuchet ms', verdana, arial; }
5
+ h2#qunit-banner.pass { background-color: green; }
6
+ h2#qunit-banner.fail { background-color: red; }
7
+
8
+ h2#qunit-userAgent { padding: 10px; background-color: #eee; color: black; margin: 0; font-size: small; font-weight: normal; font-family: 'trebuchet ms', verdana, arial; font-size: 10pt; }
9
+
10
+ div#qunit-testrunner-toolbar { background: #eee; border-top: 1px solid black; padding: 10px; font-family: 'trebuchet ms', verdana, arial; margin: 0; font-size: 10pt; }
11
+
12
+ ol#qunit-tests { font-family: 'trebuchet ms', verdana, arial; font-size: 10pt; }
13
+ ol#qunit-tests li strong { cursor:pointer; }
14
+ ol#qunit-tests .pass { color: green; }
15
+ ol#qunit-tests .fail { color: red; }
16
+
17
+ p#qunit-testresult { margin-left: 1em; font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; }