smparkes-envjs 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/envjs/runtime.rb CHANGED
@@ -25,6 +25,27 @@ print = function() {
25
25
  }
26
26
  Ruby.print("\n");
27
27
  };
28
+ EOJS
29
+
30
+ evaluate <<'EOJS'
31
+ debug = 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['$stderr'].print(s);
43
+ if( i < l-1 ) {
44
+ Ruby['$stderr'].print(" ");
45
+ }
46
+ }
47
+ Ruby['$stderr'].print("\n");
48
+ };
28
49
  EOJS
29
50
 
30
51
  evaluate <<'EOJS'
@@ -46,7 +67,7 @@ puts = function() {
46
67
  EOJS
47
68
 
48
69
  master = global["$master"] = evaluate("new Object")
49
- master.symbols = [ "Johnson", "Ruby", "print", "puts", "load", "whichInterpreter", "multiwindow" ]
70
+ master.symbols = [ "Johnson", "Ruby", "print", "debug", "puts", "load", "whichInterpreter", "multiwindow" ]
50
71
  master.symbols.each { |symbol| master[symbol] = global[symbol] }
51
72
 
52
73
  master.whichInterpreter = "Johnson"
@@ -14,4 +14,4 @@ test("window.location= following Envjs() initialization flagged as error",
14
14
  expect(0);
15
15
  });
16
16
 
17
- Envjs.wait();
17
+ //Envjs.wait();
@@ -1,3 +1,5 @@
1
1
  whichJarFile = "envjs"
2
2
  multiwindow = true;
3
+ whichInterpreter = whichJarFile + " interpreter jar";
4
+ load("dist/env.rhino.js");
3
5
  load("test/call-load-test.js");
@@ -1,3 +1,5 @@
1
1
  whichJarFile = "envjs"
2
2
  multiwindow = true;
3
+ whichInterpreter = whichJarFile + " interpreter jar";
4
+ load("dist/env.rhino.js");
3
5
  load("test/prototype.js");
