├── .gitignore ├── .jslintrbrc ├── .project ├── CHANGELOG.rdoc ├── DTD ├── xhtml-lat1.ent ├── xhtml-special.ent ├── xhtml-symbol.ent ├── xhtml.soc ├── xhtml1-frameset.dtd ├── xhtml1-strict.dtd ├── xhtml1-transitional.dtd └── xhtml1.dcl ├── Makefile ├── Manifest.txt ├── README.rdoc ├── Rakefile ├── Wakefile ├── bin ├── envjsrb ├── jquery-1.2.6-test.js ├── jquery-1.3.1-test.js ├── jquery-1.3.2-test.js ├── prototype-1.6.0.3-test.js ├── prototype_1.6.0.3_tmpl.txt ├── test-jquery.sh └── test-prototype.sh ├── build.properties ├── build.xml ├── dist ├── env-js.jar ├── env.js └── env.rhino.js ├── envjs.gemspec ├── gm ├── jquery.js ├── mainx.js ├── sensx.js ├── t.js └── x.html ├── htmlparser ├── BrowserTreeBuilder.java ├── README └── build.sh ├── jsl ├── jsl ├── jsl.default.conf └── jsl.exe ├── lib ├── envjs.rb └── envjs │ ├── event_loop.js │ ├── net.rb │ ├── net │ ├── cgi.rb │ └── file.rb │ ├── options.rb │ ├── runtime.rb │ └── tempfile.rb ├── licenses ├── GPL-LICENSE.txt └── MIT-LICENSE.txt ├── rhino ├── ant-launcher.jar ├── ant.jar ├── build.xml ├── jline-0.9.94.jar ├── js-1.7R2.jar ├── js.jar └── src │ ├── META-INF │ └── MANIFEST.MF │ └── org │ └── mozilla │ └── javascript │ └── tools │ └── envjs │ ├── Global.java │ ├── Main.java │ ├── Proxy.java │ └── Window.java ├── src ├── base64.js ├── build.js ├── cruft │ ├── bad.html │ ├── dom.js │ ├── element.js │ ├── good.html │ ├── good.js │ ├── internal.js │ └── parser.js ├── css │ ├── properties.js │ ├── rule.js │ ├── sizzle.js │ └── stylesheet.js ├── dom │ ├── attr.js │ ├── cdatasection.js │ ├── characterdata.js │ ├── comment.js │ ├── doctype.js │ ├── document.js │ ├── dom.js │ ├── element.js │ ├── entities.js │ ├── exception.js │ ├── fragment.js │ ├── implementation.js │ ├── instruction.js │ ├── namednodemap.js │ ├── namespace.js │ ├── node.js │ ├── nodelist.js │ ├── parser.js │ └── text.js ├── event │ ├── event.js │ ├── mouseevent.js │ └── uievent.js ├── html │ ├── a.js │ ├── anchor.js │ ├── area.js │ ├── base.js │ ├── blockquote-q.js │ ├── body.js │ ├── button.js │ ├── canvas.js │ ├── col-colgroup.js │ ├── collection.js │ ├── cookie.js │ ├── del-ins.js │ ├── div.js │ ├── document.js │ ├── element.js │ ├── fieldset.js │ ├── form.js │ ├── frame.js │ ├── frameset.js │ ├── head.js │ ├── html.js │ ├── htmlparser.js │ ├── iframe.js │ ├── image.js │ ├── img.js │ ├── input-elements.js │ ├── input.js │ ├── label.js │ ├── legend.js │ ├── link.js │ ├── map.js │ ├── meta.js │ ├── object.js │ ├── optgroup.js │ ├── option.js │ ├── param.js │ ├── script.js │ ├── select.js │ ├── style.js │ ├── table.js │ ├── tbody-thead-tfoot.js │ ├── td-th.js │ ├── textarea.js │ ├── title.js │ └── tr.js ├── intro.js ├── outro.js ├── parser │ ├── html5.detailed.js │ ├── html5.min.js │ ├── html5.pretty.js │ ├── intro.js │ └── outro.js ├── platform │ ├── core.js │ ├── johnson.js │ ├── rhino.js │ └── static │ │ ├── intro.js │ │ └── outro.js ├── profile │ ├── aop.js │ └── profile.js ├── serializer │ └── xml.js ├── svg │ ├── animatedstring.js │ ├── document.js │ ├── element.js │ ├── locatable.js │ ├── rect.js │ ├── rectelement.js │ ├── stylable.js │ ├── svgelement.js │ └── transformable.js ├── window │ ├── css.js │ ├── dialog.js │ ├── document.js │ ├── event.js │ ├── history.js │ ├── location.js │ ├── navigator.js │ ├── screen.js │ ├── timer.js │ ├── window.js │ └── xhr.js ├── xpath │ ├── expression.js │ ├── implementation.js │ ├── result.js │ ├── util.js │ └── xmltoken.js └── xslt │ ├── COPYING │ ├── ajaxslt-0.8.1 │ ├── AUTHORS │ ├── ChangeLog │ ├── Makefile │ ├── README │ ├── TODO │ ├── dom.js │ ├── dom_unittest.html │ ├── dom_unittest.js │ ├── simplelog.js │ ├── test │ │ ├── xpath.html │ │ ├── xpath_script.js │ │ ├── xslt.html │ │ └── xslt_script.js │ ├── unittestsuite.html │ ├── xmltoken.js │ ├── xmltoken_unittest.html │ ├── xmltoken_unittest.js │ ├── xpath_unittest.html │ ├── xpath_unittest.js │ ├── xpathdebug.js │ ├── xslt_unittest.html │ └── xslt_unittest.js │ ├── implementation.js │ ├── processor.js │ └── util.js └── test ├── base64.js ├── call-load-test.js ├── data.js ├── debug.js ├── firebug ├── errorIcon.png ├── firebug.css ├── firebug.html ├── firebug.js ├── firebugx.js ├── infoIcon.png └── warningIcon.png ├── fixtures ├── html │ ├── events.html │ ├── iframe1.html │ ├── iframe1a.html │ ├── iframe2.html │ ├── iframe3.html │ ├── iframeN.html │ ├── malformed.html │ ├── scope.html │ ├── trivial.html │ └── with_js.html ├── images │ └── icon-blue.png └── js │ ├── external_script.js │ ├── script.js │ └── script_error.js ├── foo.html ├── foo.js ├── html ├── events.html ├── iframe1.html ├── iframe1a.html ├── iframe2.html ├── iframe3.html ├── iframeN.html ├── malformed.html ├── scope.html ├── script.js ├── trivial.html └── with_js.html ├── index.html ├── java-prototype.js ├── jquery.js ├── primary-tests.js ├── prototype-test.js ├── qunit.js ├── qunit └── qunit │ ├── qunit.css │ └── qunit.js ├── scope.html ├── scope.rb ├── smp ├── dm.html ├── dm.js ├── dmathieu │ └── index.html ├── doc.html ├── doc.js ├── doc │ ├── doc.html │ ├── doc.js │ ├── if.js │ ├── iframe.html │ ├── iframe1.html │ └── iframe2.html ├── if.js ├── iframe.html ├── iframe1.html └── iframe2.html ├── specs ├── dist │ └── env.spec.js ├── envjs.spec.css ├── parser │ ├── html.js │ ├── spec.html │ └── xml.js ├── qunit.bdd.js ├── qunit.css ├── qunit.js ├── template │ ├── spec-0.js │ ├── spec-1.js │ └── spec.html ├── window │ ├── css.js │ ├── dialog.js │ ├── document.js │ ├── event.js │ ├── history.js │ ├── location.js │ ├── navigator.js │ ├── screen.js │ ├── spec.html │ ├── timer.js │ └── window.js └── xhr │ ├── spec.html │ └── xhr.js ├── test.js ├── unit ├── dom.js ├── elementmembers.js ├── events.js ├── fixtures │ └── external_script.js ├── form.js ├── iframe.js ├── insertion.js ├── multi-window.js ├── nu.validator.js ├── onload.js ├── parser.js ├── prototypecompat.js ├── proxy.js ├── scope.js ├── timer.js └── window.js ├── vendor ├── jQuery │ ├── .gitignore │ └── README └── prototype-1.6.0.3.js ├── x.js └── y.js /.gitignore: -------------------------------------------------------------------------------- 1 | /dist/env.*.*.*.js 2 | /dist/env.rhino.*.*.*.js 3 | /dist/env-js.*.jar 4 | *~ 5 | /dist/env.johnson.js 6 | /lib/envjs/env.js 7 | /lib/envjs/static.js 8 | /rhino/build 9 | /jshost 10 | /htmlparser/gwt* 11 | /htmlparser/html5 12 | /htmlparser/build 13 | /pkg 14 | /.wake -------------------------------------------------------------------------------- /.jslintrbrc: -------------------------------------------------------------------------------- 1 | { "indent": 2, 2 | "predef": [ "DOMDocument", 3 | "DOMElement", 4 | "SVGRect", 5 | "SVGRectElement", 6 | "SVGSVGElement", 7 | "$w", 8 | "__extend__", 9 | "Ruby", 10 | "debug", 11 | "print", 12 | "window", 13 | "document", 14 | "setTimeout", 15 | "load", 16 | "getFreshScopeObj", 17 | "getProxyFor", 18 | "$env", 19 | "$debug" 20 | ], 21 | "white": false, 22 | "onevar": false, 23 | "nomen": false, 24 | "regexp": false, 25 | "plusplus": false, 26 | "strict": false, 27 | "eqeqeq": false, 28 | "evil": true, 29 | "gettersetter": true 30 | } 31 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | env-js 4 | 5 | 6 | 7 | 8 | 9 | org.rubypeople.rdt.core.rubybuilder 10 | 11 | 12 | 13 | 14 | 15 | org.rubypeople.rdt.core.rubynature 16 | 17 | 18 | -------------------------------------------------------------------------------- /CHANGELOG.rdoc: -------------------------------------------------------------------------------- 1 | === 0.3.8 / 2010-09-14 2 | 3 | * don't use static variable in cookie processing 4 | * return name() lower case in html 5 | * update url even when only hash change 6 | * don't error out trying to remove event that doesn't exist (orslumen) 7 | * When serializing multipart/form-data forms we need a pair of \r\n between the boundary and headers and the data value. Not just one. [Murray Steele] 8 | * Fix for http://github.com/smparkes/env-js/issues/issue/19 [fiann] 9 | * rejigger things so the xml parser works on XHR requests; pretty much just moving code 10 | * add some dimensions that query ui needs to (barely) function 11 | * include document ref in defaultView 12 | * add some properties that help d&d simulation 13 | 14 | === 0.3.7 / 2010-07-05 15 | 16 | * Add support for https (heathkit) 17 | * allow inserting 61 | 62 |
63 | 64 | 65 | 66 |
67 |
68 | 69 | 70 | 71 |
72 | 73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /htmlparser/README: -------------------------------------------------------------------------------- 1 | Envjs make use the awesome project 'http://about.validator.nu/htmlparser/' 2 | which generates an HTML5 compliant parsing engine, written in Java, into 3 | javascript via GWT. 4 | 5 | The generated files are available in 6 | env-js/ 7 | src/ 8 | parser/ 9 | html5.js 10 | html5.min.js 11 | html5.detailed.js 12 | 13 | The various versions are simply generated with varying verbosity of source. 14 | html.js is the most readable at 60KB, html.detailed.js is almost too verbose at 15 | over 120KB, and finally html5.min.js is totally unreadable but weighs in at only 16 | 30KB. By default the html5.min.js is included in Envjs releases because most 17 | folks aren't too worried about the gory details of the parser. 18 | 19 | The scripts in this folder can be used to checkout and download the various 20 | components you will need to generate these yourself. 21 | 22 | Once generated, there are a couple very small and specific changes that must be 23 | made by hand to allow the parser to be initialized with the usual GWT hooks. 24 | 25 | You will need to download the appropiate gwt for your platform 26 | 27 | http://google-web-toolkit.googlecode.com/files/gwt-mac-1.5.1.tar.gz 28 | http://google-web-toolkit.googlecode.com/files/gwt-windows-1.5.1.zip 29 | http://google-web-toolkit.googlecode.com/files/gwt-linux-1.5.1.tar.bz2 30 | 31 | Our scripts expect that it will be available at 32 | env-js/ 33 | htmlparser/ 34 | gwt-1.5.1/ -------------------------------------------------------------------------------- /htmlparser/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | svn co https://whattf.svn.cvsdude.com/htmlparser/trunk/ html5 4 | 5 | cp BrowserTreeBuilder.java html5/gwt-src/nu/validator/htmlparser/gwt/BrowserTreeBuilder.java 6 | 7 | cp gwt-1.5.1/gwt-dev-*.jar gwt-1.5.1/gwt-dev.jar 8 | 9 | APPDIR=`dirname $0`/html5/; 10 | 11 | echo $APPDIR 12 | 13 | echo "Generating Minified HTMLParser" 14 | java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -out "build/min" "$@" nu.validator.htmlparser.HtmlParser; 15 | cp ./build/min/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.min.js 16 | perl -pi~ -e "s/if\(j\.addEventListener\)(.*)50\)/\/\*envjsedit\*\//" ./build/html5.min.js 17 | perl -pi~ -e "s/if\(j\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.min.js 18 | perl -pi~ -e "s/function kb\(\)/\/\*envjsedit\*\/var kb = Html5Parser = function\(\)/" ./build/html5.min.js 19 | 20 | echo "Generating Pretty HTMLParser" 21 | java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -style PRETTY -out "build/pretty" "$@" nu.validator.htmlparser.HtmlParser; 22 | cp ./build/pretty/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.pretty.js 23 | perl -pi~ -e "s/if(.*)\((.*)doc_0\.addEventListener\)/\/\*envjsedit/s" ./build/html5.pretty.js 24 | perl -pi~ -e "s/,\s50\);/envjsedit\*\//s" ./build/html5.pretty.js 25 | perl -pi~ -e "s/if(.*)\((.*)doc_0\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.pretty.js 26 | perl -pi~ -e "s/function onBodyDone\(\)/\/\*envjsedit\*\/var onBodyDone = Html5Parser = function\(\)/" ./build/html5.pretty.js 27 | 28 | echo "Generating Detailed HTMLParser" 29 | java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -style DETAILED -out "build/detailed" "$@" nu.validator.htmlparser.HtmlParser; 30 | cp ./build/detailed/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.detailed.js 31 | perl -pi~ -e "s/if(.*)\((.*)doc\.addEventListener\)/\/\*envjsedit/s" ./build/html5.detailed.js 32 | perl -pi~ -e "s/,\s50\);/envjsedit\*\//s" ./build/html5.detailed.js 33 | perl -pi~ -e "s/if(.*)\((.*)doc\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.detailed.js 34 | perl -pi~ -e "s/function onBodyDone\(\)/\/\*envjsedit\*\/var onBodyDone = Html5Parser = function\(\)/" ./build/html5.detailed.js 35 | 36 | rm ./build/*.js~ 37 | 38 | cp ./build/html5.*.js ../src/parser/ 39 | -------------------------------------------------------------------------------- /jsl/jsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/jsl/jsl -------------------------------------------------------------------------------- /jsl/jsl.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/jsl/jsl.exe -------------------------------------------------------------------------------- /lib/envjs.rb: -------------------------------------------------------------------------------- 1 | module Envjs 2 | 3 | VERSION = "0.3.8" 4 | 5 | def self.js_exception_stack e 6 | result = %(Exception: )+e.to_s 7 | e.stack.to_s.split(%(\n)).each do |line| 8 | next if line == "@:0" 9 | m = line.match(/(.*)@([^@]*)$/) 10 | s = m[1] 11 | limit = 50 12 | if ( s.length > limit ) 13 | s = s[0,limit] + %(...) 14 | end 15 | result += "\n" + m[2]+%( )+s 16 | end 17 | result 18 | end 19 | 20 | ENVJS = 21 | File.expand_path( File.join( File.dirname(__FILE__), 22 | "envjs", 23 | "env.js" ) ) 24 | 25 | EVENT_LOOP = 26 | File.expand_path( File.join( File.dirname(__FILE__), 27 | "envjs", 28 | "event_loop.js" ) ) 29 | 30 | STATIC = 31 | File.expand_path( File.join( File.dirname(__FILE__), 32 | "envjs", 33 | "static.js" ) ) 34 | 35 | end 36 | -------------------------------------------------------------------------------- /lib/envjs/net.rb: -------------------------------------------------------------------------------- 1 | require 'envjs' 2 | 3 | module Envjs::Net; end 4 | -------------------------------------------------------------------------------- /lib/envjs/net/cgi.rb: -------------------------------------------------------------------------------- 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 95 | -------------------------------------------------------------------------------- /lib/envjs/net/file.rb: -------------------------------------------------------------------------------- 1 | require 'net/protocol' 2 | 3 | require 'envjs/net' 4 | 5 | class Envjs::Net::File < Net::Protocol 6 | 7 | class Get 8 | attr_accessor :path 9 | def initialize path 10 | @path = path 11 | end 12 | end 13 | 14 | def initialize host, port 15 | end 16 | 17 | def self.start host, port 18 | new( host, port ).start 19 | end 20 | 21 | def start 22 | self 23 | end 24 | 25 | def finish 26 | end 27 | 28 | def request request 29 | Response.new request.path 30 | end 31 | 32 | class Response 33 | def initialize path 34 | @path = path 35 | @file = File.new @path 36 | @body = @file.read 37 | @code = @file.nil? ? "404" : "200"; 38 | @file.close 39 | end 40 | 41 | def [] *args 42 | nil 43 | end 44 | 45 | def each &block 46 | end 47 | 48 | def getHeaderFields 49 | [] 50 | end 51 | 52 | def getContentEncoding 53 | nil 54 | end 55 | 56 | def getResponseCode 57 | @file.nil? ? 404 : 200; 58 | end 59 | 60 | 61 | def getInputStream 62 | self 63 | end 64 | 65 | attr_reader :body, :code 66 | 67 | end 68 | 69 | end 70 | -------------------------------------------------------------------------------- /lib/envjs/options.rb: -------------------------------------------------------------------------------- 1 | require 'optparse' 2 | 3 | $envjsrb_wake = false 4 | 5 | OptionParser.new do |o| 6 | 7 | o.on("--wake") do |path| 8 | $envjsrb_wake = true 9 | end 10 | 11 | end.parse! 12 | -------------------------------------------------------------------------------- /lib/envjs/tempfile.rb: -------------------------------------------------------------------------------- 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 25 | -------------------------------------------------------------------------------- /licenses/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 John Resig, http://jquery.com/ 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /rhino/ant-launcher.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/rhino/ant-launcher.jar -------------------------------------------------------------------------------- /rhino/ant.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/rhino/ant.jar -------------------------------------------------------------------------------- /rhino/jline-0.9.94.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/rhino/jline-0.9.94.jar -------------------------------------------------------------------------------- /rhino/js-1.7R2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/rhino/js-1.7R2.jar -------------------------------------------------------------------------------- /rhino/js.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/rhino/js.jar -------------------------------------------------------------------------------- /rhino/src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: org.mozilla.javascript.tools.envjs.Main 3 | -------------------------------------------------------------------------------- /rhino/src/org/mozilla/javascript/tools/envjs/Global.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a component of env.js, 3 | * http://github.com/gleneivey/env-js/commits/master/README 4 | * a Pure JavaScript Browser Environment 5 | * Copyright 2009 John Resig, licensed under the MIT License 6 | * http://www.opensource.org/licenses/mit-license.php 7 | * 8 | * Contributed by Glen E. Ivey 9 | */ 10 | 11 | 12 | package org.mozilla.javascript.tools.envjs; 13 | 14 | import java.lang.reflect.Field; 15 | import java.lang.reflect.Method; 16 | import org.mozilla.javascript.Context; 17 | import org.mozilla.javascript.NativeArray; 18 | 19 | 20 | public class Global extends org.mozilla.javascript.tools.shell.Global 21 | { 22 | 23 | public Global(org.mozilla.javascript.tools.shell.Global parentSharedScope) 24 | { 25 | this.setPrototype(parentSharedScope); 26 | this.setParentScope(null); 27 | } 28 | 29 | public void init(Context cx) 30 | { 31 | // we don't init, but make sure our parent is 32 | org.mozilla.javascript.tools.shell.Global uberGlobal = 33 | (org.mozilla.javascript.tools.shell.Global) this.getPrototype(); 34 | if (!uberGlobal.isInitialized()) 35 | uberGlobal.init(cx); 36 | 37 | // shell.Global uses some package-scope instance variables, so... 38 | Class klass = org.mozilla.javascript.tools.shell.Global.class; 39 | 40 | try { 41 | 42 | // we don't want to run super.init(), but accesses to shell.Global's 43 | // history member don't go through JS' prototype chain, so we 44 | // initialize it "by hand" 45 | Field hist = klass.getDeclaredField("history"); 46 | hist.setAccessible(true); 47 | if (hist.get(this) == null) 48 | hist.set(this, (NativeArray) cx.newArray(this, 0)); 49 | 50 | // some users of Global access .initialized directly (bad 51 | // class, bad!) so we set it in the base class rather 52 | // than over-riding isInitialized 53 | Field inited = klass.getDeclaredField("initialized"); 54 | inited.setAccessible(true); 55 | inited.setBoolean(this, true); 56 | } 57 | catch (Exception ex){ // probably NoSuchField or IllegaAccess 58 | throw Context.reportRuntimeError( 59 | "Got a fatal exception when attempting to initialize " + 60 | "the shell.Global object. Original error message is: " + 61 | ex.getMessage()); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /rhino/src/org/mozilla/javascript/tools/envjs/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a component of env.js, 3 | * http://github.com/gleneivey/env-js/commits/master/README 4 | * a Pure JavaScript Browser Environment 5 | * Copyright 2009 John Resig, licensed under the MIT License 6 | * http://www.opensource.org/licenses/mit-license.php 7 | * 8 | * Contributed by Glen E. Ivey 9 | */ 10 | 11 | 12 | package org.mozilla.javascript.tools.envjs; 13 | 14 | 15 | public class Main extends org.mozilla.javascript.tools.shell.Main 16 | { 17 | 18 | private static class Quitter implements 19 | org.mozilla.javascript.tools.shell.QuitAction 20 | { 21 | public void quit(org.mozilla.javascript.Context cx, int exitCode) 22 | { 23 | System.exit(exitCode); 24 | } 25 | } 26 | 27 | static 28 | { 29 | // replace the generic Global object, instantiated in 30 | // Main.java's static initializer, with our extended version 31 | 32 | Window window = new Window(); 33 | // not calling global.initQuitAction() Doesn't matter because env.js 34 | // doesn't call the "quit" JS method provided by the Rhino shell app 35 | 36 | 37 | // now, create a new empty object to serve as the execution 38 | // context's "global", and change the preceding "global" 39 | // object into a cross-environment, uber-global object see 40 | // "Sharing Scopes" in 41 | // https://developer.mozilla.org/En/Rhino_documentation/Scopes_and_Contexts 42 | global = new Global(window); 43 | global.initQuitAction(new Quitter()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/build.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Envjs @VERSION@ 3 | * Pure JavaScript Browser Environment 4 | * By John Resig 5 | * Copyright 2008-2009 John Resig, under the MIT License 6 | */ -------------------------------------------------------------------------------- /src/cruft/bad.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World 4 | 6 | 8 | "); 12 | 13 | 14 | 15 |

