Skip to content
Browse files

Vendoring envjs

Locking version (built from source) until proper gem release
  • Loading branch information...
1 parent f2be084 commit c2b552e4c815025d287c3017d5ab3660fc9e8fcd @mynyml committed Feb 10, 2010
Showing with 31,917 additions and 3 deletions.
  1. +104 −0 Manifest
  2. +1 −2 harmony.gemspec
  3. +1 −1 lib/harmony/page.rb
  4. +1 −0 vendor/README
  5. +36 −0 vendor/envjs/README
  6. +255 −0 vendor/envjs/bin/envjsrb
  7. +33 −0 vendor/envjs/bin/jquery-1.2.6-test.js
  8. +33 −0 vendor/envjs/bin/jquery-1.3.1-test.js
  9. +106 −0 vendor/envjs/bin/jquery-1.3.2-test.js
  10. +82 −0 vendor/envjs/bin/prototype-1.6.0.3-test.js
  11. +27 −0 vendor/envjs/bin/prototype_1.6.0.3_tmpl.txt
  12. +58 −0 vendor/envjs/bin/test-jquery.sh
  13. +54 −0 vendor/envjs/bin/test-prototype.sh
  14. BIN vendor/envjs/bin/tidy
  15. +23 −0 vendor/envjs/lib/envjs.rb
  16. +21,665 −0 vendor/envjs/lib/envjs/env.js
  17. +3 −0 vendor/envjs/lib/envjs/net.rb
  18. +94 −0 vendor/envjs/lib/envjs/net/cgi.rb
  19. +75 −0 vendor/envjs/lib/envjs/net/file.rb
  20. +11 −0 vendor/envjs/lib/envjs/options.rb
  21. +351 −0 vendor/envjs/lib/envjs/runtime.rb
  22. +24 −0 vendor/envjs/lib/envjs/tempfile.rb
  23. +80 −0 vendor/envjs/test/base64.js
  24. +15 −0 vendor/envjs/test/call-load-test.js
  25. +45 −0 vendor/envjs/test/data.js
  26. +53 −0 vendor/envjs/test/debug.js
  27. BIN vendor/envjs/test/firebug/errorIcon.png
  28. +209 −0 vendor/envjs/test/firebug/firebug.css
  29. +23 −0 vendor/envjs/test/firebug/firebug.html
  30. +672 −0 vendor/envjs/test/firebug/firebug.js
  31. +10 −0 vendor/envjs/test/firebug/firebugx.js
  32. BIN vendor/envjs/test/firebug/infoIcon.png
  33. BIN vendor/envjs/test/firebug/warningIcon.png
  34. +171 −0 vendor/envjs/test/fixtures/html/events.html
  35. +46 −0 vendor/envjs/test/fixtures/html/iframe1.html
  36. +46 −0 vendor/envjs/test/fixtures/html/iframe1a.html
  37. +45 −0 vendor/envjs/test/fixtures/html/iframe2.html
  38. +28 −0 vendor/envjs/test/fixtures/html/iframe3.html
  39. +57 −0 vendor/envjs/test/fixtures/html/iframeN.html
  40. +181 −0 vendor/envjs/test/fixtures/html/malformed.html
  41. +81 −0 vendor/envjs/test/fixtures/html/scope.html
  42. +19 −0 vendor/envjs/test/fixtures/html/trivial.html
  43. +26 −0 vendor/envjs/test/fixtures/html/with_js.html
  44. BIN vendor/envjs/test/fixtures/images/icon-blue.png
  45. +1 −0 vendor/envjs/test/fixtures/js/external_script.js
  46. +1 −0 vendor/envjs/test/fixtures/js/script.js
  47. +2 −0 vendor/envjs/test/fixtures/js/script_error.js
  48. +171 −0 vendor/envjs/test/html/events.html
  49. +46 −0 vendor/envjs/test/html/iframe1.html
  50. +46 −0 vendor/envjs/test/html/iframe1a.html
  51. +45 −0 vendor/envjs/test/html/iframe2.html
  52. +30 −0 vendor/envjs/test/html/iframe3.html
  53. +57 −0 vendor/envjs/test/html/iframeN.html
  54. +181 −0 vendor/envjs/test/html/malformed.html
  55. +87 −0 vendor/envjs/test/html/scope.html
  56. +1 −0 vendor/envjs/test/html/script.js
  57. +19 −0 vendor/envjs/test/html/trivial.html
  58. +26 −0 vendor/envjs/test/html/with_js.html
  59. +328 −0 vendor/envjs/test/index.html
  60. +9 −0 vendor/envjs/test/java-prototype.js
  61. +24 −0 vendor/envjs/test/primary-tests.js
  62. +13 −0 vendor/envjs/test/prototype-test.js
  63. +61 −0 vendor/envjs/test/qunit.js
  64. +17 −0 vendor/envjs/test/qunit/qunit/qunit.css
  65. +997 −0 vendor/envjs/test/qunit/qunit/qunit.js
  66. +25 −0 vendor/envjs/test/scope.rb
  67. +1,534 −0 vendor/envjs/test/specs/dist/env.spec.js
  68. +46 −0 vendor/envjs/test/specs/envjs.spec.css
  69. +31 −0 vendor/envjs/test/specs/parser/html.js
  70. +40 −0 vendor/envjs/test/specs/parser/spec.html
  71. +31 −0 vendor/envjs/test/specs/parser/xml.js
  72. +210 −0 vendor/envjs/test/specs/qunit.bdd.js
  73. +17 −0 vendor/envjs/test/specs/qunit.css
  74. +997 −0 vendor/envjs/test/specs/qunit.js
  75. +31 −0 vendor/envjs/test/specs/template/spec-0.js
  76. +31 −0 vendor/envjs/test/specs/template/spec-1.js
  77. +40 −0 vendor/envjs/test/specs/template/spec.html
  78. +23 −0 vendor/envjs/test/specs/window/css.js
  79. +25 −0 vendor/envjs/test/specs/window/dialog.js
  80. +23 −0 vendor/envjs/test/specs/window/document.js
  81. +25 −0 vendor/envjs/test/specs/window/event.js
  82. +34 −0 vendor/envjs/test/specs/window/history.js
  83. +34 −0 vendor/envjs/test/specs/window/location.js
  84. +71 −0 vendor/envjs/test/specs/window/navigator.js
  85. +42 −0 vendor/envjs/test/specs/window/screen.js
  86. +48 −0 vendor/envjs/test/specs/window/spec.html
  87. +26 −0 vendor/envjs/test/specs/window/timer.js
  88. +53 −0 vendor/envjs/test/specs/window/window.js
  89. +47 −0 vendor/envjs/test/specs/xhr/spec.html
  90. +31 −0 vendor/envjs/test/specs/xhr/xhr.js
  91. +10 −0 vendor/envjs/test/test.js
  92. +44 −0 vendor/envjs/test/unit/dom.js
  93. +60 −0 vendor/envjs/test/unit/elementmembers.js
  94. +195 −0 vendor/envjs/test/unit/events.js
  95. +1 −0 vendor/envjs/test/unit/fixtures/external_script.js
  96. +234 −0 vendor/envjs/test/unit/iframe.js
  97. +212 −0 vendor/envjs/test/unit/multi-window.js
  98. +34 −0 vendor/envjs/test/unit/nu.validator.js
  99. +90 −0 vendor/envjs/test/unit/onload.js
  100. +121 −0 vendor/envjs/test/unit/parser.js
  101. +22 −0 vendor/envjs/test/unit/prototypecompat.js
  102. +6 −0 vendor/envjs/test/unit/proxy.js
  103. +209 −0 vendor/envjs/test/unit/scope.js
  104. +115 −0 vendor/envjs/test/unit/timer.js
  105. +41 −0 vendor/envjs/test/unit/window.js
  106. +2 −0 vendor/envjs/test/vendor/jQuery/README