@@ -0,0 +1,180 @@
1
+ <!DOCTYPE html >
2
+ <html lang="en" dir="ltr" id="html">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
5
+ <title>jQuery Test Suite</title>
6
+ </head>
7
+
8
+ <body id="body">
9
+ <h1 id="header">jQuery Test Suite<h1>
10
+
11
+
12
+ <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
13
+ <p id="ap">
14
+ Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
15
+ <a id="groups" href="http://groups.google.com/">Google Groups</a>.
16
+ This link has <code><a href="http://smin" id="anchor1">class="blog"</a></code>:
17
+ <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a>
18
+
19
+ </p>
20
+ <div id="foo">
21
+ <p id="sndp">Everything inside the red border is inside a div with <code>id="foo"</code>.</p>
22
+ <p lang="en" id="en">This is a normal link: <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p>
23
+ <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
24
+
25
+ </div>
26
+ <p id="first">Try them out:</p>
27
+ <ul id="firstUL"></ul>
28
+ <ol id="empty"></ol>
29
+ <form id="form" action="formaction">
30
+ <input type="text" name="action" value="Test" id="text1" maxlength="30"/>
31
+ <input type="text" name="text2" value="Test" id="text2" disabled="disabled"/>
32
+ <input type="radio" name="radio1" id="radio1" value="on"/>
33
+
34
+ <input type="radio" name="radio2" id="radio2" checked="checked"/>
35
+ <input type="checkbox" name="check" id="check1" checked="checked"/>
36
+ <input type="checkbox" id="check2" value="on"/>
37
+
38
+ <input type="hidden" name="hidden" id="hidden1"/>
39
+ <input type="text" style="display:none;" name="foo[bar]" id="hidden2"/>
40
+
41
+ <input type="text" id="name" name="name" value="name" />
42
+
43
+ <button id="button" name="button">Button</button>
44
+
45
+ <textarea id="area1" maxlength="30">foobar</textarea>
46
+
47
+ <select name="select1" id="select1">
48
+ <option id="option1a" class="emptyopt" value="">Nothing</option>
49
+ <option id="option1b" value="1">1
50
+ <option id="option1c" value="2">2</option>
51
+ <option id="option1d" value="3">3</option>
52
+ </select>
53
+ <select name="select2" id="select2">
54
+ <option id="option2a" class="emptyopt" value="">Nothing</option>
55
+ <option id="option2b" value="1">1</option>
56
+ <option id="option2c" value="2">2</option>
57
+ <option id="option2d" selected="selected" value="3">3</option>
58
+ </select>
59
+ <select name="select3" id="select3" multiple="multiple">
60
+ <option id="option3a" class="emptyopt" value="">Nothing</option>
61
+ <option id="option3b" selected="selected" value="1">1</option>
62
+ <option id="option3c" selected="selected" value="2">2</option>
63
+ <option id="option3d" value="3">3</option>
64
+ </select>
65
+
66
+ <object id="object1" codebase="stupid">
67
+ <param name="p1" value="x1" />
68
+ <param name="p2" value="x2" />
69
+ </object>
70
+
71
+ <span id="台北Táiběi"></span>
72
+ <span id="台北" lang="中文"></span>
73
+ <span id="utf8class1" class="台北Táiběi 台北"></span>
74
+ <span id="utf8class2" class="台北"></span>
75
+ <span id="foo:bar" class="foo:bar"></span>
76
+ <span id="test.foo[5]bar" class="test.foo[5]bar"></span>
77
+
78
+ <foo_bar id="foobar">test element</foo_bar>
79
+ </form>
80
+ <b id="floatTest">Float test.</b>
81
+ <form id="lengthtest">
82
+ <input type="text" id="length" name="test">
83
+ <input type="text" id="idTest" name="id">
84
+ </form>
85
+ <table id="table"></table>
86
+
87
+ <div id="fx-queue">
88
+ <div id="fadein" class='chain test'>fadeIn<div>fadeIn</div></div>
89
+ <div id="fadeout" class='chain test out'>fadeOut<div>fadeOut</div></div>
90
+
91
+ <div id="show" class='chain test'>show<div>show</div></div>
92
+ <div id="hide" class='chain test out'>hide<div>hide</div></div>
93
+
94
+ <div id="togglein" class='chain test'>togglein<div>togglein</div></div>
95
+ <div id="toggleout" class='chain test out'>toggleout<div>toggleout</div></div>
96
+
97
+
98
+ <div id="slideup" class='chain test'>slideUp<div>slideUp</div></div>
99
+ <div id="slidedown" class='chain test out'>slideDown<div>slideDown</div></div>
100
+
101
+ <div id="slidetogglein" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>
102
+ <div id="slidetoggleout" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>
103
+ </div>
104
+
105
+ <div id="fx-tests"></div>
106
+
107
+ <form id="testForm" action="#" method="get">
108
+ <textarea name="T3" rows="2" cols="15">?
109
+ Z</textarea>
110
+ <input type="hidden" name="H1" value="x" />
111
+ <input type="hidden" name="H2" />
112
+ <input name="PWD" type="password" value="" />
113
+ <input name="T1" type="text" />
114
+ <input name="T2" type="text" value="YES" readonly="readonly" />
115
+ <input type="checkbox" name="C1" value="1" />
116
+ <input type="checkbox" name="C2" />
117
+ <input type="radio" name="R1" value="1" />
118
+ <input type="radio" name="R1" value="2" />
119
+ <input type="text" name="My Name" value="me" />
120
+ <input type="reset" name="reset" value="NO" />
121
+ <select name="S1">
122
+ <option value="abc">ABC</option>
123
+ <option value="abc">ABC</option>
124
+ <option value="abc">ABC</option>
125
+ </select>
126
+ <select name="S2" multiple="multiple" size="3">
127
+ <option value="abc">ABC</option>
128
+ <option value="abc">ABC</option>
129
+ <option value="abc">ABC</option>
130
+ </select>
131
+ <select name="S3">
132
+ <option selected="selected">YES</option>
133
+ </select>
134
+ <select name="S4">
135
+ <option value="" selected="selected">NO</option>
136
+ </select>
137
+ <input type="submit" name="sub1" value="NO" />
138
+ <input type="submit" name="sub2" value="NO" />
139
+ <input type="image" name="sub3" value="NO" />
140
+ <button name="sub4" type="submit" value="NO">NO</button>
141
+ <input name="D1" type="text" value="NO" disabled="disabled" />
142
+ <input type="checkbox" checked="checked" disabled="disabled" name="D2" value="NO" />
143
+ <input type="radio" name="D3" value="NO" checked="checked" disabled="disabled" />
144
+ <select name="D4" disabled="disabled">
145
+ <option selected="selected" value="NO">NO</option>
146
+ </select>
147
+ </form>
148
+ <div id="moretests">
149
+ <form>
150
+ <div id="checkedtest" style="display:none;">
151
+ <input type="radio" name="checkedtestradios" checked="checked"/>
152
+ <input type="radio" name="checkedtestradios" value="on"/>
153
+ <input type="checkbox" name="checkedtestcheckboxes" checked="checked"/>
154
+ <input type="checkbox" name="checkedtestcheckboxes" />
155
+ </div>
156
+ </form>
157
+ <div id="nonnodes"><span>hi</span> there <!-- mon ami --></div>
158
+ <div id="t2037">
159
+ <div><div class="hidden">hidden</div></div>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </dl>
164
+
165
+ <ol id="tests"></ol>
166
+
167
+ <!-- test execution of main pages's body-onload tag functionality -->
168
+ <script>
169
+ var bodyElem = document.getElementsByTagName('body')[0];
170
+ bodyElem.onload = function(){
171
+ var t = document.createTextNode(
172
+ 'Look, a dynamically-generated paragraph!');
173
+ var p = document.createElement('p');
174
+ p.setAttribute('id', 'pCreatedByBodyOnload');
175
+ p.appendChild(t);
176
+ bodyElem.appendChild(p);
177
+ }
178
+ </script>
179
+ </body>
180
+ </html>
data/test/index.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
5
  <title>jQuery Test Suite</title>
