smparkes-envjs 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/README +101 -0
  2. data/bin/envjsrb +147 -0
  3. data/bin/jquery-1.2.6-test.js +33 -0
  4. data/bin/jquery-1.3.1-test.js +33 -0
  5. data/bin/jquery-1.3.2-test.js +98 -0
  6. data/bin/prototype-1.6.0.3-test.js +82 -0
  7. data/bin/prototype_1.6.0.3_tmpl.txt +27 -0
  8. data/bin/test-jquery.sh +58 -0
  9. data/bin/test-prototype.sh +54 -0
  10. data/bin/tidy +0 -0
  11. data/lib/envjs/env.js +10423 -0
  12. data/lib/envjs/net/file.rb +71 -0
  13. data/lib/envjs/net.rb +3 -0
  14. data/lib/envjs/runtime.rb +132 -0
  15. data/lib/envjs/runtime.rb.smp +133 -0
  16. data/lib/envjs/tempfile.rb +24 -0
  17. data/lib/envjs.rb +23 -0
  18. data/test/call-load-test.js +17 -0
  19. data/test/debug.js +53 -0
  20. data/test/envjs-call-load-test.js +3 -0
  21. data/test/envjs-prototype.js +3 -0
  22. data/test/html/events.html +171 -0
  23. data/test/html/iframe1.html +46 -0
  24. data/test/html/iframe1a.html +46 -0
  25. data/test/html/iframe2.html +45 -0
  26. data/test/html/iframe3.html +30 -0
  27. data/test/html/iframeN.html +57 -0
  28. data/test/html/scope.html +87 -0
  29. data/test/html/trivial.html +19 -0
  30. data/test/html/with_js.html +26 -0
  31. data/test/index.html +304 -0
  32. data/test/java-prototype.js +9 -0
  33. data/test/primaryTests.js +26 -0
  34. data/test/prototype.js +15 -0
  35. data/test/qunit/package.json +21 -0
  36. data/test/qunit/qunit/qunit.css +17 -0
  37. data/test/qunit/qunit/qunit.js +997 -0
  38. data/test/qunit/qunit/qunit.js.smp +1002 -0
  39. data/test/qunit/test/index.html +17 -0
  40. data/test/qunit/test/same.js +1368 -0
  41. data/test/qunit/test/test.js +136 -0
  42. data/test/qunit.js +61 -0
  43. data/test/qunit.smp/package.json +21 -0
  44. data/test/qunit.smp/qunit/qunit.css +17 -0
  45. data/test/qunit.smp/qunit/qunit.js +997 -0
  46. data/test/qunit.smp/test/index.html +17 -0
  47. data/test/qunit.smp/test/same.js +1368 -0
  48. data/test/qunit.smp/test/test.js +136 -0
  49. data/test/rhino-call-load-test.js +5 -0
  50. data/test/test-with-envs-jar.js +8 -0
  51. data/test/test-with-rhino-jar.js +9 -0
  52. data/test/unit/dom.js +43 -0
  53. data/test/unit/elementmembers.js +29 -0
  54. data/test/unit/events.js +195 -0
  55. data/test/unit/fixtures/external_script.js +1 -0
  56. data/test/unit/iframe.js +234 -0
  57. data/test/unit/multi-window.js +212 -0
  58. data/test/unit/onload.js +82 -0
  59. data/test/unit/parser.js +113 -0
  60. data/test/unit/prototypecompat.js +22 -0
  61. data/test/unit/proxy.js +6 -0
  62. data/test/unit/scope.js +209 -0
  63. data/test/unit/timer.js +115 -0
  64. data/test/unit/window.js +41 -0
  65. data/test/vendor/jQuery/README +2 -0
  66. data/test/vendor/prototype-1.6.0.3.js +4320 -0
  67. metadata +130 -0