Sorry, we could not display the entire diff because it was too big.
View
104 Manifest
@@ -11,3 +11,107 @@ specs.watchr
test/harmony_test.rb
test/page_test.rb
test/test_helper.rb
+vendor/README
+vendor/envjs/README
+vendor/envjs/bin/envjsrb
+vendor/envjs/bin/jquery-1.2.6-test.js
+vendor/envjs/bin/jquery-1.3.1-test.js
+vendor/envjs/bin/jquery-1.3.2-test.js
+vendor/envjs/bin/prototype-1.6.0.3-test.js
+vendor/envjs/bin/prototype_1.6.0.3_tmpl.txt
+vendor/envjs/bin/test-jquery.sh
+vendor/envjs/bin/test-prototype.sh
+vendor/envjs/bin/tidy
+vendor/envjs/lib/envjs.rb
+vendor/envjs/lib/envjs/env.js
+vendor/envjs/lib/envjs/net.rb
+vendor/envjs/lib/envjs/net/cgi.rb
+vendor/envjs/lib/envjs/net/file.rb
+vendor/envjs/lib/envjs/options.rb
+vendor/envjs/lib/envjs/runtime.rb
+vendor/envjs/lib/envjs/tempfile.rb
+vendor/envjs/test/base64.js
+vendor/envjs/test/call-load-test.js
+vendor/envjs/test/data.js
+vendor/envjs/test/debug.js
+vendor/envjs/test/firebug/errorIcon.png
+vendor/envjs/test/firebug/firebug.css
+vendor/envjs/test/firebug/firebug.html
+vendor/envjs/test/firebug/firebug.js
+vendor/envjs/test/firebug/firebugx.js
+vendor/envjs/test/firebug/infoIcon.png
+vendor/envjs/test/firebug/warningIcon.png
+vendor/envjs/test/fixtures/html/events.html
+vendor/envjs/test/fixtures/html/iframe1.html
+vendor/envjs/test/fixtures/html/iframe1a.html
+vendor/envjs/test/fixtures/html/iframe2.html
+vendor/envjs/test/fixtures/html/iframe3.html
+vendor/envjs/test/fixtures/html/iframeN.html
+vendor/envjs/test/fixtures/html/malformed.html
+vendor/envjs/test/fixtures/html/scope.html
+vendor/envjs/test/fixtures/html/trivial.html
+vendor/envjs/test/fixtures/html/with_js.html
+vendor/envjs/test/fixtures/images/icon-blue.png
+vendor/envjs/test/fixtures/js/external_script.js
+vendor/envjs/test/fixtures/js/script.js
+vendor/envjs/test/fixtures/js/script_error.js
+vendor/envjs/test/html/events.html
+vendor/envjs/test/html/iframe1.html
+vendor/envjs/test/html/iframe1a.html
+vendor/envjs/test/html/iframe2.html
+vendor/envjs/test/html/iframe3.html
+vendor/envjs/test/html/iframeN.html
+vendor/envjs/test/html/malformed.html
+vendor/envjs/test/html/scope.html
+vendor/envjs/test/html/script.js
+vendor/envjs/test/html/trivial.html
+vendor/envjs/test/html/with_js.html
+vendor/envjs/test/index.html
+vendor/envjs/test/java-prototype.js
+vendor/envjs/test/primary-tests.js
+vendor/envjs/test/prototype-test.js
+vendor/envjs/test/qunit.js
+vendor/envjs/test/qunit/qunit/qunit.css
+vendor/envjs/test/qunit/qunit/qunit.js
+vendor/envjs/test/scope.rb
+vendor/envjs/test/specs/dist/env.spec.js
+vendor/envjs/test/specs/envjs.spec.css
+vendor/envjs/test/specs/parser/html.js
+vendor/envjs/test/specs/parser/spec.html
+vendor/envjs/test/specs/parser/xml.js
+vendor/envjs/test/specs/qunit.bdd.js
+vendor/envjs/test/specs/qunit.css
+vendor/envjs/test/specs/qunit.js
+vendor/envjs/test/specs/template/spec-0.js
+vendor/envjs/test/specs/template/spec-1.js
+vendor/envjs/test/specs/template/spec.html
+vendor/envjs/test/specs/window/css.js
+vendor/envjs/test/specs/window/dialog.js
+vendor/envjs/test/specs/window/document.js
+vendor/envjs/test/specs/window/event.js
+vendor/envjs/test/specs/window/history.js
+vendor/envjs/test/specs/window/location.js
+vendor/envjs/test/specs/window/navigator.js
+vendor/envjs/test/specs/window/screen.js
+vendor/envjs/test/specs/window/spec.html
+vendor/envjs/test/specs/window/timer.js
+vendor/envjs/test/specs/window/window.js
+vendor/envjs/test/specs/xhr/spec.html
+vendor/envjs/test/specs/xhr/xhr.js
+vendor/envjs/test/test.js
+vendor/envjs/test/unit/dom.js
+vendor/envjs/test/unit/elementmembers.js
+vendor/envjs/test/unit/events.js
+vendor/envjs/test/unit/fixtures/external_script.js
+vendor/envjs/test/unit/iframe.js
+vendor/envjs/test/unit/multi-window.js
+vendor/envjs/test/unit/nu.validator.js
+vendor/envjs/test/unit/onload.js
+vendor/envjs/test/unit/parser.js
+vendor/envjs/test/unit/prototypecompat.js
+vendor/envjs/test/unit/proxy.js
+vendor/envjs/test/unit/scope.js
+vendor/envjs/test/unit/timer.js
+vendor/envjs/test/unit/window.js
+vendor/envjs/test/vendor/jQuery/README
+vendor/envjs/test/vendor/prototype-1.6.0.3.js
View
3 harmony.gemspec
@@ -12,8 +12,7 @@ Gem::Specification.new do |s|
s.version = Harmony::VERSION
s.files = File.read("Manifest").strip.split("\n")
- s.add_dependency 'johnson', '>= 2.0.0.pre0'
+ s.add_dependency 'johnson', '2.0.0.pre0'
s.add_dependency 'stackdeck' #johnson dependency
- s.add_dependency 'envjs'
s.add_development_dependency 'minitest'
end
View
2 lib/harmony/page.rb
@@ -2,7 +2,7 @@
require 'tempfile'
require 'johnson/tracemonkey'
-require 'envjs/runtime'
+require Pathname(__FILE__).dirname.parent.parent + 'vendor/envjs/lib/envjs/runtime'
module Harmony
class Page
View
1 vendor/README
@@ -0,0 +1 @@
+vendoring specific envjs version (built from source) until changes are released
View
36 vendor/envjs/README
@@ -0,0 +1,36 @@
+This is a fork of the env.js project (http://github.com/thatcher/env-js/). See that link for env.js details.
+
+This fork is based on the Johnson Ruby gem (http://github.com/jbarnette/johnson) and will become obsolete when the Johnson support has been reintegrated into the master repo.
+
+For now, you can install the envjs gem by installing Johnson:
+
+ gem install johnson --prerelease
+
+(You'll need to manually install any prerequisites it asks for) and then installing the envjs gem with
+
+ gem install envjs
+
+The envjs gem provides the envjsrb command, which functions as an extended version of the Johnson javascript shell. For example:
+
+mbp:env-js smparkes$ envjsrb
+js> this
+=> [object Window 0]
+js> window.location
+=> about:blank
+js> document.innerHTML
+=> "<html><head><title></title></head><body></body></html>"
+js>
+
+It's also possible to embed the envjs interpreter similar to the way it's done in Johnson, e.g.,
+
+require 'rubygems' # if necessary
+require 'johnson/tramonkey'
+require 'envjs/runtime'
+
+envjs = Johnson::Runtime.new
+envjs.extend Envjs::Runtime
+window = envjs.evaluate("")
+puts window.location.to_s # == "about:blank"
+puts window.document.innerHTML # == "<html><head><title></title></head><body></body></html>"
+
+Comments to http://groups.google.com/group/envjs or #envjs on freenode.
View
255 vendor/envjs/bin/envjsrb
@@ -0,0 +1,255 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'pathname'
+
+require 'envjs/options'
+
+require 'johnson/tracemonkey'
+require 'johnson/cli'
+require 'envjs/runtime'
+
+RUNTIME = js = Johnson::Runtime.new
+RUNTIME.extend Envjs::Runtime
+
+# RUNTIME.load Envjs::ENVJS
+
+EXIT_VERBS = [nil] + %w(exit quit)
+
+prepped = false
+ruby_readline = []
+js_readline = []
+local_binding = binding
+mode = nil
+
+(class<<self; self; end).send :define_method, :prep do
+
+ return if prepped
+ prepped = true
+
+ require "readline"
+ require "johnson/cli"
+
+ RUNTIME.evaluate(Johnson::CLI::JS)
+
+ def copy_history
+ new_history = []
+ until Readline::HISTORY.empty?
+ new_history.push(Readline::HISTORY.pop)
+ end
+ new_history
+ end
+
+ def paste_history(old_history)
+ until old_history.empty?
+ Readline::HISTORY << old_history.pop
+ end
+ end
+
+ def handle_exit(input)
+ return EXIT_VERBS.include?(input)
+ end
+
+ def rescued(&block)
+ yield
+ rescue Exception => e
+ exit if SystemExit === e
+
+ puts e.message
+ puts e.backtrace.reject { |l| l =~ /bin\/johnson/ }
+ end
+
+ def eval_in_js(expression,stream)
+ rescued do
+ v = RUNTIME.evaluate(expression, "(console)")
+ stream.result { "=> " + v.inspect }
+ end
+ end
+
+ def eval_in_ruby(expression, bind_to, stream)
+ rescued do
+ v = eval(expression, bind_to)
+ stream.result { "=> " + v.inspect }
+ end
+ end
+
+ (class<<self; self; end).send :define_method, :do_loop do |stream|
+ # def foo
+
+ catch "Breakout" do
+ loop do
+ mode = :js
+ input = stream.next("js> ")
+ input and input.chomp!
+ begin stream.exit(input); throw "Breakout" end if handle_exit(input)
+
+ if input =~ /^rb\s+(.+)$/
+ eval_in_ruby($1, local_binding, stream)
+ next
+ end
+
+ if input == "rb"
+ js_readline = copy_history
+ paste_history(ruby_readline)
+
+ loop do
+ mode = :rb
+ # input = Readline.readline("rb> ", true)
+ input = stream.next("rb> ")
+ begin stream.exit(input); throw "Breakout" end if handle_exit(input)
+
+ break if input == "js"
+
+ if input =~ /^js\s+(.+)$/
+ eval_in_js($1)
+ next
+ end
+
+ eval_in_ruby(input, local_binding, stream)
+ end
+
+ ruby_readline = copy_history
+ paste_history(js_readline)
+ next
+ end
+
+ eval_in_js(input, stream)
+ end
+ end
+ end
+end
+
+if ARGV.length > 0
+
+ begin
+ about_blank = true
+ ARGV.each do |file|
+
+ uri = URI.parse file
+
+ if uri.scheme == nil
+ uri.scheme = "file"
+ begin
+ uri.path = Pathname.new(uri.path).realpath.to_s
+ rescue Errno::ENOENT; end
+ uri = URI.parse uri.to_s
+ end
+
+ uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
+
+ if uri.scheme == "about" and uri.opaque == "blank"
+ RUNTIME.wait
+ RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
+ about_blank = true
+ elsif uri.path =~ /\.x?html?$/ || uri.scheme =~ %r(^https?)
+
+ # this might want to go alway; jazrb does it manually now, which I think was the use case
+ # that wanted this
+ if !about_blank
+ RUNTIME.wait
+ RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
+ end
+
+ RUNTIME.wait
+ # RUNTIME.evaluate("window.location = 'file://#{Pathname.new(file).realpath}'", file, 1)
+ RUNTIME.evaluate("window.location = '#{uri_s}'", file, 1)
+ about_blank = false
+ else
+ RUNTIME.become_first_script_window
+ RUNTIME.top_level_load uri_s
+ RUNTIME.load uri_s
+ end
+ end
+ rescue Johnson::Error => je
+ if je.message.match /<SystemExit: exit>/
+ exit
+ end
+ raise je
+ end
+
+ RUNTIME.wait
+
+else
+
+ prep
+
+ if !(files = Dir[".envjsrbrc",File.join(ENV["HOME"],".envjsrbrc")]).empty?
+ file = Class.new do
+ def initialize f
+ @file = open f
+ end
+ def next prompt
+ @file.gets
+ end
+ def result &block
+ end
+ def exit v; end
+ end.new files[0]
+
+ do_loop file
+ end
+
+ options = Johnson::CLI::Options.parse!(ARGV)
+
+ options.load_paths.each { |d| $LOAD_PATH << d }
+ options.paths_to_require.each { |p| RUNTIME.evaluate("Johnson.require('#{p}')") }
+ options.files_to_preload.each { |f| RUNTIME.load(f) }
+
+ unless options.expressions.empty?
+ options.expressions.each { |e| RUNTIME.evaluate(e, '-e') }
+ exit if options.files_to_evaluate.empty?
+ end
+
+ unless options.files_to_evaluate.empty?
+ RUNTIME[:arguments] = options.arguments
+
+ options.files_to_evaluate.each do |file|
+ RUNTIME.load(file)
+ end
+
+ exit
+ end
+
+ reader = Class.new do
+ def next prompt
+ Readline.readline(prompt, true)
+ end
+ def result
+ puts yield
+ end
+ def exit v; puts if v.nil?; end
+ end.new
+
+ begin
+ open(File.join(ENV["HOME"],".envjsrb.js")) do |f|
+ js_readline = f.read.split("\n")
+ end
+ rescue; end
+
+ begin
+ open(File.join(ENV["HOME"],".envjsrb.ruby")) do |f|
+ ruby_readline = f.read.split("\n")
+ end
+ rescue; end
+
+ case mode
+ when :js; paste_history js_readline
+ when :rb; paste_history ruby_readline
+ end
+
+ do_loop reader
+
+ case mode
+ when :js; js_readline = copy_history
+ when :rb; ruby_readline = copy_history
+ end
+
+ open(File.join(ENV["HOME"],".envjsrb.js"),"w") do |f|
+ f.write js_readline[0..100].join("\n")+"\n"
+ end
+
+ open(File.join(ENV["HOME"],".envjsrb.ruby"),"w") do |f|
+ f.write ruby_readline[0..100].join("\n")+"\n"
+ end
+
+end
View
33 vendor/envjs/bin/jquery-1.2.6-test.js
@@ -0,0 +1,33 @@
+// Init
+load("build/runtest/env.js");
+
+var isLocal;
+window.onload = function(){
+ isLocal = !!(window.location.protocol == 'file:');
+
+ // Load the test runner
+ load("dist/jquery.js",
+ "build/runtest/testrunner.js");
+
+ // Load the tests
+ load(
+ "test/unit/core.js",
+ "test/unit/selector.js",
+ "test/unit/event.js",
+ "test/unit/fx.js",
+ "test/unit/dimensions.js",
+
+ // offset relies on window.open, which is currently unimplemented in env.js
+ //"test/unit/offset.js",
+
+ // these tests require hitting a server, so we will need some clever env.js
+ // way of testing them
+ // by defining isLocal we can still load the test
+ "test/unit/ajax.js"
+ );
+
+ // Display the results
+ results();
+};
+
+window.location = "test/index.html";
View
33 vendor/envjs/bin/jquery-1.3.1-test.js
@@ -0,0 +1,33 @@
+// Init
+load("build/runtest/env.js");
+
+var isLocal;
+window.onload = function(){
+ isLocal = !!(window.location.protocol == 'file:');
+
+ // Load the test runner
+ load("dist/jquery.js",
+ "build/runtest/testrunner.js");
+
+ // Load the tests
+ load(
+ "test/unit/core.js",
+ "test/unit/selector.js",
+ "test/unit/event.js",
+ "test/unit/fx.js",
+ "test/unit/dimensions.js",
+ "test/unit/data.js",
+
+ // offset relies on window.open, which is currently unimplemented in env.js
+ //"test/unit/offset.js",
+
+ // these tests require hitting a server, so we will need some clever env.js
+ // way of testing them
+ "test/unit/ajax.js"
+ );
+
+ // Display the results
+ results();
+};
+
+window.location = "test/index.html";
View
106 vendor/envjs/bin/jquery-1.3.2-test.js
@@ -0,0 +1,106 @@
+//debugger;
+load("build/runtest/env.js");
+
+(function(Envjs){
+ var $env = Envjs.$env;
+
+ Envjs("test/index.html", {
+ //let it load the script from the html
+ logLevel: $env.INFO,
+ scriptTypes: {
+ "text/javascript" :true
+ },
+ afterScriptLoad:{
+ 'qunit/testrunner.js': function(){
+ //hook into qunit.log
+ var count = 0;
+ QUnit.log = function(result, message){
+ $env.log('(' + (count++) + ')[' +
+ ((!!result) ? 'PASS' : 'FAIL') + '] ' + message);
+ };
+ //hook into qunit.done
+ QUnit.done = function(pass, fail){
+ $env.warn('Writing Results to File');
+ jQuery('script').each(function(){
+ this.type = 'text/envjs';
+ });
+ $env.writeToFile(
+ document.documentElement.xml,
+ $env.location('jqenv-'+Date.now()+'.html')
+ );
+ };
+
+ //allow jquery to run ajax
+ isLocal = false;
+
+
+ var unsafeStop = stop,
+ unsafeStart = start,
+ isStopped = null;
+
+ var config_timeout;
+ stop = function(timeout){
+ if(isStopped === null || isStopped === false){
+ $env.log('PAUSING QUNIT');
+ isStopped = true;
+ unsafeStop.call(this);
+ timeout = ( timeout && timeout > 0 ) ? timeout : 10000;
+ if (timeout)
+ config_timeout = setTimeout(function() {
+ QUnit.ok( false, "Test timed out" );
+ start();
+ }, timeout);
+ /* $env.wait() */
+ }
+ };
+ start = function(){
+ if(isStopped === null || isStopped === true ){
+ $env.log('RESTARTING QUNIT');
+ isStopped = false;
+ if(config_timeout) {
+ clearTimeout(config_timeout);
+ config_timeout = undefined;
+ }
+ unsafeStart.call(this);
+ }
+ };
+ //we know some ajax calls will fail becuase
+ //we are not running against a running server
+ //for php files
+ var handleError = jQuery.handleError;
+ jQuery.handleError = function(){
+ ok(false, 'Ajax may have failed while running locally');
+ try{
+ handleError(arguments);
+ }catch(e){}
+ //allow tests to gracefully continue
+ start();
+ };
+ //allow unanticipated xhr error with no ajax.handleError
+ //callback (eg jQuery.getScript) to exit gracefully
+ $env.onInterrupt = function(){
+ $env.info('thread interupt: gracefully continuing test');
+ start();
+ };
+
+
+ $env.onScriptLoadError = function(script){
+ Envjs.error("failed to load script \n"+script.text);
+ ok(false, 'Ajax may have failed to load correct script while running locally');
+ //allow tests to gracefully continue
+ start();
+ };
+ }
+ }
+ });
+
+})(Envjs);
+
+Envjs.wait();
+
+// Local Variables:
+// espresso-indent-level:4
+// c-basic-offset:4
+// tab-width:4
+// mode:auto-revert
+// End:
View
82 vendor/envjs/bin/prototype-1.6.0.3-test.js
@@ -0,0 +1,82 @@
+//debugger;
+load("env.js");
+
+(function($env){
+
+
+ $env("array_test.html", {
+ //let it load the script from the html
+ scriptTypes: {
+ "text/javascript" :true
+ },
+ afterload:{
+ 'lib_assets/unittest.js': function(){
+ //hook into some messaging
+ var assertBlock = Test.Unit.Assertions.assertBlock;
+ Test.Unit.Assertions.assertBlock = function(){
+ $env.log(arguments[0]);
+ return assertBlock(arguments);
+ };
+ Test.Unit.Logger.prototype.initialize = function(id) {
+ this.id = id;
+ $env.debug(' ['+this.id+'] initialized');
+ };
+
+ Test.Unit.Logger.prototype.start = function(testName) {
+ this.currentTest = testName;
+ $env.debug(' ['+this.id+'] starting test ('+this.currentTest+')');
+ };
+
+
+ Test.Unit.Logger.prototype.setStatus = function(status) {
+ $env.log(' ['+this.id+'] ('+this.currentTest+') '+status);
+ };
+
+ Test.Unit.Logger.prototype.finish = function(status, summary) {
+ $env.log(' ['+this.id+'] ('+this.currentTest+
+ ') '+status+' '+summary.replace(/\n/g,"\t"));
+ };
+
+ }
+ }
+ });
+ $env.writeToFile(
+ document.documentElement.xml,
+ $env.location('jqenv-array_test-'+Date.now()+'.html')
+ );
+
+ $env("base_test.html", {
+ //let it load the script from the html
+ scriptTypes: {
+ "text/javascript" :true
+ }
+ });
+ $env.writeToFile(
+ document.documentElement.xml,
+ $env.location('jqenv-base_test-'+Date.now()+'.html')
+ );
+
+
+ $env("class_test.html", {
+ //let it load the script from the html
+ scriptTypes: {
+ "text/javascript" :true
+ }
+ });
+ $env.writeToFile(
+ document.documentElement.xml,
+ $env.location('jqenv-class_test-'+Date.now()+'.html')
+ );
+
+ $env("date_test.html", {
+ //let it load the script from the html
+ scriptTypes: {
+ "text/javascript" :true
+ }
+ });
+ $env.writeToFile(
+ document.documentElement.xml,
+ $env.location('jqenv-date_test-'+Date.now()+'.html')
+ );
+
+})(Envjs);
View
27 vendor/envjs/bin/prototype_1.6.0.3_tmpl.txt
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Unit test file | <%= title %> | <%= template_name %> template | <%= timestamp %></title>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <script type="text/javascript" charset="utf-8">
+ var eventResults = {};
+ var originalElement = window.Element;
+ </script>
+ <%= script_tag('assets/prototype.js') %>
+ <%= script_tag('lib_assets/unittest.js') %>
+ <%= link_tag('lib_assets/unittest.css') %>
+ <%= css_fixtures %>
+ <%= js_fixtures %>
+ <%= test_file %>
+</head>
+<body>
+
+<div id="testlog"></div>
+
+<%= html_fixtures %>
+<script type="text/javascript" charset="utf-8">
+ eventResults.endOfDocument = true;
+</script>
+</body>
+</html>
View
58 vendor/envjs/bin/test-jquery.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Usage: test-jquery.sh [version]
+# Currently supported versions: 1.3.2, 1.3.1, and 1.2.6
+#
+# This script will check out the jQuery development tree from Subversion if necessary,
+# massage the testing scripts as necessary, copy our latest version of env.js into place,
+# and then run the test scripts.
+
+
+if [ -n "$2" ]; then
+ echo 'debug'
+ if [ -n "$2" ]; then VERSION="$2"; else VERSION="1.3.2"; fi
+ DEBUG=1
+else
+ echo 'jquery'
+ if [ -n "$1" ]; then VERSION="$1"; else VERSION="1.3.2"; fi
+ DEBUG=0
+fi
+
+JQUERY_DIR="test/vendor/jQuery/$VERSION";
+
+ant concat
+
+if [ ! -d "$JQUERY_DIR" ]; then
+ svn export http://jqueryjs.googlecode.com/svn/tags/$VERSION/ $JQUERY_DIR
+ case "$VERSION" in
+ "1.3.2")
+ rm -rf "$JQUERY_DIR/test/qunit"
+ svn export -r6173 http://jqueryjs.googlecode.com/svn/trunk/qunit $JQUERY_DIR/test/qunit
+ ;;
+ "1.3.1")
+ rm -rf "$JQUERY_DIR/test/qunit"
+ svn export -r6133 http://jqueryjs.googlecode.com/svn/trunk/qunit $JQUERY_DIR/test/qunit
+ ;;
+ esac
+fi
+
+cp dist/env.rhino.js $JQUERY_DIR/build/runtest/env.js
+cp dist/env-js.jar $JQUERY_DIR/build/js.jar
+cp bin/jquery-$VERSION-test.js $JQUERY_DIR/build/runtest/test.js
+
+if [ $DEBUG -eq 1 ]; then
+ echo 'enabling rhino debugger'
+ perl -pi~ -e "s/^JAR(.*)(-jar.*|-cp.*)/JAR\1 -cp \\$\{BUILD_DIR}\/js.jar org.mozilla.javascript.tools.debugger.Main -opt -1/" $JQUERY_DIR/Makefile;
+else
+ if [ "x$JOHNSON" == "x " ]; then
+ echo 'running with rhino'
+ perl -pi~ -e "s/^JAR(.*)(-jar.*|-cp.*)/JAR\1 -cp \\$\{BUILD_DIR}\/js.jar org.mozilla.javascript.tools.envjs.Main -opt -1/" $JQUERY_DIR/Makefile;
+ else
+ echo 'running with johnson'
+ echo > $JQUERY_DIR/build/runtest/env.js
+ perl -pi~ -e "s/^JAR(.*)(-jar.*|-cp.*)/JAR = envjsrb/" $JQUERY_DIR/Makefile;
+ fi
+fi
+
+cd $JQUERY_DIR
+make runtest
View
54 vendor/envjs/bin/test-prototype.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# Usage: test-prototype.sh [version]
+# Currently supported versions: 1.6.0.3
+#
+# This script will check out the Prototype development tree from Github if necessary,
+# massage the testing scripts as necessary, copy our latest version of env.js into place,
+# and then run the test scripts.
+
+
+if [ -n "$2" ]; then
+ echo 'debug'
+ if [ -n "$2" ]; then VERSION="$2"; else VERSION="1.6.0.3"; fi
+ DEBUG=1
+else
+ echo 'jquery'
+ if [ -n "$1" ]; then VERSION="$1"; else VERSION="1.6.0.3"; fi
+ DEBUG=0
+fi
+
+PROTOTYPE_DIR="test/vendor/Prototype/$VERSION";
+
+ant concat
+
+if [ ! -d "$PROTOTYPE_DIR" ]; then
+ git clone git://github.com/sstephenson/prototype.git $PROTOTYPE_DIR
+ # - prepares tests - #
+ cd $PROTOTYPE_DIR
+ git submodule init #allow prototype to discover test framework dependencies
+ git submodule update #load the dicovered dependencies
+ cd -
+fi
+
+#replace thier test html template erb (malformed html on purpose..really???)
+cat bin/prototype_1.6.0.3_tmpl.txt > $PROTOTYPE_DIR/test/unit/templates/default.erb
+sed 's/runner\.run/ /g' $PROTOTYPE_DIR/Rakefile > $PROTOTYPE_DIR/Rakefile
+cd $PROTOTYPE_DIR
+rake test
+cd -
+
+cp dist/env.rhino.js $PROTOTYPE_DIR/test/unit/tmp/env.js
+cp dist/env-js.jar $PROTOTYPE_DIR/test/unit/tmp/env-js.jar
+cp bin/prototype-$VERSION-test.js $PROTOTYPE_DIR/test/unit/tmp/test.js
+
+
+cd $PROTOTYPE_DIR/test/unit/tmp
+if [ $DEBUG -eq 1 ]; then
+ echo 'running with rhino debugger'
+ java -cp env-js.jar org.mozilla.javascript.tools.envjs.Main test.js;
+else
+ echo 'running with rhino'
+ java -cp env-js.jar org.mozilla.javascript.tools.envjs.Main test.js;
+fi
+
View
BIN vendor/envjs/bin/tidy
Binary file not shown.
View
23 vendor/envjs/lib/envjs.rb
@@ -0,0 +1,23 @@
+module Envjs
+
+ def self.js_exception_stack e
+ result = %(Exception: )+e.to_s
+ e.stack.to_s.split(%(\n)).each do |line|
+ next if line == "@:0"
+ m = line.match(/(.*)@([^@]*)$/)
+ s = m[1]
+ limit = 50
+ if ( s.length > limit )
+ s = s[0,limit] + %(...)
+ end
+ result += "\n" + m[2]+%( )+s
+ end
+ result
+ end
+
+ ENVJS =
+ File.expand_path( File.join( File.dirname(__FILE__),
+ "envjs",
+ "env.js" ) )
+
+end
View
21,665 vendor/envjs/lib/envjs/env.js
21,665 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
3 vendor/envjs/lib/envjs/net.rb
@@ -0,0 +1,3 @@
+require 'envjs'
+
+module Envjs::Net; end
View
94 vendor/envjs/lib/envjs/net/cgi.rb
@@ -0,0 +1,94 @@
+require 'net/protocol'
+
+require 'envjs/net'
+
+class Envjs::Net::CGI
+
+ def save_and_set k, v
+ @saved[k] = ENV[k]
+ ENV[k] = v
+ end
+
+ def restore
+ @saved.keys.each do |k|
+ ENV[k] = @saved[k]
+ end
+ @saved = {}
+ end
+
+ def initialize xhr, data
+ if (match = %r((.*\.php)(\?(.*))?).match xhr.url).nil?
+ raise "Not CGI"
+ end
+
+ @saved = {}
+
+ begin
+
+ # p match[0]
+
+ path = match[1]
+ path.sub! %r(^file://), ""
+
+ save_and_set( "GATEWAY_INTERFACE", "CGI/1.1" )
+
+ save_and_set( "REQUEST_METHOD", xhr["method"] )
+ if ( match[3] )
+ save_and_set( "QUERY_STRING", match[3] )
+ end
+
+ if ct = xhr["headers"]["Content-Type"]
+ save_and_set( "CONTENT_TYPE", ct )
+ end
+
+ if data
+ save_and_set( "CONTENT_LENGTH", data.length.to_s )
+ end
+
+ xhr["headers"].each do |k,v|
+ k.gsub!("-","_")
+ k = "HTTP_" + k
+ save_and_set( k, v )
+ end
+
+ result = nil
+
+ save_and_set( "PATH_INFO", path )
+ save_and_set( "PATH_TRANSLATED", path )
+ save_and_set( "REDIRECT_STATUS", "200" )
+
+ open("|php-cgi", "r+") do |php|
+ if data
+ php.write data
+ php.flush
+ end
+ result = php.read
+ end
+
+ result && result = result.split("\r\n")
+ @headers = {}
+ while line = result.shift
+ break if line == ""
+ match = /([^:]*):\s*(.*)/.match line
+ @headers[match[1]]=match[2]
+ end
+ # p "q", result.join("\r\n")
+ @body = result.join("\r\n")
+ ensure
+ restore
+ end
+
+ end
+
+ def each
+ @headers.each do |k,v|
+ yield k, v
+ end
+ end
+
+ def finish
+ end
+
+ attr_reader :body
+
+end
View
75 vendor/envjs/lib/envjs/net/file.rb
@@ -0,0 +1,75 @@
+require 'net/protocol'
+
+require 'envjs/net'
+
+class Envjs::Net::File < Net::Protocol
+
+ class << self
+ attr_accessor :on_open
+ end
+
+ class Get
+ attr_accessor :path
+ def initialize path
+ @path = path
+ end
+ end
+
+ def initialize host, port
+ end
+
+ def self.start host, port
+ new( host, port ).start
+ end
+
+ def start
+ self
+ end
+
+ def finish
+ end
+
+ def request request
+ Response.new request.path
+ end
+
+ class Response
+ def initialize path
+ @path = path
+ on_open = Envjs::Net::File.on_open
+ on_open and on_open.call( path )
+ @file = File.new @path
+ @body = @file.read
+ @code = @file.nil? ? "404" : "200";
+ @file.close
+ end
+
+ def [] *args
+ nil
+ end
+
+ def each &block
+ end
+
+ def getHeaderFields
+ []
+ end
+
+ def getContentEncoding
+ nil
+ end
+
+ def getResponseCode
+ @file.nil? ? 404 : 200;
+ end
+
+
+ def getInputStream
+ self
+ end
+
+ attr_reader :body, :code
+
+ end
+
+end
View
11 vendor/envjs/lib/envjs/options.rb
@@ -0,0 +1,11 @@
+require 'optparse'
+
+$envjsrb_deps = nil
+
+OptionParser.new do |o|
+
+ o.on("--deps path") do |path|
+ $envjsrb_deps = path
+ end
+
+end.parse!
View
351 vendor/envjs/lib/envjs/runtime.rb
@@ -0,0 +1,351 @@
+require 'envjs'
+require "open-uri"
+require 'pathname'
+begin
+ require 'fsdb'
+rescue LoadError; end
+require 'envjs/net/file'
+
+module Envjs::Runtime
+
+ def self.extended object
+ object.instance_eval do
+
+ evaluate <<'EOJS'
+print = function() {
+ var l = arguments.length
+ for( var i = 0; i < l; i++ ) {
+ var s;
+ if ( arguments[i] === null ) {
+ s = "null";
+ } else if ( arguments[i] === undefined ) {
+ s = "undefined"
+ } else {
+ s = arguments[i].toString();
+ }
+ Ruby.print(s);
+ if( i < l-1 ) {
+ Ruby.print(" ");
+ }
+ }
+ Ruby.print("\n");
+ Ruby['$stdout'].flush();
+};
+EOJS
+
+ evaluate <<'EOJS'
+debug = function() {
+ var l = arguments.length
+ for( var i = 0; i < l; i++ ) {
+ var s;
+ if ( arguments[i] === null ) {
+ s = "null";
+ } else if ( arguments[i] === undefined ) {
+ s = "undefined"
+ } else {
+ s = arguments[i].toString();
+ }
+ Ruby['$stderr'].print(s);
+ if( i < l-1 ) {
+ Ruby['$stderr'].print(" ");
+ }
+ }
+ Ruby['$stderr'].print("\n");
+};
+EOJS
+
+ evaluate <<'EOJS'
+puts = function() {
+ var l = arguments.length
+ for( var i = 0; i < l; i++ ) {
+ var s;
+ if ( arguments[i] === null ) {
+ s = "null";
+ } else if ( arguments[i] === undefined ) {
+ s = "undefined"
+ } else {
+ s = arguments[i].toString();
+ }
+ Ruby.print(s);
+ Ruby.eval("$stdout.flush")
+ }
+};
+EOJS
+
+ master = global["$master"] = evaluate("new Object")
+ master.symbols = [ "Johnson", "Ruby", "print", "debug", "puts", "load", "reload", "whichInterpreter", "multiwindow" ]
+ master.symbols.each { |symbol| master[symbol] = global[symbol] }
+
+ master.whichInterpreter = "Johnson"
+
+ master.multiwindow = true
+
+ # calling this from JS is hosed; the ruby side is confused, maybe because HTTPHeaders is mixed in?
+ master.add_req_field = lambda { |r,k,v| r.add_field(k,v) }
+
+ db = lambda do
+ $envjsrb_deps && ( @db ||= FSDB::Database.new $envjsrb_deps )
+ end
+
+ top_level_js = nil
+
+ add_dep = nil
+
+ clear_deps = lambda do |w|
+ begin
+ if db.call
+ loc = w
+ begin loc = w.location; rescue; end
+ loc && ( loc = loc.to_s )
+ if ( loc !~ %r((http?s|file|about):) )
+ begin
+ loc = "file://" + Pathname(loc).realpath.to_s
+ rescue Errno::ENOENT; end
+ end
+ # $stderr.puts "clear", loc
+ if loc and loc != "about:blank"
+ paths = db.call[loc+".on.yml"] || []
+ paths.each do |path|
+ # $stderr.print "#{path} not by #{loc}\n";
+ db.call[path+".by.yml"].delete loc
+ end
+ # $stderr.print "#{loc} not on anything\n";
+ db.call.delete loc+".on.yml"
+ end
+ end
+ add_dep.call( nil, loc )
+ rescue Exception => e; $stderr.puts e, e.class; $stderr.puts e.backtrace; end
+ end
+
+ if $envjsrb_deps
+ Envjs::Net::File.on_open = clear_deps
+ end
+
+ add_dep = lambda do |w, f|
+ if db.call
+ loc = nil
+ begin loc = w.location; rescue Exception; end
+ loc && ( loc = loc.to_s )
+ if ( loc && loc !~ %r((http?s|file|about):) )
+ loc = "file://" + Pathname(loc).realpath.to_s
+ end
+ path = f
+ if ( path !~ %r((http?s|file|about):) )
+ begin
+ path = "file://" + Pathname(path).realpath.to_s
+ rescue Errno::ENOENT
+ return
+ end
+ end
+ if !loc || loc == "about:blank"
+ uri = URI.parse top_level_js
+ if uri.scheme == nil
+ uri.scheme = "file"
+ begin
+ uri.path = Pathname.new(uri.path).realpath.to_s
+ rescue Errno::ENOENT; end
+ uri = URI.parse uri.to_s
+ end
+ uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
+
+ # tll = "file://" + Pathname(top_level_js).realpath.to_s
+
+ tll = uri_s
+
+ if ( tll != path )
+ loc = tll
+ end
+ end
+ if loc and loc != "about:blank"
+ on = db.call[loc+".on.yml"] || []
+ on << path
+ on.uniq!
+ db.call[loc+".on.yml"] = on
+ by = db.call[path+".by.yml"] || []
+ by << loc
+ by.uniq!
+ db.call[path+".by.yml"] = by
+ # $stderr.print "#{loc} on #{path}: #{db.call[loc+'.on.yml'].join(' ')}\n"
+ # $stderr.print "#{path} by #{loc}: #{db.call[path+'.by.yml'].join(' ')}\n"
+ end
+ end
+ end
+
+ (class << self; self; end).send :define_method, :top_level_load do |path|
+ # $stderr.print "tll #{path}\n"
+ top_level_js = path
+ clear_deps.call( path )
+ end
+
+ master.load = lambda { |*files|
+ if files.length == 2 && !(String === files[1])
+ f = files[0]
+ w = files[1]
+
+ # Hmmm ...
+ uri = URI.parse f
+
+ if uri.scheme == nil
+ uri.scheme = "file"
+ begin
+ uri.path = Pathname.new(uri.path).realpath.to_s
+ rescue Errno::ENOENT; end
+ uri = URI.parse uri.to_s
+ end
+
+ uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
+
+ if uri.scheme == "file"
+ uri_s = uri.path
+ elsif uri.scheme == "data"
+ raise "implement 0"
+ end
+
+ v = open(uri_s).read.gsub(/\A#!.*$/, '')
+ loc = nil
+ add_dep.call w, f
+ evaluate(v, f, 1, w, w, f)
+ else
+ load *files
+ end
+ }
+
+ def load *files
+ files.map { |f|
+ # Hmmm ...
+
+ uri = URI.parse f
+ if uri.scheme == nil
+ uri.scheme = "file"
+ begin
+ uri.path = Pathname.new(uri.path).realpath.to_s
+ rescue Errno::ENOENT; end
+ uri = URI.parse uri.to_s
+ end
+ uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
+
+ if uri.scheme == "file"
+ super uri.path
+ elsif uri.scheme == "data"
+ raise "implement 1"
+ else
+ raise "hell 1"
+ end
+
+ # v = open(uri_s).read.gsub(/\A#!.*$/, '')
+ # loc = nil
+ # add_dep.call w, f
+ # evaluate(v, f, 1, w, w, f)
+ # evaluate(File.read(f).gsub(/\A#!.*$/, ''), f, 1)
+
+ }.last
+ end
+
+ master.reload = lambda { |*files|
+ if files.length == 2 && !(String === files[1])
+ f = files[0]
+ w = files[1]
+ v = open(f).read.gsub(/\A#!.*$/, '')
+ loc = nil
+ add_dep.call w, f
+ reevaluate(v, f, 1, w, w, f)
+ else
+ reload *files
+ end
+ }
+
+ master.evaluate = lambda { |v,w|
+ evaluate(v,"inline",1,w,w);
+ }
+
+ master.new_split_global_outer = lambda { new_split_global_outer }
+ master.new_split_global_inner = lambda { |outer,_| new_split_global_inner outer }
+
+ # create an proto window object and proxy
+
+ outer = new_split_global_outer
+ window = inner = new_split_global_inner( outer )
+
+ master.symbols.each do |symbol|
+ window[symbol] = master[symbol]
+ end
+
+ master.first_script_window = window
+
+ window["$master"] = master
+ window["$options"] = evaluate("new Object");
+ window["$options"].proxy = outer
+
+ window.evaluate = lambda { |s|
+ return master.evaluate.call(s,window);
+ }
+
+ window.load = lambda { |*files|
+ files.each do |f|
+ master.load.call f, window
+ end
+ }
+
+ window.reload = lambda { |*files|
+ files.each do |f|
+ master.reload.call f, window
+ end
+ }
+
+ ( class << self; self; end ).send :define_method, :wait do
+ master["finalize"] && master.finalize.call
+ master.timers && master.timers.wait
+ end
+
+ scripts = {}
+
+ ( class << self; self; end ).send :define_method, :become_first_script_window do
+ # p "heh", inner, master.first_script_window
+ inner = master.first_script_window
+ end
+
+ ( class << self; self; end ).send :define_method, :evaluate do |*args|
+ ( script, file, line, global, scope, fn ) = *args
+ # print "eval in " + script[0,50].inspect + (scope ? scope.toString() : "nil") + "\n"
+ global = nil
+ scope ||= inner
+ if fn
+ compiled_script = scripts[fn]
+ end
+ # compiled_script = compile(script, file, line, global)
+ compiled_script ||= compile(script, file, line, global)
+ if fn && !scripts[fn]
+ scripts[fn] = compiled_script
+ end
+ # p "?", script
+ evaluate_compiled_script(compiled_script,scope)
+ end
+
+ ( class << self; self; end ).send :define_method, :reevaluate do |*args|
+ ( script, file, line, global, scope, fn ) = *args
+ # print "eval in " + script[0,50].inspect + (scope ? scope.toString() : "nil") + "\n"
+ global = nil
+ scope ||= inner
+ compiled_script = compile(script, file, line, global)
+ if fn
+ scripts[fn] = compiled_script
+ end
+ evaluate_compiled_script(compiled_script,scope)
+ end
+
+ @envjs = inner
+
+ ( class << self; self; end ).send :define_method, :"[]" do |key|
+ key == "this" && evaluate("this") || @envjs[key]
+ end
+
+ ( class << self; self; end ).send :define_method, :"[]=" do |k,v|
+ @envjs[k] = v
+ end
+
+ load Envjs::ENVJS
+
+ end
+ end
+
+end
View
24 vendor/envjs/lib/envjs/tempfile.rb
@@ -0,0 +1,24 @@
+require 'tempfile'
+
+require 'envjs'
+
+class Envjs::TempFile < Tempfile
+
+ def initialize pattern, suffix = nil
+ super(pattern)
+
+
+ if suffix
+ new_path = path + "." + suffix
+ File.link path, new_path
+ File.unlink path
+ # blah ... implementation specific ...
+ @data[0] = @tmpname = new_path
+ end
+ end
+
+ def getAbsolutePath
+ path
+ end
+
+end
View
80 vendor/envjs/test/base64.js
@@ -0,0 +1,80 @@
+// This code was written by Tyler Akins and has been placed in the
+// public domain. It would be nice if you left this header intact.
+// Base64 code from Tyler Akins -- http://rumkin.com
+
+var Base64 = (function () {
+ var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+
+ var obj = {
+ /**
+ * Encodes a string in base64
+ * @param {String} input The string to encode in base64.
+ */
+ encode: function (input) {
+ var output = "";
+ var chr1, chr2, chr3;
+ var enc1, enc2, enc3, enc4;
+ var i = 0;
+
+ do {
+ chr1 = input.charCodeAt(i++);
+ chr2 = input.charCodeAt(i++);
+ chr3 = input.charCodeAt(i++);
+
+ enc1 = chr1 >> 2;
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+ enc4 = chr3 & 63;
+
+ if (isNaN(chr2)) {
+ enc3 = enc4 = 64;
+ } else if (isNaN(chr3)) {
+ enc4 = 64;
+ }
+
+ output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
+ keyStr.charAt(enc3) + keyStr.charAt(enc4);
+ } while (i < input.length);
+
+ return output;
+ },
+
+ /**
+ * Decodes a base64 string.
+ * @param {String} input The string to decode.
+ */
+ decode: function (input) {
+ var output = "";
+ var chr1, chr2, chr3;
+ var enc1, enc2, enc3, enc4;
+ var i = 0;
+
+ // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
+
+ do {
+ enc1 = keyStr.indexOf(input.charAt(i++));
+ enc2 = keyStr.indexOf(input.charAt(i++));
+ enc3 = keyStr.indexOf(input.charAt(i++));
+ enc4 = keyStr.indexOf(input.charAt(i++));
+
+ chr1 = (enc1 << 2) | (enc2 >> 4);
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+ chr3 = ((enc3 & 3) << 6) | enc4;
+
+ output = output + String.fromCharCode(chr1);
+
+ if (enc3 != 64) {
+ output = output + String.fromCharCode(chr2);
+ }
+ if (enc4 != 64) {
+ output = output + String.fromCharCode(chr3);
+ }
+ } while (i < input.length);
+
+ return output;
+ }
+ };
+
+ return obj;
+})();
View
15 vendor/envjs/test/call-load-test.js
@@ -0,0 +1,15 @@
+load("test/qunit.js");
+
+Envjs("test/index.html", {});
+
+test("'index.html' loaded correctly via 'Envjs()' call", function(){
+ expect(1);
+ try{ ok(document.getElementById('body').id == "body",
+ "'index.html' page content available");
+ }catch(e){print(e);}
+});
+
+test("window.location= following Envjs() initialization flagged as error",
+ function(){
+ expect(0);
+});
View
45 vendor/envjs/test/data.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env envjsrb
+load('base64.js');
+inner = "<head><title>Hello, World from a data uri!</title></head><body></body>";
+doc = "<html>"+inner+"</html>";
+url_escaped = "data:text/html,"+escape(doc);
+base64 = "data:text/html;base64,"+Base64.encode(doc);
+debug(url_escaped);
+window.location = "about:blank";
+Envjs.wait();
+window.location = url_escaped;
+Envjs.wait();
+debug(window.document.documentElement.innerHTML);
+if(window.document.documentElement.innerHTML != inner){
+ debug(window.document.documentElement.innerHTML);
+ debug(inner);
+ throw new Error(window.document.documentElement.innerHTML);
+}
+debug(base64);
+window.location = "about:blank";
+Envjs.wait();
+window.location = base64;
+Envjs.wait();
+debug(window.document.documentElement.innerHTML);
+if(window.document.documentElement.innerHTML != inner){
+ throw new Error("b"+window.document.documentElement.innerHTML);
+}
+window.location = "about:blank";
+Envjs.wait();
+window.location = "data:,"+escape("Hello, World from a data uri!");
+Envjs.wait();
+debug(window.location+"");
+debug(window.document.documentElement.innerHTML);
+inner = "<head><title></title></head><body>Hello, World from a data uri!</body>";
+if(window.document.documentElement.innerHTML != inner){
+ throw new Error("c"+window.document.documentElement.innerHTML);
+}
+
+/* not implemented yet ...
+w = open("about:blank");
+w.foo = 10;
+debug(w.foo);
+uri = "data:text/javascript;base64,"+"foo = 20;";
+w.load(uri);
+debug(w.foo);
+*/
View
53 vendor/envjs/test/debug.js
@@ -0,0 +1,53 @@
+// Init
+load("src/env.js");
+load("src/htmlparser.js");
+
+window.location = "test/index.html";
+
+window.onload = function(){
+ load("test/testrunner.js");
+ load("test/jquery.js");
+
+ var depth = 0;
+
+ function indent(){
+ var str = "";
+ for ( var i = 0; i < depth; i++ ) {
+ str += " ";
+ }
+ return str;
+ }
+
+ function dump(name, args, ret){
+ print(name + ": " + Array.prototype.slice.call(args) + " - Return: " + ret);
+ }
+
+ for ( var method in jQuery.fn ) (function(method){ if ( method != "init" ) {
+ var old = jQuery.fn[method];
+ jQuery.fn[method] = function(){
+ print(indent() + method + ": " + Array.prototype.slice.call(arguments));
+ depth++;
+ var ret = old.apply(this, arguments);
+ depth--;
+ print(indent() + method + ": Return " + ret);
+ return ret;
+ };
+ } })(method);
+
+ for ( var method in jQuery ) (function(method){ if ( method != "prototype" && method != "fn" ) {
+ var old = jQuery[method];
+ jQuery[method] = function(){
+ print(indent() + "$." + method + ": " + Array.prototype.slice.call(arguments));
+ depth++;
+ var ret = old.apply(this, arguments);
+ depth--;
+ print(indent() + "$." + method + ": Return " + ret);
+ return ret;
+ };
+ } })(method);
+
+ jQuery.prototype.toString = DOMNodeList.prototype.toString;
+ Function.prototype.toString = function(){ return "function()"; };
+
+ print("Ready.");
+};
View
BIN vendor/envjs/test/firebug/errorIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
209 vendor/envjs/test/firebug/firebug.css
@@ -0,0 +1,209 @@
+
+html, body {
+ margin: 0;
+ background: #FFFFFF;
+ font-family: Lucida Grande, Tahoma, sans-serif;
+ font-size: 11px;
+ overflow: hidden;
+}
+
+a {
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+.toolbar {
+ height: 14px;
+ border-top: 1px solid ThreeDHighlight;
+ border-bottom: 1px solid ThreeDShadow;
+ padding: 2px 6px;
+ background: ThreeDFace;
+}
+
+.toolbarRight {
+ position: absolute;
+ top: 4px;
+ right: 6px;
+}
+
+#log {
+ overflow: auto;
+ position: absolute;
+ left: 0;
+ width: 100%;
+}
+
+#commandLine {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 18px;
+ border: none;
+ border-top: 1px solid ThreeDShadow;
+}
+
+/************************************************************************************************/
+
+.logRow {
+ position: relative;
+ border-bottom: 1px solid #D7D7D7;
+ padding: 2px 4px 1px 6px;
+ background-color: #FFFFFF;
+}
+
+.logRow-command {
+ font-family: Monaco, monospace;
+ color: blue;
+}
+
+.objectBox-null {
+ padding: 0 2px;
+ border: 1px solid #666666;
+ background-color: #888888;
+ color: #FFFFFF;
+}
+
+.objectBox-string {
+ font-family: Monaco, monospace;
+ color: red;
+ white-space: pre;
+}
+
+.objectBox-number {
+ color: #000088;
+}
+
+.objectBox-function {
+ font-family: Monaco, monospace;
+ color: DarkGreen;
+}
+
+.objectBox-object {
+ color: DarkGreen;
+ font-weight: bold;
+}
+
+/************************************************************************************************/
+
+.logRow-info,
+.logRow-error,
+.logRow-warning {
+ background: #FFFFFF no-repeat 2px 2px;
+ padding-left: 20px;
+ padding-bottom: 3px;
+}
+
+.logRow-info {
+ background-image: url(infoIcon.png);
+}
+
+.logRow-warning {
+ background-color: cyan;
+ background-image: url(warningIcon.png);
+}
+
+.logRow-error {
+ background-color: LightYellow;
+ background-image: url(errorIcon.png);
+}
+
+.errorMessage {
+ vertical-align: top;
+ color: #FF0000;
+}
+
+.objectBox-sourceLink {
+ position: absolute;
+ right: 4px;
+ top: 2px;
+ padding-left: 8px;
+ font-family: Lucida Grande, sans-serif;
+ font-weight: bold;
+ color: #0000FF;
+}
+
+/************************************************************************************************/
+
+.logRow-group {
+ background: #EEEEEE;
+ border-bottom: none;
+}
+
+.logGroup {
+ background: #EEEEEE;
+}
+
+.logGroupBox {
+ margin-left: 24px;
+ border-top: 1px solid #D7D7D7;
+ border-left: 1px solid #D7D7D7;
+}
+
+/************************************************************************************************/
+
+.selectorTag,
+.selectorId,
+.selectorClass {
+ font-family: Monaco, monospace;
+ font-weight: normal;
+}
+
+.selectorTag {
+ color: #0000FF;
+}
+
+.selectorId {
+ color: DarkBlue;
+}
+
+.selectorClass {
+ color: red;
+}
+
+/************************************************************************************************/
+
+.objectBox-element {
+ font-family: Monaco, monospace;
+ color: #000088;
+}
+
+.nodeChildren {
+ margin-left: 16px;
+}
+
+.nodeTag {
+ color: blue;
+}
+
+.nodeValue {
+ color: #FF0000;
+ font-weight: normal;
+}
+
+.nodeText,
+.nodeComment {
+ margin: 0 2px;
+ vertical-align: top;
+}
+
+.nodeText {
+ color: #333333;
+}
+
+.nodeComment {
+ color: DarkGreen;
+}
+
+/************************************************************************************************/
+
+.propertyNameCell {
+ vertical-align: top;
+}
+
+.propertyName {
+ font-weight: bold;
+}
View
23 vendor/envjs/test/firebug/firebug.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+ <title>Firebug</title>
+ <link rel="stylesheet" type="text/css" href="firebug.css">
+</head>
+
+<body>
+ <div id="toolbar" class="toolbar">
+ <a href="#" onclick="parent.console.clear()">Clear</a>
+ <span class="toolbarRight">
+ <a href="#" onclick="parent.console.close()">Close</a>
+ </span>
+ </div>
+ <div id="log"></div>
+ <input type="text" id="commandLine">
+
+ <script>parent.onFirebugReady(document);</script>
+</body>
+</html>
View
672 vendor/envjs/test/firebug/firebug.js
@@ -0,0 +1,672 @@
+
+if (!("console" in window) || !("firebug" in console)) {
+(function()
+{
+ window.console =
+ {
+ log: function()
+ {
+ logFormatted(arguments, "");
+ },
+
+ debug: function()
+ {
+ logFormatted(arguments, "debug");
+ },
+
+ info: function()
+ {
+ logFormatted(arguments, "info");
+ },
+
+ warn: function()
+ {
+ logFormatted(arguments, "warning");
+ },
+
+ error: function()
+ {
+ logFormatted(arguments, "error");
+ },
+
+ assert: function(truth, message)
+ {
+ if (!truth)
+ {
+ var args = [];
+ for (var i = 1; i < arguments.length; ++i)
+ args.push(arguments[i]);
+
+ logFormatted(args.length ? args : ["Assertion Failure"], "error");
+ throw message ? message : "Assertion Failure";
+ }
+ },
+
+ dir: function(object)
+ {
+ var html = [];
+
+ var pairs = [];
+ for (var name in object)
+ {
+ try
+ {
+ pairs.push([name, object[name]]);
+ }
+ catch (exc)
+ {
+ }
+ }
+
+ pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; });
+
+ html.push('<table>');
+ for (var i = 0; i < pairs.length; ++i)
+ {
+ var name = pairs[i][0], value = pairs[i][1];
+
+ html.push('<tr>',
+ '<td class="propertyNameCell"><span class="propertyName">',
+ escapeHTML(name), '</span></td>', '<td><span class="propertyValue">');
+ appendObject(value, html);
+ html.push('</span></td></tr>');
+ }
+ html.push('</table>');
+
+ logRow(html, "dir");
+ },
+
+ dirxml: function(node)
+ {
+ var html = [];
+
+ appendNode(node, html);
+ logRow(html, "dirxml");
+ },
+
+ group: function()
+ {
+ logRow(arguments, "group", pushGroup);
+ },
+
+ groupEnd: function()
+ {
+ logRow(arguments, "", popGroup);
+ },
+
+ time: function(name)
+ {
+ timeMap[name] = (new Date()).getTime();
+ },
+
+ timeEnd: function(name)
+ {
+ if (name in timeMap)
+ {
+ var delta = (new Date()).getTime() - timeMap[name];
+ logFormatted([name+ ":", delta+"ms"]);
+ delete timeMap[name];
+ }
+ },
+
+ count: function()
+ {
+ this.warn(["count() not supported."]);
+ },
+
+ trace: function()
+ {
+ this.warn(["trace() not supported."]);
+ },
+
+ profile: function()
+ {
+ this.warn(["profile() not supported."]);
+ },
+
+ profileEnd: function()
+ {
+ },
+
+ clear: function()
+ {
+ consoleBody.innerHTML = "";
+ },
+
+ open: function()
+ {
+ toggleConsole(true);
+ },
+
+ close: function()
+ {
+ if (frameVisible)
+ toggleConsole();
+ }
+ };
+
+ // ********************************************************************************************
+
+ var consoleFrame = null;
+ var consoleBody = null;
+ var commandLine = null;
+
+ var frameVisible = false;
+ var messageQueue = [];
+ var groupStack = [];
+ var timeMap = {};
+
+ var clPrefix = ">>> ";
+
+ var isFirefox = navigator.userAgent.indexOf("Firefox") != -1;
+ var isIE = navigator.userAgent.indexOf("MSIE") != -1;
+ var isOpera = navigator.userAgent.indexOf("Opera") != -1;
+ var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1;
+
+ // ********************************************************************************************
+
+ function toggleConsole(forceOpen)
+ {
+ frameVisible = forceOpen || !frameVisible;
+ if (consoleFrame)
+ consoleFrame.style.visibility = frameVisible ? "visible" : "hidden";
+ else
+ waitForBody();
+ }
+
+ function focusCommandLine()
+ {
+ toggleConsole(true);
+ if (commandLine)
+ commandLine.focus();
+ }
+
+ function waitForBody()
+ {
+ if (document.body)
+ createFrame();
+ else
+ setTimeout(waitForBody, 200);
+ }
+
+ function createFrame()
+ {
+ if (consoleFrame)
+ return;
+
+ window.onFirebugReady = function(doc)
+ {
+ window.onFirebugReady = null;
+
+ var toolbar = doc.getElementById("toolbar");
+ toolbar.onmousedown = onSplitterMouseDown;
+
+ commandLine = doc.getElementById("commandLine");
+ addEvent(commandLine, "keydown", onCommandLineKeyDown);
+
+ addEvent(doc, isIE || isSafari ? "keydown" : "keypress", onKeyDown);
+
+ consoleBody = doc.getElementById("log");
+ layout();
+ flush();
+ }
+
+ var baseURL = getFirebugURL();
+
+ consoleFrame = document.createElement("iframe");
+ consoleFrame.setAttribute("src", baseURL+"/firebug.html");
+ consoleFrame.setAttribute("frameBorder", "0");
+ consoleFrame.style.visibility = (frameVisible ? "visible" : "hidden");
+ consoleFrame.style.zIndex = "2147483647";
+ consoleFrame.style.position = "fixed";
+ consoleFrame.style.width = "100%";
+ consoleFrame.style.left = "0";
+ consoleFrame.style.bottom = "0";
+ consoleFrame.style.height = "200px";
+ document.body.appendChild(consoleFrame);
+ }
+
+ function getFirebugURL()
+ {
+ var scripts = document.getElementsByTagName("script");
+ for (var i = 0; i < scripts.length; ++i)
+ {
+ if (scripts[i].src.indexOf("firebug.js") != -1)
+ {
+ var lastSlash = scripts[i].src.lastIndexOf("/");
+ return scripts[i].src.substr(0, lastSlash);
+ }
+ }
+ }
+
+ function evalCommandLine()
+ {
+ var text = commandLine.value;
+ commandLine.value = "";
+
+ logRow([clPrefix, text], "command");
+
+ var value;
+ try
+ {
+ value = eval(text);
+ }
+ catch (exc)
+ {
+ }
+
+ console.log(value);
+ }
+
+ function layout()
+ {
+ var toolbar = consoleBody.ownerDocument.getElementById("toolbar");
+ var height = consoleFrame.offsetHeight - (toolbar.offsetHeight + commandLine.offsetHeight);
+ consoleBody.style.top = toolbar.offsetHeight + "px";
+ consoleBody.style.height = height + "px";
+
+ commandLine.style.top = (consoleFrame.offsetHeight - commandLine.offsetHeight) + "px";
+ }
+
+ function logRow(message, className, handler)
+ {
+ if (consoleBody)
+ writeMessage(message, className, handler);
+ else
+ {
+ messageQueue.push([message, className, handler]);
+ waitForBody();
+ }
+ }