envjs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'net/protocol'
|
2
|
+
|
3
|
+
require 'envjs/net'
|
4
|
+
|
5
|
+
class Envjs::Net::CGI
|
6
|
+
|
7
|
+
def save_and_set k, v
|
8
|
+
@saved[k] = ENV[k]
|
9
|
+
ENV[k] = v
|
10
|
+
end
|
11
|
+
|
12
|
+
def restore
|
13
|
+
@saved.keys.each do |k|
|
14
|
+
ENV[k] = @saved[k]
|
15
|
+
end
|
16
|
+
@saved = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize xhr, data
|
20
|
+
if (match = %r((.*\.php)(\?(.*))?).match xhr.url).nil?
|
21
|
+
raise "Not CGI"
|
22
|
+
end
|
23
|
+
|
24
|
+
@saved = {}
|
25
|
+
|
26
|
+
begin
|
27
|
+
|
28
|
+
# p match[0]
|
29
|
+
|
30
|
+
path = match[1]
|
31
|
+
path.sub! %r(^file://), ""
|
32
|
+
|
33
|
+
save_and_set( "GATEWAY_INTERFACE", "CGI/1.1" )
|
34
|
+
|
35
|
+
save_and_set( "REQUEST_METHOD", xhr["method"] )
|
36
|
+
if ( match[3] )
|
37
|
+
save_and_set( "QUERY_STRING", match[3] )
|
38
|
+
end
|
39
|
+
|
40
|
+
if ct = xhr["headers"]["Content-Type"]
|
41
|
+
save_and_set( "CONTENT_TYPE", ct )
|
42
|
+
end
|
43
|
+
|
44
|
+
if data
|
45
|
+
save_and_set( "CONTENT_LENGTH", data.length.to_s )
|
46
|
+
end
|
47
|
+
|
48
|
+
xhr["headers"].each do |k,v|
|
49
|
+
k.gsub!("-","_")
|
50
|
+
k = "HTTP_" + k
|
51
|
+
save_and_set( k, v )
|
52
|
+
end
|
53
|
+
|
54
|
+
result = nil
|
55
|
+
|
56
|
+
save_and_set( "PATH_INFO", path )
|
57
|
+
save_and_set( "PATH_TRANSLATED", path )
|
58
|
+
save_and_set( "REDIRECT_STATUS", "200" )
|
59
|
+
|
60
|
+
open("|php-cgi", "r+") do |php|
|
61
|
+
if data
|
62
|
+
php.write data
|
63
|
+
php.flush
|
64
|
+
end
|
65
|
+
result = php.read
|
66
|
+
end
|
67
|
+
|
68
|
+
result && result = result.split("\r\n")
|
69
|
+
@headers = {}
|
70
|
+
while line = result.shift
|
71
|
+
break if line == ""
|
72
|
+
match = /([^:]*):\s*(.*)/.match line
|
73
|
+
@headers[match[1]]=match[2]
|
74
|
+
end
|
75
|
+
# p "q", result.join("\r\n")
|
76
|
+
@body = result.join("\r\n")
|
77
|
+
ensure
|
78
|
+
restore
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def each
|
84
|
+
@headers.each do |k,v|
|
85
|
+
yield k, v
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def finish
|
90
|
+
end
|
91
|
+
|
92
|
+
attr_reader :body
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'net/protocol'
|
2
|
+
|
3
|
+
require 'envjs/net'
|
4
|
+
|
5
|
+
class Envjs::Net::File < Net::Protocol
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :on_open
|
9
|
+
end
|
10
|
+
|
11
|
+
class Get
|
12
|
+
attr_accessor :path
|
13
|
+
def initialize path
|
14
|
+
@path = path
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize host, port
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.start host, port
|
22
|
+
new( host, port ).start
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def finish
|
30
|
+
end
|
31
|
+
|
32
|
+
def request request
|
33
|
+
Response.new request.path
|
34
|
+
end
|
35
|
+
|
36
|
+
class Response
|
37
|
+
def initialize path
|
38
|
+
@path = path
|
39
|
+
on_open = Envjs::Net::File.on_open
|
40
|
+
on_open and on_open.call( path )
|
41
|
+
@file = File.new @path
|
42
|
+
@body = @file.read
|
43
|
+
@code = @file.nil? ? "404" : "200";
|
44
|
+
@file.close
|
45
|
+
end
|
46
|
+
|
47
|
+
def [] *args
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def each &block
|
52
|
+
end
|
53
|
+
|
54
|
+
def getHeaderFields
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
|
58
|
+
def getContentEncoding
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def getResponseCode
|
63
|
+
@file.nil? ? 404 : 200;
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def getInputStream
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_reader :body, :code
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/lib/envjs/net.rb
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
require 'envjs'
|
2
|
+
require "open-uri"
|
3
|
+
require 'rubygems'
|
4
|
+
begin
|
5
|
+
require 'fsdb'
|
6
|
+
rescue LoadError; end
|
7
|
+
require 'envjs/net/file'
|
8
|
+
|
9
|
+
module Envjs::Runtime
|
10
|
+
|
11
|
+
def self.extended object
|
12
|
+
object.instance_eval do
|
13
|
+
|
14
|
+
evaluate <<'EOJS'
|
15
|
+
print = function() {
|
16
|
+
var l = arguments.length
|
17
|
+
for( var i = 0; i < l; i++ ) {
|
18
|
+
var s;
|
19
|
+
if ( arguments[i] === null ) {
|
20
|
+
s = "null";
|
21
|
+
} else if ( arguments[i] === undefined ) {
|
22
|
+
s = "undefined"
|
23
|
+
} else {
|
24
|
+
s = arguments[i].toString();
|
25
|
+
}
|
26
|
+
Ruby.print(s);
|
27
|
+
if( i < l-1 ) {
|
28
|
+
Ruby.print(" ");
|
29
|
+
}
|
30
|
+
}
|
31
|
+
Ruby.print("\n");
|
32
|
+
Ruby['$stdout'].flush();
|
33
|
+
};
|
34
|
+
EOJS
|
35
|
+
|
36
|
+
evaluate <<'EOJS'
|
37
|
+
debug = function() {
|
38
|
+
var l = arguments.length
|
39
|
+
for( var i = 0; i < l; i++ ) {
|
40
|
+
var s;
|
41
|
+
if ( arguments[i] === null ) {
|
42
|
+
s = "null";
|
43
|
+
} else if ( arguments[i] === undefined ) {
|
44
|
+
s = "undefined"
|
45
|
+
} else {
|
46
|
+
s = arguments[i].toString();
|
47
|
+
}
|
48
|
+
Ruby['$stderr'].print(s);
|
49
|
+
if( i < l-1 ) {
|
50
|
+
Ruby['$stderr'].print(" ");
|
51
|
+
}
|
52
|
+
}
|
53
|
+
Ruby['$stderr'].print("\n");
|
54
|
+
};
|
55
|
+
EOJS
|
56
|
+
|
57
|
+
evaluate <<'EOJS'
|
58
|
+
puts = function() {
|
59
|
+
var l = arguments.length
|
60
|
+
for( var i = 0; i < l; i++ ) {
|
61
|
+
var s;
|
62
|
+
if ( arguments[i] === null ) {
|
63
|
+
s = "null";
|
64
|
+
} else if ( arguments[i] === undefined ) {
|
65
|
+
s = "undefined"
|
66
|
+
} else {
|
67
|
+
s = arguments[i].toString();
|
68
|
+
}
|
69
|
+
Ruby.print(s);
|
70
|
+
Ruby.eval("$stdout.flush")
|
71
|
+
}
|
72
|
+
};
|
73
|
+
EOJS
|
74
|
+
|
75
|
+
master = global["$master"] = evaluate("new Object")
|
76
|
+
master.symbols = [ "Johnson", "Ruby", "print", "debug", "puts", "load", "reload", "whichInterpreter", "multiwindow" ]
|
77
|
+
master.symbols.each { |symbol| master[symbol] = global[symbol] }
|
78
|
+
|
79
|
+
master.whichInterpreter = "Johnson"
|
80
|
+
|
81
|
+
master.multiwindow = true
|
82
|
+
|
83
|
+
# calling this from JS is hosed; the ruby side is confused, maybe because HTTPHeaders is mixed in?
|
84
|
+
master.add_req_field = lambda { |r,k,v| r.add_field(k,v) }
|
85
|
+
|
86
|
+
db = lambda do
|
87
|
+
$envjsrb_deps && ( @db ||= FSDB::Database.new $envjsrb_deps )
|
88
|
+
end
|
89
|
+
|
90
|
+
top_level_js = nil
|
91
|
+
|
92
|
+
add_dep = nil
|
93
|
+
|
94
|
+
clear_deps = lambda do |w|
|
95
|
+
begin
|
96
|
+
if db.call
|
97
|
+
loc = w
|
98
|
+
begin loc = w.location; rescue; end
|
99
|
+
loc && ( loc = loc.to_s )
|
100
|
+
if ( loc !~ %r((http?s|file|about):) )
|
101
|
+
begin
|
102
|
+
loc = "file://" + Pathname(loc).realpath.to_s
|
103
|
+
rescue Errno::ENOENT; end
|
104
|
+
end
|
105
|
+
# $stderr.puts "clear", loc
|
106
|
+
if loc and loc != "about:blank"
|
107
|
+
paths = db.call[loc+".on.yml"] || []
|
108
|
+
paths.each do |path|
|
109
|
+
# $stderr.print "#{path} not by #{loc}\n";
|
110
|
+
db.call[path+".by.yml"].delete loc
|
111
|
+
end
|
112
|
+
# $stderr.print "#{loc} not on anything\n";
|
113
|
+
db.call.delete loc+".on.yml"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
add_dep.call( nil, loc )
|
117
|
+
rescue Exception => e; $stderr.puts e, e.class; $stderr.puts e.backtrace; end
|
118
|
+
end
|
119
|
+
|
120
|
+
if $envjsrb_deps
|
121
|
+
Envjs::Net::File.on_open = clear_deps
|
122
|
+
end
|
123
|
+
|
124
|
+
add_dep = lambda do |w, f|
|
125
|
+
if db.call
|
126
|
+
loc = nil
|
127
|
+
begin loc = w.location; rescue Exception; end
|
128
|
+
loc && ( loc = loc.to_s )
|
129
|
+
if ( loc && loc !~ %r((http?s|file|about):) )
|
130
|
+
loc = "file://" + Pathname(loc).realpath.to_s
|
131
|
+
end
|
132
|
+
path = f
|
133
|
+
if ( path !~ %r((http?s|file|about):) )
|
134
|
+
begin
|
135
|
+
path = "file://" + Pathname(path).realpath.to_s
|
136
|
+
rescue Errno::ENOENT
|
137
|
+
return
|
138
|
+
end
|
139
|
+
end
|
140
|
+
if !loc || loc == "about:blank"
|
141
|
+
tll = "file://" + Pathname(top_level_js).realpath.to_s
|
142
|
+
if ( tll != path )
|
143
|
+
loc = tll
|
144
|
+
end
|
145
|
+
end
|
146
|
+
if loc and loc != "about:blank"
|
147
|
+
on = db.call[loc+".on.yml"] || []
|
148
|
+
on << path
|
149
|
+
on.uniq!
|
150
|
+
db.call[loc+".on.yml"] = on
|
151
|
+
by = db.call[path+".by.yml"] || []
|
152
|
+
by << loc
|
153
|
+
by.uniq!
|
154
|
+
db.call[path+".by.yml"] = by
|
155
|
+
# $stderr.print "#{loc} on #{path}: #{db.call[loc+'.on.yml'].join(' ')}\n"
|
156
|
+
# $stderr.print "#{path} by #{loc}: #{db.call[path+'.by.yml'].join(' ')}\n"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
(class << self; self; end).send :define_method, :top_level_load do |path|
|
162
|
+
# $stderr.print "tll #{path}\n"
|
163
|
+
top_level_js = path
|
164
|
+
clear_deps.call( path )
|
165
|
+
end
|
166
|
+
|
167
|
+
master.load = lambda { |*files|
|
168
|
+
if files.length == 2 && !(String === files[1])
|
169
|
+
f = files[0]
|
170
|
+
w = files[1]
|
171
|
+
v = open(f).read.gsub(/\A#!.*$/, '')
|
172
|
+
loc = nil
|
173
|
+
add_dep.call w, f
|
174
|
+
evaluate(v, f, 1, w, w, f)
|
175
|
+
else
|
176
|
+
load *files
|
177
|
+
end
|
178
|
+
}
|
179
|
+
|
180
|
+
master.reload = lambda { |*files|
|
181
|
+
if files.length == 2 && !(String === files[1])
|
182
|
+
f = files[0]
|
183
|
+
w = files[1]
|
184
|
+
v = open(f).read.gsub(/\A#!.*$/, '')
|
185
|
+
loc = nil
|
186
|
+
add_dep.call w, f
|
187
|
+
reevaluate(v, f, 1, w, w, f)
|
188
|
+
else
|
189
|
+
reload *files
|
190
|
+
end
|
191
|
+
}
|
192
|
+
|
193
|
+
master.evaluate = lambda { |v,w|
|
194
|
+
evaluate(v,"inline",1,w,w);
|
195
|
+
}
|
196
|
+
|
197
|
+
master.new_split_global_outer = lambda { new_split_global_outer }
|
198
|
+
master.new_split_global_inner = lambda { |outer,_| new_split_global_inner outer }
|
199
|
+
|
200
|
+
# create an proto window object and proxy
|
201
|
+
|
202
|
+
outer = new_split_global_outer
|
203
|
+
window = inner = new_split_global_inner( outer )
|
204
|
+
|
205
|
+
master.symbols.each do |symbol|
|
206
|
+
window[symbol] = master[symbol]
|
207
|
+
end
|
208
|
+
|
209
|
+
master.first_script_window = window
|
210
|
+
|
211
|
+
window["$master"] = master
|
212
|
+
window["$options"] = evaluate("new Object");
|
213
|
+
window["$options"].proxy = outer
|
214
|
+
|
215
|
+
window.load = lambda { |*files|
|
216
|
+
files.each do |f|
|
217
|
+
master.load.call f, window
|
218
|
+
end
|
219
|
+
}
|
220
|
+
|
221
|
+
window.reload = lambda { |*files|
|
222
|
+
files.each do |f|
|
223
|
+
master.reload.call f, window
|
224
|
+
end
|
225
|
+
}
|
226
|
+
|
227
|
+
( class << self; self; end ).send :define_method, :wait do
|
228
|
+
master["finalize"] && master.finalize.call
|
229
|
+
master.timers && master.timers.wait
|
230
|
+
end
|
231
|
+
|
232
|
+
scripts = {}
|
233
|
+
|
234
|
+
( class << self; self; end ).send :define_method, :become_first_script_window do
|
235
|
+
# p "heh", inner, master.first_script_window
|
236
|
+
inner = master.first_script_window
|
237
|
+
end
|
238
|
+
|
239
|
+
( class << self; self; end ).send :define_method, :evaluate do |*args|
|
240
|
+
( script, file, line, global, scope, fn ) = *args
|
241
|
+
# print "eval in " + script[0,50].inspect + (scope ? scope.toString() : "nil") + "\n"
|
242
|
+
global = nil
|
243
|
+
scope ||= inner
|
244
|
+
if fn
|
245
|
+
compiled_script = scripts[fn]
|
246
|
+
end
|
247
|
+
# compiled_script = compile(script, file, line, global)
|
248
|
+
compiled_script ||= compile(script, file, line, global)
|
249
|
+
if fn && !scripts[fn]
|
250
|
+
scripts[fn] = compiled_script
|
251
|
+
end
|
252
|
+
evaluate_compiled_script(compiled_script,scope)
|
253
|
+
end
|
254
|
+
|
255
|
+
( class << self; self; end ).send :define_method, :reevaluate do |*args|
|
256
|
+
( script, file, line, global, scope, fn ) = *args
|
257
|
+
# print "eval in " + script[0,50].inspect + (scope ? scope.toString() : "nil") + "\n"
|
258
|
+
global = nil
|
259
|
+
scope ||= inner
|
260
|
+
compiled_script = compile(script, file, line, global)
|
261
|
+
if fn
|
262
|
+
scripts[fn] = compiled_script
|
263
|
+
end
|
264
|
+
evaluate_compiled_script(compiled_script,scope)
|
265
|
+
end
|
266
|
+
|
267
|
+
@envjs = inner
|
268
|
+
|
269
|
+
( class << self; self; end ).send :define_method, :"[]" do |key|
|
270
|
+
key == "this" && evaluate("this") || @envjs[key]
|
271
|
+
end
|
272
|
+
|
273
|
+
( class << self; self; end ).send :define_method, :"[]=" do |k,v|
|
274
|
+
@envjs[k] = v
|
275
|
+
end
|
276
|
+
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
require 'envjs'
|
4
|
+
|
5
|
+
class Envjs::TempFile < Tempfile
|
6
|
+
|
7
|
+
def initialize pattern, suffix = nil
|
8
|
+
super(pattern)
|
9
|
+
|
10
|
+
|
11
|
+
if suffix
|
12
|
+
new_path = path + "." + suffix
|
13
|
+
File.link path, new_path
|
14
|
+
File.unlink path
|
15
|
+
# blah ... implementation specific ...
|
16
|
+
@data[0] = @tmpname = new_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def getAbsolutePath
|
21
|
+
path
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/envjs.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Envjs
|
2
|
+
|
3
|
+
def self.js_exception_stack e
|
4
|
+
result = %(Exception: )+e.to_s
|
5
|
+
e.stack.to_s.split(%(\n)).each do |line|
|
6
|
+
next if line == "@:0"
|
7
|
+
m = line.match(/(.*)@([^@]*)$/)
|
8
|
+
s = m[1]
|
9
|
+
limit = 50
|
10
|
+
if ( s.length > limit )
|
11
|
+
s = s[0,limit] + %(...)
|
12
|
+
end
|
13
|
+
result += "\n" + m[2]+%( )+s
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
|
18
|
+
ENVJS =
|
19
|
+
File.expand_path( File.join( File.dirname(__FILE__),
|
20
|
+
"envjs",
|
21
|
+
"env.js" ) )
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
load("test/qunit.js");
|
2
|
+
|
3
|
+
Envjs("test/index.html", {});
|
4
|
+
|
5
|
+
test("'index.html' loaded correctly via 'Envjs()' call", function(){
|
6
|
+
expect(1);
|
7
|
+
try{ ok(document.getElementById('body').id == "body",
|
8
|
+
"'index.html' page content available");
|
9
|
+
}catch(e){print(e);}
|
10
|
+
});
|
11
|
+
|
12
|
+
test("window.location= following Envjs() initialization flagged as error",
|
13
|
+
function(){
|
14
|
+
expect(0);
|
15
|
+
});
|
data/test/debug.js
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
// Init
|
2
|
+
load("src/env.js");
|
3
|
+
load("src/htmlparser.js");
|
4
|
+
|
5
|
+
window.location = "test/index.html";
|
6
|
+
|
7
|
+
window.onload = function(){
|
8
|
+
load("test/testrunner.js");
|
9
|
+
load("test/jquery.js");
|
10
|
+
|
11
|
+
var depth = 0;
|
12
|
+
|
13
|
+
function indent(){
|
14
|
+
var str = "";
|
15
|
+
for ( var i = 0; i < depth; i++ ) {
|
16
|
+
str += " ";
|
17
|
+
}
|
18
|
+
return str;
|
19
|
+
}
|
20
|
+
|
21
|
+
function dump(name, args, ret){
|
22
|
+
print(name + ": " + Array.prototype.slice.call(args) + " - Return: " + ret);
|
23
|
+
}
|
24
|
+
|
25
|
+
for ( var method in jQuery.fn ) (function(method){ if ( method != "init" ) {
|
26
|
+
var old = jQuery.fn[method];
|
27
|
+
jQuery.fn[method] = function(){
|
28
|
+
print(indent() + method + ": " + Array.prototype.slice.call(arguments));
|
29
|
+
depth++;
|
30
|
+
var ret = old.apply(this, arguments);
|
31
|
+
depth--;
|
32
|
+
print(indent() + method + ": Return " + ret);
|
33
|
+
return ret;
|
34
|
+
};
|
35
|
+
} })(method);
|
36
|
+
|
37
|
+
for ( var method in jQuery ) (function(method){ if ( method != "prototype" && method != "fn" ) {
|
38
|
+
var old = jQuery[method];
|
39
|
+
jQuery[method] = function(){
|
40
|
+
print(indent() + "$." + method + ": " + Array.prototype.slice.call(arguments));
|
41
|
+
depth++;
|
42
|
+
var ret = old.apply(this, arguments);
|
43
|
+
depth--;
|
44
|
+
print(indent() + "$." + method + ": Return " + ret);
|
45
|
+
return ret;
|
46
|
+
};
|
47
|
+
} })(method);
|
48
|
+
|
49
|
+
jQuery.prototype.toString = DOMNodeList.prototype.toString;
|
50
|
+
Function.prototype.toString = function(){ return "function()"; };
|
51
|
+
|
52
|
+
print("Ready.");
|
53
|
+
};
|
Binary file
|