@@ -0,0 +1,71 @@
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
+ class Response
29
+ def initialize path
30
+ @path = path
31
+ @file = File.new @path
32
+ @body = @file.read
33
+ @file.close
34
+ end
35
+
36
+ def [] *args
37
+ nil
38
+ end
39
+
40
+ def each &block
41
+ end
42
+
43
+ def getHeaderFields
44
+ []
45
+ end
46
+
47
+ def getContentEncoding
48
+ nil
49
+ end
50
+
51
+ def getResponseCode
52
+ @file.nil? ? 404 : 200;
53
+ end
54
+
55
+ def code
56
+ @file.nil? ? "404" : "200";
57
+ end
58
+
59
+ def getInputStream
60
+ self
61
+ end
62
+
63
+ attr_reader :body
64
+
65
+ end
66
+
67
+ def request request
68
+ Response.new request.path
69
+ end
70
+
71
+ end
data/lib/envjs/net.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'envjs'
2
+
3
+ module Envjs::Net; end
@@ -0,0 +1,132 @@
1
+ require 'envjs'
2
+ require "open-uri"
3
+
4
+ module Envjs::Runtime
5
+
6
+ def self.extended object
7
+ object.instance_eval do
8
+
9
+ evaluate <<'EOJS'
10
+ print = function() {
11
+ var l = arguments.length
12
+ for( var i = 0; i < l; i++ ) {
13
+ var s;
14
+ if ( arguments[i] === null ) {
15
+ s = "null";
16
+ } else if ( arguments[i] === undefined ) {
17
+ s = "undefined"
18
+ } else {
19
+ s = arguments[i].toString();
20
+ }
21
+ Ruby.print(s);
22
+ if( i < l-1 ) {
23
+ Ruby.print(" ");
24
+ }
25
+ }
26
+ Ruby.print("\n");
27
+ };
28
+ EOJS
29
+
30
+ evaluate <<'EOJS'
31
+ puts = function() {
32
+ var l = arguments.length
33
+ for( var i = 0; i < l; i++ ) {
34
+ var s;
35
+ if ( arguments[i] === null ) {
36
+ s = "null";
37
+ } else if ( arguments[i] === undefined ) {
38
+ s = "undefined"
39
+ } else {
40
+ s = arguments[i].toString();
41
+ }
42
+ Ruby.print(s);
43
+ Ruby.eval("$stdout.flush")
44
+ }
45
+ };
46
+ EOJS
47
+
48
+ master = global["$master"] = evaluate("new Object")
49
+ master.symbols = [ "Johnson", "Ruby", "print", "puts", "load", "whichInterpreter", "multiwindow" ]
50
+ master.symbols.each { |symbol| master[symbol] = global[symbol] }
51
+
52
+ master.whichInterpreter = "Johnson"
53
+
54
+ master.multiwindow = true
55
+
56
+ # calling this from JS is hosed; the ruby side is confused, maybe because HTTPHeaders is mixed in?
57
+ master.add_req_field = lambda { |r,k,v| r.add_field(k,v) }
58
+
59
+ master.load = lambda { |*files|
60
+ if files.length == 2 && !(String === files[1])
61
+ f = files[0]
62
+ w = files[1]
63
+ v = open(f).read.gsub(/\A#!.*$/, '')
64
+ evaluate(v, f, 1, w, w, f)
65
+ else
66
+ load *files
67
+ end
68
+ }
69
+
70
+ master.evaluate = lambda { |v,w|
71
+ evaluate(v,"inline",1,w,w);
72
+ }
73
+
74
+ master.new_split_global_outer = lambda { new_split_global_outer }
75
+ master.new_split_global_inner = lambda { |outer,_| new_split_global_inner outer }
76
+
77
+ # create an proto window object and proxy
78
+
79
+ outer = new_split_global_outer
80
+ window = inner = new_split_global_inner( outer )
81
+
82
+ master.symbols.each do |symbol|
83
+ window[symbol] = master[symbol]
84
+ end
85
+
86
+ master.first_script_window = window
87
+
88
+ window["$master"] = master
89
+
90
+ window.load = lambda { |*files|
91
+ files.each do |f|
92
+ master.load.call f, window
93
+ end
94
+ }
95
+
96
+ ( class << self; self; end ).send :define_method, :wait do
97
+ master["finalize"] && master.finalize.call
98
+ master.timers && master.timers.wait
99
+ end
100
+
101
+ scripts = {}
102
+
103
+ ( class << self; self; end ).send :define_method, :evaluate do |*args|
104
+ ( script, file, line, global, scope, fn ) = *args
105
+ # print "eval in " + script[0,50].inspect + (scope ? scope.toString() : "nil") + "\n"
106
+ global = nil
107
+ scope ||= inner
108
+ if fn
109
+ compiled_script = scripts[fn]
110
+ end
111
+ # compiled_script = compile(script, file, line, global)
112
+ compiled_script ||= compile(script, file, line, global)
113
+ if fn && !scripts[fn]
114
+ scripts[fn] = compiled_script
115
+ end
116
+ evaluate_compiled_script(compiled_script,scope)
117
+ end
118
+
119
+ @envjs = inner
120
+
121
+ ( class << self; self; end ).send :define_method, :"[]" do |key|
122
+ key == "this" && evaluate("this") || @envjs[key]
123
+ end
124
+
125
+ ( class << self; self; end ).send :define_method, :"[]=" do |k,v|
126
+ @envjs[k] = v
127
+ end
128
+
129
+ end
130
+ end
131
+
132
+ end
@@ -0,0 +1,133 @@
1
+ require 'envjs'
2
+
3
+ module Envjs::Runtime
4
+
5
+ def self.extended object
6
+ object.instance_eval do
7
+
8
+ @outer = {} # ||= new_split_global_outer
9
+ @inner = {} # ||= new_split_global_inner( @outer )
10
+
11
+ @inner["Johnson"] = global["Johnson"]
12
+ @inner["Ruby"] = global["Ruby"]
13
+
14
+ evaluate <<'EOJS'
15
+ print = function() {
16
+ var l = arguments.length
17
+ for( var i = 0; i < l; i++ ) {
18
+ var s;
19
+ if ( arguments[i] === null ) {
20
+ s = "null";
21
+ } else if ( arguments[i] === undefined ) {
22
+ s = "undefined"
23
+ } else {
24
+ s = arguments[i].toString();
25
+ }
26
+ Ruby.print(s);
27
+ if( i < l-1 ) {
28
+ Ruby.print(" ");
29
+ }
30
+ }
31
+ Ruby.print("\n");
32
+ };
33
+ EOJS
34
+
35
+ @inner["print"] = global["print"]
36
+
37
+ ( class << self; self; end ).send :define_method, :evaluate do |*args|
38
+ ( script, file, line, global, scope ) = *args
39
+ g ||= @inner
40
+ s ||= @inner
41
+ p "super"
42
+ super( script, file, line, g, s )
43
+ end
44
+
45
+
46
+ # self.global = outer
47
+
48
+ return
49
+
50
+ evaluate <<'EOJS'
51
+ print = function() {
52
+ var l = arguments.length
53
+ for( var i = 0; i < l; i++ ) {
54
+ var s;
55
+ if ( arguments[i] === null ) {
56
+ s = "null";
57
+ } else if ( arguments[i] === undefined ) {
58
+ s = "undefined"
59
+ } else {
60
+ s = arguments[i].toString();
61
+ }
62
+ Ruby.print(s);
63
+ if( i < l-1 ) {
64
+ Ruby.print(" ");
65
+ }
66
+ }
67
+ Ruby.print("\n");
68
+ };
69
+ EOJS
70
+
71
+ master = global["$master"] = evaluate("new Object")
72
+ master.symbols = [ "Johnson", "Ruby", "print", "load", "whichInterpreter", "multiwindow" ]
73
+ # master.symbols = [ "Johnson", "whichInterpreter" ]
74
+ master.symbols.each { |symbol| master[symbol] = global[symbol] }
75
+
76
+ master.whichInterpreter = "Johnson"
77
+
78
+ if true
79
+
80
+ master.multiwindow = true
81
+
82
+ master.load = lambda { |*files| load *files }
83
+
84
+ master.evaluate = lambda { |script|
85
+ return evaluate(script, nil, nil, master["inner"], master["inner"])
86
+ }
87
+
88
+ master.global = lambda { global }
89
+
90
+ master.new_global = lambda { new_global }
91
+
92
+ master.set_global = lambda { |target, s| self.global = target }
93
+
94
+ master._new_proxy = lambda { |target| new_proxy target }
95
+ master._set_proxy_target = lambda { |proxy, target| set_proxy_target proxy, target }
96
+
97
+ master.new_split_global_outer = lambda { new_split_global_outer }
98
+ master.new_split_global_inner = lambda { |outer,_| new_split_global_inner outer }
99
+
100
+
101
+ end
102
+
103
+ # create an proto window object and proxy
104
+
105
+ outer = master["outer"] = new_split_global_outer
106
+ window = inner = master["inner"] = new_split_global_inner( outer )
107
+
108
+ master.symbols.each do |symbol|
109
+ window[symbol] = master[symbol]
110
+ end
111
+
112
+ master.first_script_window = window
113
+
114
+ window["$master"] = master
115
+
116
+ self.global = outer
117
+
118
+ ( class << self; self; end ).send :define_method, :wait do
119
+ master["finalize"] && master.finalize.call
120
+ end
121
+
122
+ ( class << self; self; end ).send :define_method, :evaluate do |*args|
123
+ ( script, file, line, global, scope ) = *args
124
+ global ||= inner
125
+ scope ||= inner
126
+ p "super"
127
+ super( script, file, line, global, scope )
128
+ end
129
+
130
+ end
131
+ end
132
+
133
+ end
@@ -0,0 +1,24 @@
1
+ require 'tempfile'
2
+
3
+ require 'envjs'
4
+
5
+ class Envjs::TempFile < Tempfile
6
+
7
+ def initialize pattern, suffix = nil
8
+ super(pattern)
9
+
10
+
11
+ if suffix
12
+ new_path = path + "." + suffix
13
+ File.link path, new_path
14
+ File.unlink path
15
+ # blah ... implementation specific ...
16
+ @data[0] = @tmpname = new_path
17
+ end
18
+ end
19
+
20
+ def getAbsolutePath
21
+ path
22
+ end
23
+
24
+ end
data/lib/envjs.rb ADDED
@@ -0,0 +1,23 @@
1
+ module Envjs
2
+
3
+ def self.js_exception_stack e
4
+ result = %(Exception: )+e.to_s
5
+ e.stack.to_s.split(%(\n)).each do |line|
6
+ next if line == "@:0"
7
+ m = line.match(/(.*)@([^@]*)$/)
8
+ s = m[1]
9
+ limit = 50
10
+ if ( s.length > limit )
11
+ s = s[0,limit] + %(...)
12
+ end
13
+ result += "\n" + m[2]+%( )+s
14
+ end
15
+ result
16
+ end
17
+
18
+ ENVJS =
19
+ File.expand_path( File.join( File.dirname(__FILE__),
20
+ "envjs",
21
+ "env.js" ) )
22
+
23
+ end
@@ -0,0 +1,17 @@
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
+
17
+ Envjs.wait();
data/test/debug.js ADDED
@@ -0,0 +1,53 @@
1
+ // Init
2
+ load("src/env.js");
3
+ load("src/htmlparser.js");
4
+
5
+ window.location = "test/index.html";
6
+
7
+ window.onload = function(){
8
+ load("test/testrunner.js");
9
+ load("test/jquery.js");
10
+
11
+ var depth = 0;
12
+
13
+ function indent(){
14
+ var str = "";
15
+ for ( var i = 0; i < depth; i++ ) {
16
+ str += " ";
17
+ }
18
+ return str;
19
+ }
20
+
21
+ function dump(name, args, ret){
22
+ print(name + ": " + Array.prototype.slice.call(args) + " - Return: " + ret);
23
+ }
24
+
25
+ for ( var method in jQuery.fn ) (function(method){ if ( method != "init" ) {
26
+ var old = jQuery.fn[method];
27
+ jQuery.fn[method] = function(){
28
+ print(indent() + method + ": " + Array.prototype.slice.call(arguments));
29
+ depth++;
30
+ var ret = old.apply(this, arguments);
31
+ depth--;
32
+ print(indent() + method + ": Return " + ret);
33
+ return ret;
34
+ };
35
+ } })(method);
36
+
37
+ for ( var method in jQuery ) (function(method){ if ( method != "prototype" && method != "fn" ) {
38
+ var old = jQuery[method];
39
+ jQuery[method] = function(){
40
+ print(indent() + "$." + method + ": " + Array.prototype.slice.call(arguments));
41
+ depth++;
42
+ var ret = old.apply(this, arguments);
43
+ depth--;
44
+ print(indent() + "$." + method + ": Return " + ret);
45
+ return ret;
46
+ };
47
+ } })(method);
48
+
49
+ jQuery.prototype.toString = DOMNodeList.prototype.toString;
50
+ Function.prototype.toString = function(){ return "function()"; };
51
+
52
+ print("Ready.");
53
+ };
@@ -0,0 +1,3 @@
1
+ whichJarFile = "envjs"
2
+ multiwindow = true;
3
+ load("test/call-load-test.js");
@@ -0,0 +1,3 @@
1
+ whichJarFile = "envjs"
2
+ multiwindow = true;
3
+ load("test/prototype.js");
@@ -0,0 +1,171 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <!--
4
+ * This file is a component of env.js,
5
+ * http://github.com/gleneivey/env-js/commits/master/README
6
+ * a Pure JavaScript Browser Environment
7
+ * Copyright 2009 John Resig, licensed under the MIT License
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ -->
10
+
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
12
+ lang="en" dir="ltr" id="html">
13
+ <head>
14
+ <title>IFRAME content page, env.js unit tests, deeply-nested structure
15
+ </title>
16
+
17
+ <script>
18
+ // define event handlers for following HTML structure
19
+
20
+ window.initECounters = function (counterObj){
21
+ counterObj["window onload"] = 0;
22
+ counterObj["window onunload"] = 0;
23
+ counterObj["body onload"] = 0;
24
+ counterObj["body onclick"] = 0;
25
+ counterObj["body onunload"] = 0;
26
+ counterObj["h1 onclick"] = 0;
27
+ counterObj["h2 onclick"] = 0;
28
+ counterObj["div onclick"] = 0;
29
+ counterObj["table onclick"] = 0;
30
+ counterObj["tbody onclick"] = 0;
31
+ counterObj["tr onclick"] = 0;
32
+ counterObj["td onclick"] = 0;
33
+ counterObj["ul onclick"] = 0;
34
+ counterObj["li onclick"] = 0;
35
+ counterObj["p onclick"] = 0;
36
+ counterObj["b onclick"] = 0;
37
+ counterObj["i onclick"] = 0;
38
+ counterObj["a onclick"] = 0;
39
+ counterObj["img onclick"] = 0;
40
+ counterObj["img onload"] = 0;
41
+ }
42
+
43
+ // init only first time this page loads, re-init'ed in unit/events.js
44
+ try {
45
+ if (!(window.top.eCounters)){
46
+ window.top.eCounters = {};
47
+ initECounters(window.top.eCounters);
48
+ }
49
+ } catch(e){
50
+ window.top.eCounters = {};
51
+ initECounters(window.top.eCounters);
52
+ }
53
+
54
+ function bodyOnloadHandler(elem){
55
+ if (elem === document.getElementById('theBODY'))
56
+ window.top.eCounters["body onload"] += 1;
57
+ }
58
+ function bodyOnclickHandler(elem){
59
+ if (elem === document.getElementById('theBODY'))
60
+ window.top.eCounters["body onclick"] += 1;
61
+ }
62
+ function bodyOnunloadHandler(elem){
63
+ if (elem === document.getElementById('theBODY'))
64
+ window.top.eCounters["body onunload"] += 1;
65
+ }
66
+ function h1OnclickHandler(elem){
67
+ if (elem === document.getElementById('theH1'))
68
+ window.top.eCounters["h1 onclick"] += 1;
69
+ }
70
+ function h2OnclickHandler(elem){
71
+ if (elem === document.getElementById('theH2'))
72
+ window.top.eCounters["h2 onclick"] += 1;
73
+ }
74
+ function divOnclickHandler(elem){
75
+ if (elem === document.getElementById('theDIV'))
76
+ window.top.eCounters["div onclick"] += 1;
77
+ }
78
+ function tableOnclickHandler(elem){
79
+ if (elem === document.getElementById('theTABLE'))
80
+ window.top.eCounters["table onclick"] += 1;
81
+ }
82
+ function tbodyOnclickHandler(elem){
83
+ if (elem === document.getElementById('theTBODY'))
84
+ window.top.eCounters["tbody onclick"] += 1;
85
+ }
86
+ function trOnclickHandler(elem){
87
+ if (elem === document.getElementById('theTR'))
88
+ window.top.eCounters["tr onclick"] += 1;
89
+ }
90
+ function tdOnclickHandler(elem){
91
+ if (elem === document.getElementById('theTD'))
92
+ window.top.eCounters["td onclick"] += 1;
93
+ }
94
+ function ulOnclickHandler(elem){
95
+ if (elem === document.getElementById('theUL'))
96
+ window.top.eCounters["ul onclick"] += 1;
97
+ }
98
+ function liOnclickHandler(elem){
99
+ if (elem === document.getElementById('theLI'))
100
+ window.top.eCounters["li onclick"] += 1;
101
+ }
102
+ function pOnclickHandler(elem){
103
+ if (elem === document.getElementById('theP'))
104
+ window.top.eCounters["p onclick"] += 1;
105
+ }
106
+ function bOnclickHandler(elem){
107
+ if (elem === document.getElementById('theB'))
108
+ window.top.eCounters["b onclick"] += 1;
109
+ }
110
+ function iOnclickHandler(elem){
111
+ if (elem === document.getElementById('theI'))
112
+ window.top.eCounters["i onclick"] += 1;
113
+ }
114
+ function aOnclickHandler(elem){
115
+ if (elem === document.getElementById('theA'))
116
+ window.top.eCounters["a onclick"] += 1;
117
+ }
118
+ function imgOnclickHandler(elem){
119
+ if (elem === document.getElementById('theIMG'))
120
+ window.top.eCounters["img onclick"] += 1;
121
+ }
122
+ function imgOnloadHandler(elem){
123
+ if (elem === document.getElementById('theIMG'))
124
+ window.top.eCounters["img onload"] += 1;
125
+ }
126
+
127
+ window.onload = function(){
128
+ window.top.eCounters["window onload"] += 1;
129
+ }
130
+
131
+ window.onunload = function(){
132
+ window.top.eCounters["window onunload"] += 1;
133
+ }
134
+ </script>
135
+
136
+ </head>
137
+ <body id="theBODY" onload="bodyOnloadHandler(this);"
138
+ onclick="bodyOnclickHandler(this);"
139
+ onunload="bodyOnunloadHandler(this);">
140
+ <h1 id="theH1" onclick="h1OnclickHandler(this);">
141
+ First header in document</h1>
142
+ <h2 id="theH2" onclick="h2OnclickHandler(this);">
143
+ Second header in document</h2>
144
+
145
+ <div id="theDIV" onclick="divOnclickHandler(this);">
146
+ <table id="theTABLE" onclick="tableOnclickHandler(this);">
147
+ <tbody id="theTBODY" onclick="tbodyOnclickHandler(this);">
148
+ <tr id="theTR" onclick="trOnclickHandler(this);">
149
+ <td id="theTD" onclick="tdOnclickHandler(this);">
150
+ <ul id="theUL" onclick="ulOnclickHandler(this);">
151
+ <li id="theLI" onclick="liOnclickHandler(this);">
152
+ <p id="theP" onclick="pOnclickHandler(this);">
153
+ Some text <b id="theB" onclick="bOnclickHandler(this);">
154
+ more text <i id="theI" onclick="iOnclickHandler(this);">
155
+ <a id="theA" href="#" onclick="aOnclickHandler(this);">
156
+ <img id="theIMG" src="noImg.png" alt="image link"
157
+ onclick="imgOnclickHandler(this);"
158
+ onload="imgOnloadHandler(this);" />
159
+ </a> fu fu
160
+ </i> bar bar,
161
+ </b> blah blah.
162
+ </p>
163
+ </li>
164
+ </ul>
165
+ </td>
166
+ </tr>
167
+ </tbody>
168
+ </table>
169
+ </div>
170
+ </body>
171
+ </html>
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <!--
4
+ * This file is a component of env.js,
5
+ * http://github.com/gleneivey/env-js/commits/master/README
6
+ * a Pure JavaScript Browser Environment
7
+ * Copyright 2009 John Resig, licensed under the MIT License
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ -->
10
+
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
12
+ lang="en" dir="ltr" id="html">
13
+ <head>
14
+ <title>Content document for IFRAME element in env.js unit test suite</title>
15
+ </head>
16
+ <body onload="try{checkEventsWithinIframe();}catch(e){;}">
17
+ <p id="anElementWithText">
18
+ This is the text content of a paragraph element.
19
+ </p>
20
+
21
+ <!-- elements and scripting here match test cases in ../unit/window.js -->
22
+ <script>//ensure that we can execute JS inline while loading
23
+ document.write(
24
+ '\x3cp id="js_generated_p"\x3eDynamically-generated\x3c/p\x3e');
25
+ </script>
26
+
27
+ <script>//verify that our "document" object actually points to this page
28
+ document.write('\x3cp id="internalDocRefResult"\x3e');
29
+ if (document.getElementById('anElementWithText'))
30
+ document.write("First paragraph element exists-found.");
31
+ else
32
+ document.write("Eeek! Didn't find paragraph id=anElementWithText.");
33
+ document.write('\x3c/p\x3e');
34
+ </script>
35
+
36
+ <script>// append 'p id=appended "An appended paragraph"' to doc....
37
+ function checkEventsWithinIframe(){
38
+ var t = document.createTextNode("An appended paragraph");
39
+ var p = document.createElement("p");
40
+ p.setAttribute("id", "appended");
41
+ p.appendChild(t);
42
+ document.getElementsByTagName('body')[0].appendChild(p);
43
+ }
44
+ </script>
45
+ </body>
46
+ </html>