hello world!

16 |
17 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /src/cruft/good.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | Hello World 8 | 9 | 11 | 18 | 19 | 20 |

hello world!

21 |
22 |
    23 |
  • item 1
  • 24 |
  • item 2
  • 25 |
  • item 3 link to another 26 | page!
  • 27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/cruft/good.js: -------------------------------------------------------------------------------- 1 | { 2 | "html":{ 3 | "$xmlns" : "http://www.w3.org/1999/xhtml", 4 | "$xmlns$xml": "http://www.w3.org/XML/1998/namespace", 5 | "$lang" : "en", 6 | "$xml$lang" : "en", 7 | "head":{ 8 | "meta":{ 9 | "$name" : "generator", 10 | "$content" : "HTML Tidy for Mac OS X (vers 1st July 2004), see www.w3.org" 11 | }, 12 | "title":"Hello World", 13 | "meta":[null,null], 14 | "script":{ 15 | "$type" : "text/javascript", 16 | '$':["// document.write(\" 9 | 11 | 13 | 15 | 17 | 18 | 19 | 20 | This is a jsUnit test 21 | page. Run it using the jsUnit runner. 23 | 24 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/simplelog.js: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2006 Google 2 | // 3 | // Author: Steffen Meschkat 4 | // 5 | // A very simple logging facility, used in test/xpath.html. 6 | 7 | var logging__ = true; 8 | 9 | function Log() {}; 10 | 11 | Log.lines = []; 12 | 13 | Log.write = function(s) { 14 | if (logging__) { 15 | this.lines.push(xmlEscapeText(s)); 16 | this.show(); 17 | } 18 | }; 19 | 20 | // Writes the given XML with every tag on a new line. 21 | Log.writeXML = function(xml) { 22 | if (logging__) { 23 | var s0 = xml.replace(/'); 26 | this.lines.push(s2); 27 | this.show(); 28 | } 29 | } 30 | 31 | // Writes without any escaping 32 | Log.writeRaw = function(s) { 33 | if (logging__) { 34 | this.lines.push(s); 35 | this.show(); 36 | } 37 | } 38 | 39 | Log.clear = function() { 40 | if (logging__) { 41 | var l = this.div(); 42 | l.innerHTML = ''; 43 | this.lines = []; 44 | } 45 | } 46 | 47 | Log.show = function() { 48 | var l = this.div(); 49 | l.innerHTML += this.lines.join('
') + '
'; 50 | this.lines = []; 51 | l.scrollTop = l.scrollHeight; 52 | } 53 | 54 | Log.div = function() { 55 | var l = document.getElementById('log'); 56 | if (!l) { 57 | l = document.createElement('div'); 58 | l.id = 'log'; 59 | l.style.position = 'absolute'; 60 | l.style.right = '5px'; 61 | l.style.top = '5px'; 62 | l.style.width = '250px'; 63 | l.style.height = '150px'; 64 | l.style.overflow = 'auto'; 65 | l.style.backgroundColor = '#f0f0f0'; 66 | l.style.border = '1px solid gray'; 67 | l.style.fontSize = '10px'; 68 | l.style.padding = '5px'; 69 | document.body.appendChild(l); 70 | } 71 | return l; 72 | } 73 | 74 | // Reimplement the log functions from util.js to use the simple log. 75 | function xpathLog(msg) { 76 | Log.write(msg); 77 | }; 78 | function xsltLog(msg) {}; 79 | function xsltLogXml(msg) {}; 80 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/test/xpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/test/xpath_script.js: -------------------------------------------------------------------------------- 1 | // Copyright 2005 Google Inc. 2 | // All Rights Reserved 3 | // 4 | // Tests for the XPath parser. To run the test, open the file from the 5 | // file system. No server support is required. 6 | // 7 | // 8 | // Author: Steffen Meschkat 9 | 10 | logging = true; 11 | xpathdebug = true; 12 | 13 | function load_expr() { 14 | var s = document.getElementById('s'); 15 | for (var i = 0; i < expr.length; ++i) { 16 | var o = new Option(expr[i].replace(/>/,'>').replace(/</,'<')); 17 | s.options[s.options.length] = o; 18 | } 19 | s.selectedIndex = 0; 20 | } 21 | 22 | function xpath_test(form) { 23 | Log.clear(); 24 | try { 25 | var i = form.cases.selectedIndex; 26 | var options = form.cases.options; 27 | 28 | var text = options[i].value; 29 | Log.writeRaw('' + text + ''); 30 | 31 | var expr = xpathParse(text); 32 | Log.writeRaw('' + text + ''); 33 | Log.writeRaw('
' + expr.parseTree('') + '
'); 34 | 35 | options[i].selected = false; 36 | if (i < options.length - 1) { 37 | options[i+1].selected = true; 38 | } else { 39 | options[0].selected = true; 40 | } 41 | 42 | } catch (e) { 43 | Log.write('EXCEPTION ' + e); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/test/xslt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Simple XSLT test 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 25 | 40 | 41 | 42 | 45 | 46 | 47 | 51 | 54 | 55 |
17 | 24 | 26 | 39 |
43 | 44 |
48 | 50 | 52 |
53 |
56 |
57 | 58 | 59 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/test/xslt_script.js: -------------------------------------------------------------------------------- 1 | // Copyright 2005 Google Inc. 2 | // All Rights Reserved 3 | // 4 | // Tests for the XSLT processor. To run the test, open the file from 5 | // the file system. No server support is required. 6 | // 7 | // 8 | // Author: Steffen Meschkat 9 | 10 | logging = true; 11 | xsltdebug = true; 12 | 13 | function el(id) { 14 | return document.getElementById(id); 15 | } 16 | 17 | function test_xslt() { 18 | var xml = xmlParse(el('xml').value); 19 | var xslt = xmlParse(el('xslt').value); 20 | var html = xsltProcess(xml, xslt); 21 | el('html').value = html; 22 | el('htmldisplay').innerHTML = html; 23 | } 24 | 25 | function cleanxml() { 26 | cleanvalue('xml'); 27 | cleanvalue('xslt'); 28 | } 29 | 30 | function cleanvalue(id) { 31 | var x = el(id); 32 | x.value = x.value.replace(/^\s*/, '').replace(/\n\s*/g, '\n'); 33 | } 34 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/unittestsuite.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | AJAXSLT Test Suite 7 | 9 | 11 | 13 | 24 | 25 | AJAXSLT Test Suite 26 | 27 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | JsUnit test page for file xmltoken.js of goog-ajaxslt 7 | 9 | 11 | 13 | 14 | 15 | 16 | JsUnit test page for file xmltoken.js of goog-ajaxslt. 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/xpath_unittest.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | JsUnit test page for file xpath.js of goog-ajaxslt 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 22 | 23 | 24 | This is a jsUnit test 25 | page. Run it using the jsUnit runner. 27 | 28 | 29 | 30 |
31 |
test1
32 | javascript href with spaces 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/xslt/ajaxslt-0.8.1/xslt_unittest.js: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Unit test for the XSLT processor. 5 | // 6 | // Author: Steffen Meschkat 7 | 8 | //******************************************** 9 | // DGF BEWARE! You MUST update this function if you add tests! 10 | //******************************************** 11 | function exposeTestFunctionNames() { 12 | return ['testForEachSort', 'testForEachSortAscending', 'testForEachSortDescending', 'testApplyTemplates', 'testGlobalVariables', 'testTopLevelOutput', 'testCopy']; 13 | } 14 | 15 | function el(id) { 16 | return document.getElementById(id); 17 | } 18 | 19 | function testForEachSort() { 20 | var xml = xmlParse(el('xml').value); 21 | var xslt = xmlParse(el('xslt-for-each-sort').value); 22 | var html = xsltProcess(xml, xslt); 23 | assertEquals("CAB", html); 24 | } 25 | 26 | function testForEachSortAscending() { 27 | var xml = xmlParse(el('xml').value); 28 | var xslt = xmlParse(el('xslt-for-each-sort-ascending').value); 29 | var html = xsltProcess(xml, xslt); 30 | assertEquals("ABC", html); 31 | } 32 | 33 | function testForEachSortDescending() { 34 | var xml = xmlParse(el('xml').value); 35 | var xslt = xmlParse(el('xslt-for-each-sort-descending').value); 36 | var html = xsltProcess(xml, xslt); 37 | assertEquals("CBA", html); 38 | } 39 | 40 | function testApplyTemplates() { 41 | var xml = xmlParse(el('xml-apply-templates').value); 42 | var xslt = xmlParse(el('xslt-apply-templates').value); 43 | var html = xsltProcess(xml, xslt); 44 | assertEquals("ABC", html); 45 | } 46 | 47 | function testGlobalVariables() { 48 | var xml = xmlParse(el('xml').value); 49 | var xslt = xmlParse(el('xslt-global-variables').value); 50 | var html = xsltProcess(xml, xslt); 51 | assertEquals("xzyyy", html); 52 | } 53 | 54 | function testTopLevelOutput() { 55 | var xml = xmlParse(el('xml').value); 56 | var xslt = xmlParse(el('xslt-top-level-output').value); 57 | var html = xsltProcess(xml, xslt); 58 | assertEquals('k', html); 59 | } 60 | 61 | function testCopy() { 62 | var xml = xmlParse(el('xml').value); 63 | var xslt = xmlParse(el('xslt-copy').value); 64 | var html = xsltProcess(xml, xslt); 65 | assertEquals('A' + 66 | 'B' + 67 | 'C', html); 68 | } 69 | -------------------------------------------------------------------------------- /src/xslt/processor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | $w.__defineGetter__("XSLTProcessor", function(){ 6 | return new XSLTProcessor(arguments); 7 | }); 8 | 9 | var XSLTProcessor = function() { 10 | this.__stylesheet__ = null; 11 | }; 12 | __extend__(XSLTProcessor.prototype, { 13 | clearParameters: function(){ 14 | //TODO 15 | }, 16 | getParameter: function(nsuri, name){ 17 | //TODO 18 | }, 19 | importStyleSheet: function(stylesheet){ 20 | this.__stylesheet__ = stylesheet; 21 | }, 22 | removeParameter: function(nsuri, name){ 23 | //TODO 24 | }, 25 | reset: function(){ 26 | //TODO 27 | }, 28 | setParameter: function(nsuri, name, value){ 29 | //TODO 30 | }, 31 | transformToDocument: function(sourceNode){ 32 | return xsltProcess(sourceNode, this.__stylesheet__); 33 | }, 34 | transformToFragment: function(sourceNode, ownerDocument){ 35 | return xsltProcess(sourceNode, this.__stylesheet__).childNodes; 36 | } 37 | }); -------------------------------------------------------------------------------- /test/call-load-test.js: -------------------------------------------------------------------------------- 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 | }); 16 | -------------------------------------------------------------------------------- /test/data.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env envjsrb 2 | load('base64.js'); 3 | inner = "Hello, World from a data uri!"; 4 | doc = ""+inner+""; 5 | url_escaped = "data:text/html,"+escape(doc); 6 | base64 = "data:text/html;base64,"+Base64.encode(doc); 7 | debug(url_escaped); 8 | window.location = "about:blank"; 9 | Envjs.wait(); 10 | window.location = url_escaped; 11 | Envjs.wait(); 12 | debug(window.document.documentElement.innerHTML); 13 | if(window.document.documentElement.innerHTML != inner){ 14 | debug(window.document.documentElement.innerHTML); 15 | debug(inner); 16 | throw new Error(window.document.documentElement.innerHTML); 17 | } 18 | debug(base64); 19 | window.location = "about:blank"; 20 | Envjs.wait(); 21 | window.location = base64; 22 | Envjs.wait(); 23 | debug(window.document.documentElement.innerHTML); 24 | if(window.document.documentElement.innerHTML != inner){ 25 | throw new Error("b"+window.document.documentElement.innerHTML); 26 | } 27 | window.location = "about:blank"; 28 | Envjs.wait(); 29 | window.location = "data:,"+escape("Hello, World from a data uri!"); 30 | Envjs.wait(); 31 | debug(window.location+""); 32 | debug(window.document.documentElement.innerHTML); 33 | inner = "Hello, World from a data uri!"; 34 | if(window.document.documentElement.innerHTML != inner){ 35 | throw new Error("c"+window.document.documentElement.innerHTML); 36 | } 37 | 38 | /* not implemented yet ... 39 | w = open("about:blank"); 40 | w.foo = 10; 41 | debug(w.foo); 42 | uri = "data:text/javascript;base64,"+"foo = 20;"; 43 | w.load(uri); 44 | debug(w.foo); 45 | */ -------------------------------------------------------------------------------- /test/debug.js: -------------------------------------------------------------------------------- 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 | }; 54 | -------------------------------------------------------------------------------- /test/firebug/errorIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/test/firebug/errorIcon.png -------------------------------------------------------------------------------- /test/firebug/firebug.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Firebug 8 | 9 | 10 | 11 | 12 |
13 | Clear 14 | 15 | Close 16 | 17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/firebug/firebugx.js: -------------------------------------------------------------------------------- 1 | 2 | if (!("console" in window) || !("firebug" in console)) 3 | { 4 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", 5 | "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; 6 | 7 | window.console = {}; 8 | for (var i = 0; i < names.length; ++i) 9 | window.console[names[i]] = function() {} 10 | } -------------------------------------------------------------------------------- /test/firebug/infoIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/test/firebug/infoIcon.png -------------------------------------------------------------------------------- /test/firebug/warningIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/test/firebug/warningIcon.png -------------------------------------------------------------------------------- /test/fixtures/html/iframe1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 13 | 14 | Content document for IFRAME element in env.js unit test suite 15 | 16 | 17 |

18 | This is the text content of a paragraph element. 19 |

20 | 21 | 22 | 26 | 27 | 35 | 36 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/fixtures/html/iframe1a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 13 | 14 | Content document 'iframe1a.html' for env.js unit test suite 15 | 16 | 17 | 18 | This is the text content of a block-quote element. 19 | 20 | 21 | 22 | 26 | 27 | 35 | 36 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/fixtures/html/iframe2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 14 | 15 | Content document for IFRAME loading in env.js unit test suite 16 | 17 | 18 |

19 | Here is a short paragraph. 20 |

21 | 22 |

2

23 |

24 | The preceding is the seed value for the automatic iframe-nesting 25 | count generation in iframeN.html, used by the nesting 26 | test in ../unit/frame.js. Value must be equal to the 27 | test's 'startingDepth' variable, minus 1, for things to work. 28 |

29 | 30 | 31 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/fixtures/html/iframe3.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 14 | 15 | Content document for nested-IFRAME testing in env.js 16 | 17 | 18 |

19 | First paragraph in iframe.3.html. 20 |

21 | 22 | 23 | 24 |

25 | Last paragraph in iframe.3.html. 26 |

27 | 28 | 29 | -------------------------------------------------------------------------------- /test/fixtures/html/iframeN.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 14 | 15 | Document for testing arbitrary-depth IFRAME nesting in env.js 16 | 17 | 18 | 41 | 42 |

43 | This document will be loaded into an IFRAME, and the following 44 | JavaScript finds an element in the parent document that contains 45 | the nesting level count, increments it, and then produces an 46 | identical element with the result in this document. 47 | 48 | 55 |

56 | 57 | 58 | -------------------------------------------------------------------------------- /test/fixtures/html/trivial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 13 | 14 | Nearly-empty HTML page 15 | 16 | 17 |

Nearly-empty HTML page

18 | 19 | 20 | -------------------------------------------------------------------------------- /test/fixtures/html/with_js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 |

Hello, "World"!

11 | 12 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/fixtures/images/icon-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smparkes/env-js/0a5606be96b0914de095c7946ec8c70b75f33939/test/fixtures/images/icon-blue.png -------------------------------------------------------------------------------- /test/fixtures/js/external_script.js: -------------------------------------------------------------------------------- 1 | var $$$$$ = "12345"; 2 | -------------------------------------------------------------------------------- /test/fixtures/js/script.js: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- /test/fixtures/js/script_error.js: -------------------------------------------------------------------------------- 1 | // 2 | true = false; -------------------------------------------------------------------------------- /test/foo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hello, world 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/foo.js: -------------------------------------------------------------------------------- 1 | debug = this.debug || ( console.log && function(f){console.log(f)} ) || console.debug; 2 | $(function(){ 3 | $("
").appendTo(document.body); 4 | $("#xx").get(0).innerHTML = 5 | " 26 | 27 | 35 | 36 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/html/iframe1a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 13 | 14 | Content document 'iframe1a.html' for env.js unit test suite 15 | 16 | 17 | 18 | This is the text content of a block-quote element. 19 | 20 | 21 | 22 | 26 | 27 | 35 | 36 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/html/iframe2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 14 | 15 | Content document for IFRAME loading in env.js unit test suite 16 | 17 | 18 |

19 | Here is a short paragraph. 20 |

21 | 22 |

2

23 |

24 | The preceding is the seed value for the automatic iframe-nesting 25 | count generation in iframeN.html, used by the nesting 26 | test in ../unit/frame.js. Value must be equal to the 27 | test's 'startingDepth' variable, minus 1, for things to work. 28 |

29 | 30 | 31 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/html/iframe3.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 14 | 15 | Content document for nested-IFRAME testing in env.js 16 | 17 | 18 |

19 | First paragraph in iframe.3.html. 20 |

21 | 22 | 24 | 25 | 26 |

27 | Last paragraph in iframe.3.html. 28 |

29 | 30 | 31 | -------------------------------------------------------------------------------- /test/html/iframeN.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 14 | 15 | Document for testing arbitrary-depth IFRAME nesting in env.js 16 | 17 | 18 | 41 | 42 |

43 | This document will be loaded into an IFRAME, and the following 44 | JavaScript finds an element in the parent document that contains 45 | the nesting level count, increments it, and then produces an 46 | identical element with the result in this document. 47 | 48 | 55 |

56 | 57 | 58 | -------------------------------------------------------------------------------- /test/html/script.js: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- /test/html/trivial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 13 | 14 | Nearly-empty HTML page 15 | 16 | 17 |

Nearly-empty HTML page

18 | 19 | 20 | -------------------------------------------------------------------------------- /test/html/with_js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 |

Hello, "World"!

11 | 12 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/java-prototype.js: -------------------------------------------------------------------------------- 1 | if(!this.whichJarFile){ 2 | whichJarFile = "rhino" 3 | } 4 | whichInterpreter = whichJarFile + " interpreter jar"; 5 | if(!this.multiwindow){ 6 | multiwindow = false; 7 | } 8 | load("dist/env.rhino.js"); 9 | load("prototype.js"); 10 | -------------------------------------------------------------------------------- /test/primary-tests.js: -------------------------------------------------------------------------------- 1 | load("test/qunit.js"); 2 | 3 | window.addEventListener("load",function(){ 4 | print("\n\nTesting with " + whichInterpreter); 5 | print("Handling onload for test.js"); 6 | print("Loading tests."); 7 | 8 | load("test/unit/dom.js"); 9 | load("test/unit/window.js"); 10 | load("test/unit/elementmembers.js"); 11 | load("test/unit/insertion.js"); 12 | if (multiwindow) { 13 | load("test/unit/onload.js"); 14 | load("test/unit/scope.js"); // must come before frame.js changes page content 15 | load("test/unit/iframe.js"); 16 | load("test/unit/events.js"); 17 | load("test/unit/multi-window.js"); 18 | } 19 | load("test/unit/parser.js"); 20 | load("test/unit/timer.js"); 21 | load("test/unit/form.js"); 22 | 23 | print("Load complete. Running tests."); 24 | }); 25 | 26 | window.location = "test/index.html"; 27 | -------------------------------------------------------------------------------- /test/prototype-test.js: -------------------------------------------------------------------------------- 1 | load("test/qunit.js"); 2 | 3 | window.addEventListener("load",function(){ 4 | print("\n\nTesting with " + whichInterpreter); 5 | print("Handling onload for test.js"); 6 | print("Loading tests."); 7 | 8 | load("test/unit/prototypecompat.js"); 9 | 10 | print("Load complete. Running tests."); 11 | }); 12 | 13 | window.location = "test/index.html"; 14 | -------------------------------------------------------------------------------- /test/qunit.js: -------------------------------------------------------------------------------- 1 | load("test/qunit/qunit/qunit.js"); 2 | 3 | (function(){ 4 | var assertion_index = 0; 5 | 6 | var module_index = 0; 7 | var module; 8 | 9 | var test_index = 0; 10 | var test; 11 | 12 | QUnit.moduleStart = function(m,te) { 13 | module = m; 14 | module_index++; 15 | }; 16 | 17 | QUnit.moduleDone = function(t,f,tx) { 18 | var s = module_index + ". module "+t+": "; 19 | if ( f ) { 20 | s += f + " failure(s) in " + tx + " tests"; 21 | } else { 22 | s += "all " + tx + " tests successful"; 23 | } 24 | // print(s); 25 | module = undefined; 26 | }; 27 | 28 | QUnit.testStart = function(t) { 29 | test = t; 30 | test_index++; 31 | }; 32 | 33 | QUnit.testDone = function(t) { 34 | test = undefined; 35 | } 36 | 37 | QUnit.log = function(r,m) { 38 | assertion_index++; 39 | var test_string = ""; 40 | if ( module || test ) { 41 | var test_string = "["; 42 | if ( module ) { 43 | test_string += module; 44 | if ( test ) { 45 | test_string += ": "; 46 | } 47 | } 48 | if ( test ) { 49 | test_string += test; 50 | } 51 | test_string += "] "; 52 | } 53 | var s = ( r ? "PASS (" : "FAIL (" ) + assertion_index + ") " + test_string + m; 54 | print(s); 55 | }; 56 | 57 | QUnit.done = function(f,t) { 58 | print((t-f) + " Passed, " + f + " Failed, " + t + " Total Tests" ); 59 | }; 60 | 61 | })(QUnit); 62 | -------------------------------------------------------------------------------- /test/qunit/qunit/qunit.css: -------------------------------------------------------------------------------- 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; } 18 | -------------------------------------------------------------------------------- /test/scope.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/scope.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'rubygems' 3 | require 'johnson/tracemonkey' 4 | require 'envjs/runtime' 5 | 6 | require 'nanotest' 7 | include Nanotest 8 | 9 | rt = Johnson::Runtime.new 10 | rt.extend(Envjs::Runtime) 11 | 12 | rt.evaluate("var foo = 10"); 13 | assert { rt.evaluate("foo") == 10 } 14 | 15 | rt.evaluate('window.location = "http://example.com"') 16 | assert { 'Example Web Page' == rt.evaluate('window.document.title') } 17 | assert { 'Example Web Page' == rt.evaluate('this.document.title') } 18 | assert { 'Example Web Page' == rt.evaluate('document.title') } 19 | 20 | rt.evaluate('window.location = "http://montrealrb.org"') 21 | assert { 'Montreal.rb' == rt.evaluate('window.document.title') } 22 | assert { 'Montreal.rb' == rt.evaluate('this.document.title') } 23 | 24 | assert { 'Example Web Page' == rt.evaluate('document.title') } 25 | -------------------------------------------------------------------------------- /test/smp/dm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/smp/dm.js: -------------------------------------------------------------------------------- 1 | jQuery(function(){ 2 | debug("0",jQuery('#select')[0].innerHTML); 3 | jQuery('#select')[0].selectedIndex = 1; 4 | debug("1",jQuery('#select')[0].innerHTML); 5 | jQuery('#select').change(); 6 | debug("2",jQuery('#select')[0].innerHTML); 7 | }); -------------------------------------------------------------------------------- /test/smp/dmathieu/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Click me ! 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/smp/doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/smp/doc.js: -------------------------------------------------------------------------------- 1 | // console.debug("doc"); 2 | setTimeout(function(){ 3 | // console.debug("to"); 4 | var ifd = document.getElementById("if").contentWindow.document; 5 | // console.debug(ifd); 6 | var q = ifd.poke(); 7 | console.debug("q",q,q.myl); 8 | console.debug(document.getElementById("if").contentWindow === q); 9 | setTimeout(function() { 10 | document.getElementById("if").contentWindow.location = "iframe2.html"; 11 | setTimeout(function(){ 12 | var y = ifd.poke(); 13 | console.debug("qy",q === y); 14 | console.debug("q",q,q.myl,q === document.getElementById("if").contentWindow); 15 | console.debug("y",y,y.myl,y === document.getElementById("if").contentWindow); 16 | document.getElementById("if").contentWindow.document.poke(); 17 | },2000); 18 | },2000); 19 | },1000); 20 | -------------------------------------------------------------------------------- /test/smp/doc/doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/smp/doc/doc.js: -------------------------------------------------------------------------------- 1 | // console.debug("doc"); 2 | setTimeout(function(){ 3 | // console.debug("to"); 4 | var ifd = document.getElementById("if").contentWindow.document; 5 | // console.debug(ifd); 6 | ifd.poke(); 7 | setTimeout(function() { 8 | document.getElementById("if").contentWindow.location = "iframe2.html"; 9 | setTimeout(function(){ 10 | ifd.poke(); 11 | document.getElementById("if").contentWindow.document.poke(); 12 | },2000); 13 | },2000); 14 | },1000); 15 | -------------------------------------------------------------------------------- /test/smp/doc/if.js: -------------------------------------------------------------------------------- 1 | console.debug("if"); 2 | window.myl = document.location+""; 3 | (function(){ 4 | document.poke = function() { 5 | alert([myl,window.location+"",window,window.document,document,window.document===document]+""); 6 | }; 7 | }()); -------------------------------------------------------------------------------- /test/smp/doc/iframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/smp/doc/iframe1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/smp/doc/iframe2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/smp/if.js: -------------------------------------------------------------------------------- 1 | console.debug("if"); 2 | window.myl = document.location+""; 3 | old_global = (function(){return this;}()); 4 | document.poke = function() { 5 | var global = (function(){return this;}()); 6 | console.debug([myl,window.location+"",window,window.document,document,window.document===document, 7 | global.document === document]+"",global,window===global,global===old_global); 8 | return global; 9 | }; 10 | -------------------------------------------------------------------------------- /test/smp/iframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/smp/iframe1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/smp/iframe2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/specs/envjs.spec.css: -------------------------------------------------------------------------------- 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 | } -------------------------------------------------------------------------------- /test/specs/parser/html.js: -------------------------------------------------------------------------------- 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 | 32 | -------------------------------------------------------------------------------- /test/specs/parser/spec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Envjs HTML5 Parser Spec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

19 | 22 | Envjs HTML5 Parser Spec 23 |

24 |

25 |
26 |
27 |
    28 |
    29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /test/specs/parser/xml.js: -------------------------------------------------------------------------------- 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); -------------------------------------------------------------------------------- /test/specs/qunit.css: -------------------------------------------------------------------------------- 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; } 18 | -------------------------------------------------------------------------------- /test/specs/template/spec-0.js: -------------------------------------------------------------------------------- 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('provide the required w3c interfaces', 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 | 32 | -------------------------------------------------------------------------------- /test/specs/template/spec-1.js: -------------------------------------------------------------------------------- 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); -------------------------------------------------------------------------------- /test/specs/template/spec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TEMPLATE Spec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

    19 | 22 | Envjs TEMPLATE Spec 23 |

    24 |

    25 |
    26 |
    27 |
      28 |
      29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /test/specs/window/css.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | (function(Q){ 5 | 6 | Q.describe('Window CSS',{ 7 | 8 | before:function(){ 9 | //setup 10 | }, 11 | after:function(){ 12 | //tear down 13 | } 14 | 15 | }).should('provide the required w3c interfaces', function(){ 16 | 17 | expect(1); 18 | ok(window.getComputedStyle, 'window.getComputedStyle'); 19 | 20 | }); 21 | 22 | })(QUnit); 23 | 24 | -------------------------------------------------------------------------------- /test/specs/window/dialog.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | (function(Q){ 6 | 7 | Q.describe('Window Dialog',{ 8 | 9 | before:function(){ 10 | //setup 11 | }, 12 | after:function(){ 13 | //tear down 14 | } 15 | 16 | }).should('provide the required w3c interfaces', function(){ 17 | 18 | expect(3); 19 | ok(alert, 'alert'); 20 | ok(confirm, 'confirm'); 21 | ok(prompt, 'prompt'); 22 | 23 | }); 24 | 25 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/window/document.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | (function(Q){ 6 | 7 | Q.describe('Window Document',{ 8 | 9 | before:function(){ 10 | //setup 11 | }, 12 | after:function(){ 13 | //tear down 14 | } 15 | 16 | }).should('provide the required w3c interfaces', function(){ 17 | 18 | expect(1); 19 | ok(window.document === document, 'document is window.document'); 20 | 21 | }); 22 | 23 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/window/event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | (function(Q){ 6 | 7 | Q.describe('Window Event',{ 8 | 9 | before:function(){ 10 | //setup 11 | }, 12 | after:function(){ 13 | //tear down 14 | } 15 | 16 | }).should('provide the required w3c interfaces', function(){ 17 | 18 | expect(3); 19 | ok(addEventListener, 'addEventListener'); 20 | ok(removeEventListener, 'removeEventListener'); 21 | ok(dispatchEvent, 'dispatchEvent'); 22 | 23 | }) 24 | 25 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/window/history.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | (function(Q){ 6 | 7 | Q.describe('Window History',{ 8 | 9 | before:function(){ 10 | //setup 11 | }, 12 | after:function(){ 13 | //tear down 14 | } 15 | 16 | }).should('provide the required w3c interfaces', function(){ 17 | 18 | expect(8); 19 | ok(history === window.history, "history is window.history"); 20 | ok(history.length, 'history.length'); 21 | ok(history.back, 'history.back'); 22 | ok(history.forward, 'history.forward'); 23 | ok(history.go, 'history.go'); 24 | ok(history.item, 'history.item'); 25 | 26 | //these are generally secured properties of the history 27 | //object so we only check that the are defined since 28 | //trying to access them will throw an exception 29 | ok('current' in history, 'history.current'); 30 | ok('previous' in history, 'history.previous'); 31 | 32 | }); 33 | 34 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/window/location.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | (function(Q){ 6 | 7 | Q.describe('Window Location',{ 8 | 9 | before:function(){ 10 | //setup 11 | }, 12 | after:function(){ 13 | //tear down 14 | } 15 | 16 | }).should('provide required w3c interfaces', function(){ 17 | 18 | expect(12); 19 | ok(location === window.location, "location is window.location"); 20 | ok('href' in location, 'location.href'); 21 | ok('hash' in location, 'location.hash'); 22 | ok('host' in location, 'location.host'); 23 | ok('hostname' in location, 'location.hostname'); 24 | ok('pathname' in location, 'location.pathname'); 25 | ok('port' in location, 'location.port'); 26 | ok('search' in location, 'location.search'); 27 | ok(location.protocol, 'location.protocol'); 28 | ok(location.reload, 'location.reload'); 29 | ok(location.replace, 'location.replace'); 30 | ok(location.assign, 'location.assign'); 31 | 32 | }); 33 | 34 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/window/screen.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | (function(Q){ 5 | 6 | Q.describe('Window Screen',{ 7 | 8 | before:function(){ 9 | //setup 10 | }, 11 | after:function(){ 12 | //tear down 13 | } 14 | 15 | }).should('provide the required w3c interfaces', function(){ 16 | 17 | expect(18); 18 | ok(screen === window.screen , 'screen is window screen'); 19 | ok("top" in screen, 'top'); 20 | ok(screen.height, 'height'); 21 | ok(screen.width, 'width'); 22 | ok("left" in screen, 'left'); 23 | ok(screen.pixelDepth, 'pixelDepth'); 24 | ok(screen.colorDepth, 'colorDepth'); 25 | ok(screen.availWidth, 'availWidth'); 26 | ok(screen.availHeight, 'availHeight'); 27 | ok("availLeft" in screen, 'availLeft'); 28 | ok(screen.availTop, 'availTop'); 29 | 30 | //closely related function available at window 31 | ok(moveBy, 'moveBy'); 32 | ok(moveTo, 'moveTo'); 33 | ok(resizeBy, 'resizeBy'); 34 | ok(resizeTo, 'resizeTo'); 35 | ok(scroll, 'scroll'); 36 | ok(scrollBy, 'scrollBy'); 37 | ok(scrollTo, 'scrollTo'); 38 | 39 | }); 40 | 41 | })(QUnit); 42 | 43 | -------------------------------------------------------------------------------- /test/specs/window/spec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Envjs Window Spec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |

      27 | 30 | Envjs Window Spec 31 |

      32 |

      33 |
      34 |
      35 |
        36 |
        37 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/specs/window/timer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | (function(Q){ 6 | 7 | Q.describe('Window Timer',{ 8 | 9 | before:function(){ 10 | //setup 11 | }, 12 | after:function(){ 13 | //tear down 14 | } 15 | 16 | }).should('provide the required w3c interfaces', function(){ 17 | 18 | expect(4); 19 | ok(setTimeout, 'setTimeout'); 20 | ok(setInterval, 'setInterval'); 21 | ok(clearTimeout, 'clearTimeout'); 22 | ok(clearInterval, 'clearInterval'); 23 | 24 | }); 25 | 26 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/window/window.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | var global_scope=this; 5 | 6 | (function(Q){ 7 | 8 | Q.describe('Window Basic Properties',{ 9 | 10 | before:function(){ 11 | //setup 12 | }, 13 | after:function(){ 14 | //tear down 15 | } 16 | 17 | }).should('provide the required w3c interfaces', function(){ 18 | 19 | expect(19); 20 | ok(window, 'window'); 21 | ok(self, 'self'); 22 | ok(top, 'top'); 23 | ok(parent, 'parent'); 24 | ok(window.toString(), '[object Window]'); 25 | 26 | //these values are usually the empty string '' 27 | //so we just verify the property is available 28 | ok('name' in window, 'name'); 29 | ok('status' in window, 'status'); 30 | ok('closed' in window, 'closed'); 31 | ok('defaultStatus' in window, 'defaultStatus'); 32 | ok('length' in window, 'length'); 33 | ok('opener' in window, 'opener'); 34 | 35 | ok(frames, 'frames'); 36 | ok(open, 'open'); 37 | ok(close, 'close'); 38 | ok(innerHeight, 'innerHeight'); 39 | ok(outerHeight, 'outerHeight'); 40 | ok(outerWidth, 'outerWidth'); 41 | ok(screenX, 'screenX'); 42 | ok(screenY, 'screenY'); 43 | 44 | 45 | }).should('have the expected values', function(){ 46 | 47 | equals( window, global_scope, 'window is the global scope "this"'); 48 | equals( window, self, 'self is an alias for window'); 49 | equals( window, top, 'top is an alias for window when the window is not in a frame'); 50 | 51 | }); 52 | 53 | })(QUnit); -------------------------------------------------------------------------------- /test/specs/xhr/spec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Envjs Window Spec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |

        26 | 29 | Envjs Window Spec 30 |

        31 |

        32 |
        33 |
        34 |
          35 |
          36 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /test/specs/xhr/xhr.js: -------------------------------------------------------------------------------- 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); -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | whichJarFile = arguments[0]; 2 | whichTestFile = arguments[1]; 3 | 4 | multiwindow = !(whichJarFile == "rhino"); 5 | whichInterpreter = whichJarFile + " interpreter jar"; 6 | 7 | load("dist/env.rhino.js"); 8 | load("test/" + whichTestFile + ".js"); 9 | 10 | Envjs.wait(); 11 | -------------------------------------------------------------------------------- /test/unit/dom.js: -------------------------------------------------------------------------------- 1 | // dependencies for the tests 2 | $w = { } 3 | $env = { debug: function() {} } 4 | $openingWindow = $parentWindow = $initTop = null; 5 | this.options = this.options || {} 6 | 7 | load("src/window/window.js", "src/dom/node.js"); 8 | 9 | debugger; 10 | module("dom"); 11 | 12 | test("Basic requirements", function() { 13 | expect(5); 14 | ok( Array.prototype.push, "Array.push()" ); 15 | ok( Function.prototype.apply, "Function.apply()" ); 16 | ok( document.getElementById, "getElementById" ); 17 | ok( document.getElementsByTagName, "getElementsByTagName" ); 18 | ok( RegExp, "RegExp" ); 19 | }); 20 | 21 | 22 | test("document.getElementById", function() { 23 | expect(14); 24 | try{ok (document.getElementById('body').id == "body", "Can get Element by id, expected id='body'");}catch(e){print(e);} 25 | try{ok (document.getElementById('header').id == "header", "Can get Element by id, expected id='header'");}catch(e){print(e);} 26 | try{ok (document.getElementById('banner').id == "banner", "Can get Element by id, expected id='banner'");}catch(e){print(e);} 27 | try{ok (document.getElementById('userAgent').id == "userAgent", "Can get Element by id, expected id='userAgent'");}catch(e){print(e);} 28 | try{ok (document.getElementById('nothiddendiv').id == "nothiddendiv", "Can get Element by id, expected id='nothiddendiv'");}catch(e){print(e);} 29 | try{ok (document.getElementById('nothiddendivchild').id == "nothiddendivchild", "Can get Element by id, expected id='nothiddendivchild'");}catch(e){print(e);} 30 | try{ok (document.getElementById('dl').id == "dl", "Can get Element by id, expected id='dl'");}catch(e){print(e);} 31 | try{ok (document.getElementById('main').id == "main", "Can get Element by id, expected id='main'");}catch(e){print(e);} 32 | try{ok (document.getElementById('firstp').id == "firstp", "Can get Element by id, expected id='firstp");}catch(e){print(e);} 33 | try{ok (document.getElementById('simon1').id == "simon1", "Can get Element by id, expected id='simon1'");}catch(e){print(e);} 34 | try{ok (document.getElementById('ap').id == "ap", "Can get Element by id, expected id='ap'");}catch(e){print(e);} 35 | try{ok (document.getElementById('google').id == "google", "Can get Element by id, expected id='google'");}catch(e){print(e);} 36 | try{ok (document.getElementById('groups').id == "groups", "Can get Element by id, expected id='groups'");}catch(e){print(e);} 37 | try{ok (document.getElementById('台北Táiběi').id == "台北Táiběi", "Can get Element by UTF-8 id, expected id='台北Táiběi'");}catch(e){print(e);} 38 | }); 39 | 40 | test("element.getElementsByTagName", function() { 41 | expect(1); 42 | var body = document.getElementById('body'); 43 | try{ok (body.getElementsByTagName('h1').length == 1, "Can get NodeList length : Expected 1 , Got " + body.getElementsByTagName('h1').length);}catch(e){print(e);} 44 | }); 45 | -------------------------------------------------------------------------------- /test/unit/fixtures/external_script.js: -------------------------------------------------------------------------------- 1 | var $$$$$ = "12345"; -------------------------------------------------------------------------------- /test/unit/insertion.js: -------------------------------------------------------------------------------- 1 | module("insertion"); 2 | 3 | test("inserting SELECT elements with multiple='multiple' should not raise an error", function() { 4 | expect(3); 5 | var div = document.createElement('div'); 6 | var html = ""; 7 | ok(div.innerHTML = html, html); 8 | var select = document.createElement('select'); 9 | var x; 10 | try { 11 | select.type = "foo"; 12 | }catch(e){ 13 | x = e; 14 | } 15 | ok(x !== void(0), "should not allow setting type"); 16 | x = void(0); 17 | try { 18 | select.setAttribute("type","foo"); 19 | }catch(e){ 20 | x = e; 21 | } 22 | ok(x !== void(0), "should not allow setting type via setAttribute"); 23 | }); 24 | -------------------------------------------------------------------------------- /test/unit/nu.validator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author thatcher 3 | */ 4 | 5 | load('dist/env.rhino.js'); 6 | 7 | window.location = 'test/html/malformed.html'; 8 | 9 | 10 | var fixture = document.xml, 11 | testhtml = '

          abc', 12 | testfragment = '

          this is apig
          oink oink!', 13 | success = function(){ 14 | print(doc.xml); 15 | }; 16 | 17 | var doc; 18 | //Envjs.logLevel = Envjs.DEBUG; 19 | doc = new DOMParser().parseFromString(testhtml); 20 | print(doc.xml); 21 | 22 | 23 | doc.body.innerHTML = testfragment; 24 | print(doc.xml); 25 | 26 | 27 | /* 28 | var start = new Date().getTime(); 29 | for(var i=0;i<1000;i++){ 30 | parseHtmlDocument(trivial, document, null, null); 31 | } 32 | var stop = new Date().getTime(); 33 | print("1000 parses "+(stop-start)); 34 | */ 35 | -------------------------------------------------------------------------------- /test/unit/prototypecompat.js: -------------------------------------------------------------------------------- 1 | //FYI: shipped with Rails 2.2.2 2 | load("test/vendor/prototype-1.6.0.3.js"); 3 | 4 | module("prototypecompat"); 5 | 6 | test("$ method", function(){ 7 | expect(1); 8 | equals($("header"), document.getElementById("header")); 9 | }); 10 | 11 | test("$$ method", function(){ 12 | expect(1); 13 | ok($$(".chain").length == 10, "$$ found correct number of elements"); 14 | }); 15 | 16 | // When this failing test passes, ticket #69 can be closed. 17 | // (http://envjs.lighthouseapp.com/projects/21590-envjs/tickets/69-prototypes-down-method-is-unavailable) 18 | // 19 | test("down method", function(){ 20 | expect(1); 21 | ok($('main').down('#foo') != undefined, "$('main').down('#foo') successfully found an element"); 22 | }); 23 | -------------------------------------------------------------------------------- /test/unit/proxy.js: -------------------------------------------------------------------------------- 1 | module("proxy"); 2 | 3 | test("something", function() { 4 | expect(1); 5 | ok(true,"something"); 6 | }); 7 | -------------------------------------------------------------------------------- /test/unit/window.js: -------------------------------------------------------------------------------- 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 | }); 42 | 43 | test("Allows to change the window.location.hash parameter w/o hash", function() { 44 | expect(1); 45 | try { 46 | window.location.hash = 'test'; 47 | ok(window.location.hash === '#test'); 48 | }catch(e){print(e);} 49 | }); 50 | 51 | test("Allows to change the window.location.hash parameter w/hash", function() { 52 | expect(1); 53 | try { 54 | window.location.hash = '#test'; 55 | ok(window.location.hash === '#test'); 56 | }catch(e){print(e);} 57 | }); -------------------------------------------------------------------------------- /test/vendor/jQuery/.gitignore: -------------------------------------------------------------------------------- 1 | *.*.* 2 | -------------------------------------------------------------------------------- /test/vendor/jQuery/README: -------------------------------------------------------------------------------- 1 | Note: To avoid adding to Git an entire jQuery development tree for each tag we want to test, 2 | the bin/test-jquery.sh script will checkout the tag into this directory. -------------------------------------------------------------------------------- /test/x.js: -------------------------------------------------------------------------------- 1 | debug("**"); -------------------------------------------------------------------------------- /test/y.js: -------------------------------------------------------------------------------- 1 | debug("**2"); --------------------------------------------------------------------------------