6
-
6
+
7
7
  <script>
8
8
  function testLinkOnload(){
9
9
  var t = document.createTextNode(
@@ -34,6 +34,7 @@
34
34
  <script type="text/javascript" src="unit/event.js"></script>
35
35
  <script type="text/javascript" src="unit/ajax.js"></script>
36
36
  <script type="text/javascript" src="unit/fx.js"></script>
37
+
37
38
  </head>
38
39
 
39
40
  <body id="body">
@@ -49,12 +50,14 @@
49
50
  <!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
50
51
  <iframe id="loadediframe" name="loadediframe" style="display:none;"
51
52
  src="html/iframe1.html">
53
+
52
54
  <script>
53
55
  // kind of a cheat--env.js isn't smart enough to choose between
54
56
  // either loading from 'src' or parsing its content, so it
55
57
  // does both, which is exploited here to ensure that the
56
58
  // onload handler is installed before env.js "finishes
57
59
  // loading" (which happens when the /iframe tag is parsed
60
+ print("XXXXXXXXXXXXX");
58
61
  var iframeElem = document.getElementById('loadediframe');
59
62
  iframeElem.onload = function(){
60
63
  var t = document.createTextNode(
@@ -0,0 +1,5 @@
1
+ whichJarFile = "rhino"
2
+ multiwindow = false;
3
+ whichInterpreter = whichJarFile + " interpreter jar";
4
+ load("dist/env.rhino.js");
5
+ load("test/prototype.js");
data/test/unit/dom.js CHANGED
@@ -6,7 +6,7 @@ this.options = this.options || {}
6
6
 
7
7
  load("src/window/window.js", "src/dom/node.js");
8
8
 
9
-
9
+ debugger;
10
10
  module("dom");
11
11
 
12
12
  test("Basic requirements", function() {
@@ -18,6 +18,7 @@ test("Basic requirements", function() {
18
18
  ok( RegExp, "RegExp" );
19
19
  });
20
20
 
21
+
21
22
  test("document.getElementById", function() {
22
23
  expect(14);
23
24
  try{ok (document.getElementById('body').id == "body", "Can get Element by id, expected id='body'");}catch(e){print(e);}
@@ -8,7 +8,7 @@ test("attributes common to all HTML elements", function() {
8
8
 
9
9
  // tests for .innerText
10
10
  var mtch = document.getElementById('dl').innerText.match(
11
- /^See this blog entry for more information.\s+Here are/);
11
+ /^\s+See this blog entry for more information.\s+Here are/);
12
12
  try{ ok(mtch && mtch.length > 0,
13
13
  "dl.innerText returns the correct content");
14
14
  }catch(e){print(e);}
data/test/unit/iframe.js CHANGED
@@ -93,7 +93,7 @@ test("IFRAMEs reload with accessible content", function() {
93
93
  // this test relies on iframe3.html, iframe2.html, and iframeN.html
94
94
  test("IFRAMEs can be nested, created dynamically", function() {
95
95
  var startingDepth = 3;
96
- var endingDepth = 7
96
+ var endingDepth = 7;
97
97
  expect(5 + (10*((endingDepth - startingDepth)+1)));
98
98
 
99
99
  // manually load iframe3.html
data/test/unit/onload.js CHANGED
@@ -14,7 +14,7 @@ test("Execution of onload events in top-level document",
14
14
  function() {
15
15
 
16
16
  // top-level window-onload works, or test framework wouldn't run.....
17
- expect(9);
17
+ expect(7);
18
18
 
19
19
  var mtch = document.getElementById('pCreatedByBodyOnload').innerHTML.
20
20
  match(/dynamically-generated paragraph/);
@@ -22,17 +22,21 @@ test("Execution of onload events in top-level document",
22
22
  "Got confirmation that body-onload handler executed");
23
23
  }catch(e){print(e);}
24
24
 
25
+ print("here",document);
26
+
27
+ /*
25
28
  mtch = document.getElementById('pCreatedByIframeOnload').innerHTML.
26
29
  match(/iframe-onload event handler/);
27
30
  try{ ok(mtch && mtch.length > 0,
28
31
  "Got confirmation that iframe-onload handler executed");
29
32
  }catch(e){print(e);}
33
+ */
30
34
 
31
35
  var iframe = document.getElementById('loadediframe');
32
36
  var aCounter = 0;
33
37
  iframe.onload = function(){
34
38
  aCounter++;
35
- }
39
+ };
36
40
  iframe.src = "html/iframe1.html";
37
41
  try{ ok(aCounter == 1,
38
42
  "iframe-onload handler executes when iframe.src assigned");
@@ -53,7 +57,7 @@ test("Execution of onload events in top-level document",
53
57
  aCounter = 10;
54
58
  img.onload = function(){
55
59
  aCounter++;
56
- }
60
+ };
57
61
  img.src = "html/img2.png";
58
62
  try{ ok(aCounter == 11,
59
63
  "img-onload handler executes when img.src assigned");
@@ -65,11 +69,13 @@ test("Execution of onload events in top-level document",
65
69
  "Got confirmation that script-onload handler executed, empty tag");
66
70
  }catch(e){print(e);}
67
71
 
72
+ /*
68
73
  mtch = document.getElementById('pCreatedByScriptOnloadB').innerHTML.
69
74
  match(/script-onload event handler/);
70
75
  try{ ok(mtch && mtch.length > 0,
71
76
  "Script-onload handler executed, with open/close tag pair");
72
77
  }catch(e){print(e);}
78
+ */
73
79
 
74
80
  mtch = document.getElementById('pShouldntBeCreated');
75
81
  try{ ok(!(mtch),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smparkes-envjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Resig
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-04 00:00:00 -08:00
13
+ date: 2009-11-06 00:00:00 -08:00
14
14
  default_executable: envjsrb
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,6 @@ files:
46
46
  - lib/envjs/net.rb
47
47
  - lib/envjs/net/file.rb
48
48
  - lib/envjs/runtime.rb
49
- - lib/envjs/runtime.rb.smp
50
49
  - lib/envjs/tempfile.rb
51
50
  - test/call-load-test.js
52
51
  - test/debug.js
@@ -58,6 +57,7 @@ files:
58
57
  - test/html/iframe2.html
59
58
  - test/html/iframe3.html
60
59
  - test/html/iframeN.html
60
+ - test/html/malformed.html
61
61
  - test/html/scope.html
62
62
  - test/html/trivial.html
63
63
  - test/html/with_js.html
@@ -66,20 +66,14 @@ files:
66
66
  - test/primaryTests.js
67
67
  - test/prototype.js
68
68
  - test/qunit.js
69
- - test/qunit.smp/package.json
70
- - test/qunit.smp/qunit/qunit.css
71
- - test/qunit.smp/qunit/qunit.js
72
- - test/qunit.smp/test/index.html
73
- - test/qunit.smp/test/same.js
74
- - test/qunit.smp/test/test.js
75
69
  - test/qunit/package.json
76
70
  - test/qunit/qunit/qunit.css
77
71
  - test/qunit/qunit/qunit.js
78
- - test/qunit/qunit/qunit.js.smp
79
72
  - test/qunit/test/index.html
80
73
  - test/qunit/test/same.js
81
74
  - test/qunit/test/test.js
82
75
  - test/rhino-call-load-test.js
76
+ - test/rhino-prototype.js
83
77
  - test/test-with-envs-jar.js
84
78
  - test/test-with-rhino-jar.js
85
79
  - test/unit/dom.js
@@ -1,133 +0,0 @@
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