jspec 2.11.13 → 3.0.0

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.
Files changed (77) hide show
  1. data/History.md +714 -0
  2. data/Manifest +51 -36
  3. data/README.md +968 -0
  4. data/Rakefile +4 -53
  5. data/bin/jspec +93 -224
  6. data/jspec.gemspec +5 -5
  7. data/lib/images/sprites.png +0 -0
  8. data/lib/jspec.css +2 -2
  9. data/lib/jspec.growl.js +115 -0
  10. data/lib/jspec.jquery.js +1 -1
  11. data/lib/jspec.js +98 -101
  12. data/lib/jspec.shell.js +5 -2
  13. data/lib/jspec.timers.js +1 -1
  14. data/lib/jspec.xhr.js +12 -2
  15. data/spec/commands/example_command.rb +19 -0
  16. data/spec/dom.html +33 -0
  17. data/spec/node.js +32 -0
  18. data/spec/rhino.js +24 -0
  19. data/spec/ruby/bin/init_spec.rb +101 -0
  20. data/spec/ruby/bin/install_spec.rb +141 -0
  21. data/spec/ruby/bin/run_spec.rb +0 -0
  22. data/spec/ruby/bin/shell_spec.rb +13 -0
  23. data/spec/ruby/bin/spec_helper.rb +25 -0
  24. data/spec/ruby/bin/update_spec.rb +72 -0
  25. data/spec/server.html +29 -0
  26. data/spec/server.rb +1 -1
  27. data/spec/{env.js → support/env.js} +554 -664
  28. data/spec/support/jquery.js +4376 -0
  29. data/spec/{helpers.js → unit/helpers.js} +2 -0
  30. data/spec/{spec.fixtures.js → unit/spec.fixtures.js} +0 -1
  31. data/spec/{spec.grammar-less.js → unit/spec.grammar-less.js} +0 -0
  32. data/spec/{spec.grammar.js → unit/spec.grammar.js} +1 -11
  33. data/spec/{spec.jquery.js → unit/spec.jquery.js} +0 -17
  34. data/spec/{spec.jquery.xhr.js → unit/spec.jquery.xhr.js} +13 -2
  35. data/spec/unit/spec.js +187 -0
  36. data/spec/{spec.matchers.js → unit/spec.matchers.js} +141 -66
  37. data/spec/{spec.modules.js → unit/spec.modules.js} +0 -0
  38. data/spec/{spec.shared-behaviors.js → unit/spec.shared-behaviors.js} +0 -0
  39. data/spec/{spec.utils.js → unit/spec.utils.js} +123 -22
  40. data/spec/{spec.xhr.js → unit/spec.xhr.js} +11 -10
  41. data/{server → src}/browsers.rb +23 -0
  42. data/{server → src}/helpers.rb +2 -17
  43. data/src/installables.rb +229 -0
  44. data/src/project.rb +340 -0
  45. data/{server → src}/routes.rb +1 -1
  46. data/{server → src}/server.rb +0 -0
  47. data/support/js.jar +0 -0
  48. data/templates/default/History.md +5 -0
  49. data/templates/default/{README.rdoc → Readme.md} +3 -3
  50. data/templates/default/lib/{yourlib.core.js → yourlib.js} +0 -0
  51. data/templates/default/spec/commands/example_command.rb +19 -0
  52. data/templates/default/spec/{spec.dom.html → dom.html} +5 -3
  53. data/templates/default/spec/rhino.js +10 -0
  54. data/templates/default/spec/server.html +18 -0
  55. data/templates/default/spec/unit/spec.helper.js +0 -0
  56. data/templates/default/spec/{spec.core.js → unit/spec.js} +0 -0
  57. data/templates/rails/commands/example_commands.rb +19 -0
  58. data/templates/rails/{spec.dom.html → dom.html} +4 -2
  59. data/templates/rails/rhino.js +10 -0
  60. data/templates/rails/server.html +18 -0
  61. data/templates/rails/unit/spec.helper.js +0 -0
  62. data/templates/rails/{spec.application.js → unit/spec.js} +0 -0
  63. metadata +56 -41
  64. data/History.rdoc +0 -590
  65. data/README.rdoc +0 -842
  66. data/spec/async +0 -1
  67. data/spec/jquery.js +0 -19
  68. data/spec/spec.dom.html +0 -34
  69. data/spec/spec.js +0 -166
  70. data/spec/spec.node.js +0 -46
  71. data/spec/spec.rhino.js +0 -23
  72. data/spec/spec.server.html +0 -29
  73. data/templates/default/History.rdoc +0 -4
  74. data/templates/default/spec/spec.rhino.js +0 -8
  75. data/templates/default/spec/spec.server.html +0 -16
  76. data/templates/rails/spec.rhino.js +0 -8
  77. data/templates/rails/spec.server.html +0 -16
@@ -0,0 +1,25 @@
1
+
2
+ require 'fileutils'
3
+
4
+ load File.dirname(__FILE__) + '/../../../bin/jspec'
5
+
6
+ def jspec name, *args
7
+ capture do
8
+ command(name).run *args
9
+ end
10
+ end
11
+
12
+ def capture &block
13
+ IO.popen('-') do |io|
14
+ io ? io.read : yield
15
+ end
16
+ end
17
+
18
+ def shell *args
19
+ IO.popen(JSPEC_ROOT + '/bin/jspec shell', 'r+') do |io|
20
+ args.each do |arg|
21
+ io.puts arg
22
+ end
23
+ io.read
24
+ end
25
+ end
@@ -0,0 +1,72 @@
1
+
2
+ include FileUtils
3
+
4
+ describe "jspec" do
5
+ describe "update" do
6
+ before :each do
7
+ @dest = File.dirname(__FILE__) + '/test'
8
+ mkdir @dest
9
+ end
10
+
11
+ after :each do
12
+ rm_rf @dest
13
+ end
14
+
15
+ def mock_version_in path, &block
16
+ File.open(path, 'w+') do |file|
17
+ file.write 'src="/Some/path/jspec-1.1.0"'
18
+ end
19
+ yield path if block
20
+ end
21
+
22
+ it "should update absolute paths matching jspec-n.n.n" do
23
+ jspec(:init, @dest)
24
+ mock_version_in "#{@dest}/spec/dom.html" do |path|
25
+ Dir.chdir(@dest) { jspec(:update) }
26
+ File.read(path).should include("jspec-#{program(:version)}")
27
+ end
28
+ end
29
+
30
+ it "should update absolute paths matching jspec-n.n.n for a rails project" do
31
+ mkdir @dest + '/vendor'
32
+ jspec(:init, @dest)
33
+ mock_version_in "#{@dest}/jspec/dom.html" do |path|
34
+ Dir.chdir(@dest) { jspec(:update) }
35
+ File.read(path).should include("jspec-#{program(:version)}")
36
+ end
37
+ end
38
+
39
+ it "should update absolute paths matching jspec-n.n.n when a destination is passed" do
40
+ jspec(:init, @dest)
41
+ mock_version_in "#{@dest}/spec/dom.html" do |path|
42
+ jspec(:update, @dest)
43
+ File.read(path).should include("jspec-#{program(:version)}")
44
+ end
45
+ end
46
+
47
+ it "should update absolute paths matching jspec-n.n.n for a rails project when a destination in passed" do
48
+ mkdir @dest + '/vendor'
49
+ jspec(:init, @dest)
50
+ mock_version_in "#{@dest}/jspec/dom.html" do |path|
51
+ jspec(:update, @dest)
52
+ File.read(path).should include("jspec-#{program(:version)}")
53
+ end
54
+ end
55
+
56
+ it "should update projects initialized with --freeze" do
57
+ jspec(:init, @dest, '--freeze')
58
+ rm "#{@dest}/spec/lib/jspec.js"
59
+ jspec(:update, @dest)
60
+ File.exists?("#{@dest}/spec/lib/jspec.js").should be_true
61
+ end
62
+
63
+ it "should update rails projects initialized with --freeze" do
64
+ mkdir @dest + '/vendor'
65
+ jspec(:init, @dest, '--freeze')
66
+ rm "#{@dest}/jspec/lib/jspec.js"
67
+ jspec(:update, @dest)
68
+ File.exists?("#{@dest}/jspec/lib/jspec.js").should be_true
69
+ end
70
+
71
+ end
72
+ end
data/spec/server.html ADDED
@@ -0,0 +1,29 @@
1
+ <html>
2
+ <head>
3
+ <script src="/spec/support/jquery.js"></script>
4
+ <script src="/jspec/jspec.js"></script>
5
+ <script src="/jspec/jspec.jquery.js"></script>
6
+ <script src="/jspec/jspec.xhr.js"></script>
7
+ <script src="/spec/helpers.js"></script>
8
+ <script src="/spec/unit/spec.grammar-less.js"></script>
9
+ <script>
10
+ function runSuites() {
11
+ JSpec
12
+ .exec('/spec/unit/spec.grammar.js')
13
+ .exec('/spec/unit/spec.js')
14
+ .exec('/spec/unit/spec.matchers.js')
15
+ .exec('/spec/unit/spec.utils.js')
16
+ .exec('/spec/unit/spec.fixtures.js')
17
+ .exec('/spec/unit/spec.shared-behaviors.js')
18
+ .exec('/spec/unit/spec.jquery.js')
19
+ .exec('/spec/unit/spec.modules.js')
20
+ .exec('/spec/unit/spec.xhr.js')
21
+ .exec('/spec/unit/spec.jquery.xhr.js')
22
+ .run({ reporter: JSpec.reporters.Server, fixturePath: '/spec/fixtures' })
23
+ .report()
24
+ }
25
+ </script>
26
+ </head>
27
+ <body class="jspec" onLoad="runSuites();">
28
+ </body>
29
+ </html>
data/spec/server.rb CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- puts 'Use spec/jspec.rb to alter anything you like, provide routes, browsers, etc'
2
+ puts 'Use server.rb to alter anything you like, provide routes, browser support, etc'
@@ -19,9 +19,7 @@ var Envjs = function(){
19
19
  Envjs[i] = arguments[1][i];
20
20
  }
21
21
  }
22
-
23
- if (arguments[0] != null && arguments[0] != "")
24
- window.location = arguments[0];
22
+ window.location = arguments[0];
25
23
  };
26
24
 
27
25
  /*
@@ -74,11 +72,8 @@ var Envjs = function(){
74
72
  // for manipulating the JavaScript scope chain, put in trivial emulations
75
73
  $env.debug("performing check for custom Java methods in env-js.jar");
76
74
  var countOfMissing = 0, dontCare;
77
- try { dontCare = getFreshScopeObj; }
78
- catch (ex){ getFreshScopeObj = function(){ return {}; };
79
- countOfMissing++; }
80
- try { dontCare = getProxyFor; }
81
- catch (ex){ getProxyFor = function(obj){ return obj; };
75
+ try { dontCare = globalize; }
76
+ catch (ex){ globalize = function(){ return {}; };
82
77
  countOfMissing++; }
83
78
  try { dontCare = getScope; }
84
79
  catch (ex){ getScope = function(){}; countOfMissing++; }
@@ -88,12 +83,11 @@ var Envjs = function(){
88
83
  catch (ex){ configureScope = function(){}; countOfMissing++; }
89
84
  try { dontCare = restoreScope; }
90
85
  catch (ex){ restoreScope = function(){}; countOfMissing++; }
91
- try { $env.loadIntoFnsScope = loadIntoFnsScope; }
92
- catch (ex){ $env.loadIntoFnsScope = load; countOfMissing++; }
93
- if (countOfMissing != 0 && countOfMissing != 7)
94
- $env.warn("Some but not all of scope-manipulation functions were " +
95
- "not present in environment. JavaScript execution may " +
96
- "not occur correctly.");
86
+ if (countOfMissing != 0 && countOfMissing != 5)
87
+ $env.warning("Some but not all of scope-manipulation functions were " +
88
+ "not present in environment. JavaScript execution may " +
89
+ "not occur correctly.");
90
+
97
91
 
98
92
  $env.lineSource = function(e){};
99
93
 
@@ -132,6 +126,8 @@ var Envjs = function(){
132
126
  $env.lang = '';
133
127
  $env.platform = "Rhino ";//how do we get the version
134
128
 
129
+ $env.load = function(){};
130
+
135
131
  $env.scriptTypes = {
136
132
  "text/javascript" :false,
137
133
  "text/envjs" :true
@@ -207,94 +203,77 @@ var Envjs = function(){
207
203
  $env.loadInlineScript = function(script){};
208
204
 
209
205
 
210
- $env.getFreshScopeObj = function(){};
211
- $env.getProxyFor = function(){};
206
+ $env.globalize = function(){};
212
207
  $env.getScope = function(){};
213
208
  $env.setScope = function(){};
214
209
  $env.configureScope = function(){};
215
210
  $env.restoreScope = function(){};
211
+ $env.loadFrame = function(frame, url){
212
+ try {
216
213
 
214
+ var frameWindow,
215
+ makingNewWinFlag = !(frame._content);
216
+ if (makingNewWinFlag)
217
+ // a blank object, inherits from original global
218
+ // see org.mozilla.javascript.tools.envjs.Window.java
219
+ frameWindow = $env.globalize();
220
+ else
221
+ frameWindow = frame._content;
222
+
223
+
224
+ // define local variables with content of things that are
225
+ // in current global/window, because when the following
226
+ // function executes we'll have a new/blank
227
+ // global/window and won't be able to get at them....
228
+ var local__window__ = $env.window,
229
+ local_env = $env,
230
+ local_window = frame.ownerDocument.parentWindow;
231
+
232
+ // a local function gives us something whose scope
233
+ // is easy to change
234
+ var __frame__ = function(){
235
+ if (makingNewWinFlag){
236
+ local__window__(frameWindow,
237
+ local_env,
238
+ local_window,
239
+ local_window.top);
240
+ }
217
241
 
218
- $env.loadFrame = function(frameElement, url){
219
- try {
220
- if (frameElement._content){
221
- $env.$unloadEventsFor(frameElement._content);
222
- $env.reloadAWindowProxy(frameElement._content, url);
242
+ frameWindow.location = url;
223
243
  }
224
- else
225
- frameElement._content = $env.makeNewWindowMaybeLoad(this,
226
- frameElement.ownerDocument.parentWindow, url);
244
+
245
+
246
+ // change scope of window object creation
247
+ // functions, so that functions/code they create
248
+ // will be scoped to new window object
249
+ // getScope()/setScope() from Window.java
250
+ var scopes = {
251
+ frame : $env.getScope(__frame__),
252
+ window : $env.getScope(local__window__),
253
+ global_load: $env.getScope(load),
254
+ local_load: $env.getScope($env.loadLocalScript)
255
+ };
256
+
257
+ $env.setScope(__frame__, frameWindow);
258
+ $env.setScope(local__window__, frameWindow);
259
+ $env.setScope($env.load, frameWindow);
260
+ $env.setScope($env.loadLocalScript, frameWindow);
261
+
262
+ __frame__();
263
+ frame._content = frameWindow;
264
+
265
+ // now restore the scope
266
+ $env.setScope(__frame__, scopes.frame);
267
+ $env.setScope(local__window__, scopes.window);
268
+ $env.setScope($env.load, scopes.global_load);
269
+ $env.setScope($env.loadLocalScript, scopes.local_load);
227
270
  } catch(e){
228
271
  $env.error("failed to load frame content: from " + url, e);
229
272
  }
230
- };
231
-
232
- $env.reloadAWindowProxy = function(oldWindowProxy, url){
233
- var newWindowProxy = $env.makeNewWindowMaybeLoad(
234
- oldWindowProxy.opener,
235
- oldWindowProxy.parent,
236
- url);
237
- var newWindow = newWindowProxy.__proto__;
238
-
239
- oldWindowProxy.__proto__ = newWindow;
240
- newWindow.$thisWindowsProxyObject = oldWindowProxy;
241
- newWindow.document._parentWindow = oldWindowProxy;
242
- };
243
-
244
- $env.makeNewWindowMaybeLoad = function(openingWindow, parentArg, url){
245
- var newWindow = $env.getFreshScopeObj();
246
- var newProxy = $env.getProxyFor(newWindow);
247
- newWindow.$thisWindowsProxyObject = newProxy;
248
-
249
- var local__window__ = $env.window,
250
- local_env = $env,
251
- local_opener = openingWindow,
252
- local_parent = parentArg ? parentArg : newWindow;
253
-
254
- var inNewContext = function(){
255
- local__window__(newWindow, // object to "window-ify"
256
- local_env, // our scope for globals
257
- local_parent, // win's "parent"
258
- local_opener, // win's "opener"
259
- local_parent.top, // win's "top"
260
- false // this win isn't the original
261
- );
262
- if (url)
263
- newWindow.__loadAWindowsDocument__(url);
264
- };
265
273
 
266
- var scopes = recordScopesOfKeyObjects(inNewContext);
267
- setScopesOfKeyObjects(inNewContext, newWindow);
268
- inNewContext(); // invoke local fn to window-ify new scope object
269
- restoreScopesOfKeyObjects(inNewContext, scopes);
270
- return newProxy;
271
274
  };
272
-
273
- function recordScopesOfKeyObjects(fnToExecInOtherContext){
274
- return { // getScope()/setScope() from Window.java
275
- frame : $env.getScope(fnToExecInOtherContext),
276
- window : $env.getScope($env.window),
277
- global_load : $env.getScope($env.loadIntoFnsScope),
278
- local_load : $env.getScope($env.loadLocalScript)
279
- };
280
- }
281
-
282
- function setScopesOfKeyObjects(fnToExecInOtherContext, windowObj){
283
- $env.setScope(fnToExecInOtherContext, windowObj);
284
- $env.setScope($env.window, windowObj);
285
- $env.setScope($env.loadIntoFnsScope, windowObj);
286
- $env.setScope($env.loadLocalScript, windowObj);
287
- }
288
-
289
- function restoreScopesOfKeyObjects(fnToExecInOtherContext, scopes){
290
- $env.setScope(fnToExecInOtherContext, scopes.frame);
291
- $env.setScope($env.window, scopes.window);
292
- $env.setScope($env.loadIntoFnsScope, scopes.global_load);
293
- $env.setScope($env.loadLocalScript, scopes.local_load);
294
- }
295
- })(Envjs);
296
-
297
- /*
275
+
276
+ })(Envjs);/*
298
277
  * env.rhino.js
299
278
  */
300
279
  (function($env){
@@ -635,6 +614,9 @@ var Envjs = function(){
635
614
  $env.lang = java.lang.System.getProperty("user.lang");
636
615
  $env.platform = "Rhino ";//how do we get the version
637
616
 
617
+ //injected by org.mozilla.javascript.tools.envjs.
618
+ $env.load = load;
619
+
638
620
  $env.scriptTypes = {
639
621
  "text/javascript" :false,
640
622
  "text/envjs" :true
@@ -644,12 +626,11 @@ var Envjs = function(){
644
626
  $env.loadInlineScript = function(script){
645
627
  var tmpFile = $env.writeToTempFile(script.text, 'js') ;
646
628
  $env.debug("loading " + tmpFile);
647
- $env.loadIntoFnsScope(tmpFile);
629
+ $env.load(tmpFile);
648
630
  };
649
631
 
650
632
  //injected by org.mozilla.javascript.tools.envjs.
651
- $env.getFreshScopeObj = getFreshScopeObj;
652
- $env.getProxyFor = getProxyFor;
633
+ $env.globalize = globalize;
653
634
  $env.getScope = getScope;
654
635
  $env.setScope = setScope;
655
636
  $env.configureScope = configureScope;
@@ -664,21 +645,17 @@ var Envjs = function(){
664
645
 
665
646
 
666
647
  try {
667
-
668
- Envjs.window = function($w,
648
+
649
+ Envjs.window = function($w,
669
650
  $env,
670
651
  $parentWindow,
671
- $openingWindow,
672
- $initTop,
673
- $thisIsTheOriginalWindow){
674
-
675
- // The Window Object
676
- var __this__ = $w;
677
- $w.__defineGetter__('window', function(){
678
- return __this__;
679
- });
680
- $w.$isOriginalWindow = $thisIsTheOriginalWindow;
681
- $w.$haveCalledWindowLocationSetter = false;
652
+ $initTop){
653
+
654
+ // The Window Object
655
+ var __this__ = $w;
656
+ $w.__defineGetter__('window', function(){
657
+ return __this__;
658
+ });
682
659
 
683
660
  /*
684
661
  * window.js
@@ -734,7 +711,7 @@ var $name;
734
711
 
735
712
  // a read/write reference to the Window object that contained the script that called open() to
736
713
  //open this browser window. This property is valid only for top-level window objects.
737
- var $opener = $openingWindow;
714
+ var $opener;
738
715
 
739
716
  // Read-only properties that specify the total height and width, in pixels, of the browser window.
740
717
  // These dimensions include the height and width of the menu bar, toolbars, scrollbars, window
@@ -746,18 +723,10 @@ var $outerHeight = $innerHeight, $outerWidth = $innerWidth;
746
723
  //to the right and down. These are not supported by IE.
747
724
  var $pageXOffset = 0, $pageYOffset = 0;
748
725
 
749
-
750
- // A read-only reference to the Window object that contains this window
751
- // or frame. If the window is a top-level window, parent refers to
752
- // the window itself. If this window is a frame, this property refers
753
- // to the window or frame that conatins it.
726
+ //A read-only reference to the Window object that contains this window or frame. If the window is
727
+ // a top-level window, parent refers to the window itself. If this window is a frame, this property
728
+ // refers to the window or frame that conatins it.
754
729
  var $parent = $parentWindow;
755
- try {
756
- if ($parentWindow.$thisWindowsProxyObject)
757
- $parent = $parentWindow.$thisWindowsProxyObject;
758
- } catch(e){}
759
-
760
-
761
730
 
762
731
  // a read-only refernce to the Screen object that specifies information about the screen:
763
732
  // the number of available pixels and the number of available colors.
@@ -776,11 +745,6 @@ var $top = $initTop;
776
745
 
777
746
  // the window property is identical to the self property and to this obj
778
747
  var $window = $w;
779
- try {
780
- if ($w.$thisWindowsProxyObject)
781
- $window = $w.$thisWindowsProxyObject;
782
- } catch(e){}
783
-
784
748
 
785
749
  $debug("Initializing Window.");
786
750
  __extend__($w,{
@@ -793,7 +757,7 @@ __extend__($w,{
793
757
  get frames(){return undefined;}, // TODO: not yet any code to maintain list
794
758
  get length(){return undefined;}, // should be frames.length, but.... TODO
795
759
 
796
- //get history(){return $history;}, - see history.js
760
+ //get history(){return $history;}, - see location.js
797
761
  get innerHeight(){return $innerHeight;},
798
762
  get innerWidth(){return $innerWidth;},
799
763
  get clientHeight(){return $innerHeight;},
@@ -821,34 +785,12 @@ __extend__($w,{
821
785
  });
822
786
 
823
787
  $w.open = function(url, name, features, replace){
824
- if (features)
825
- $env.warn("'features' argument for 'window.open()' not yet implemented");
826
- if (replace)
827
- $env.warn("'replace' argument for 'window.open()' not yet implemented");
828
-
829
- var newWindow = $env.makeNewWindowMaybeLoad(this, null, url);
830
- newWindow.$name = name;
831
- return newWindow;
788
+ //TODO. Remember to set $opener, $name
832
789
  };
833
790
 
834
791
  $w.close = function(){
835
- $env.$unloadEventsFor($w);
836
- $closed = true;
792
+ //TODO. Remember to set $closed
837
793
  };
838
-
839
- $env.$unloadEventsFor = function(windowToUnload){
840
- try {
841
- var event = windowToUnload.document.createEvent();
842
- event.initEvent("unload");
843
- windowToUnload.document.getElementsByTagName('body')[0].
844
- dispatchEvent(event, false);
845
- }
846
- catch (e){} // maybe no/bad document loaded, ignore
847
-
848
- var event = windowToUnload.document.createEvent();
849
- event.initEvent("unload");
850
- windowToUnload.dispatchEvent(event, false);
851
- };
852
794
 
853
795
  /* Time related functions - see timer.js
854
796
  * - clearTimeout
@@ -2792,7 +2734,7 @@ $debug("Defining DOMParser");
2792
2734
  var DOMParser = function(){};
2793
2735
  __extend__(DOMParser.prototype,{
2794
2736
  parseFromString: function(xmlString){
2795
- $debug("Parsing XML String: " +xmlString);
2737
+ //$log("Parsing XML String: " +xmlString);
2796
2738
  return document.implementation.createDocument().loadXML(xmlString);
2797
2739
  }
2798
2740
  });
@@ -4275,17 +4217,14 @@ var DOMImplementation = function() {
4275
4217
 
4276
4218
  var __endHTMLElement__ = function(node, doc, p){
4277
4219
  if(node.nodeName.toLowerCase() == 'script'){
4278
- // unless we're parsing in a window context, don't execute scripts
4279
- if (doc.parentWindow){
4280
- p.replaceEntities = true;
4281
- $env.loadLocalScript(node, p);
4282
-
4283
- // only fire event if we actually had something to load
4284
- if (node.src && node.src.length > 0){
4285
- var event = doc.createEvent();
4286
- event.initEvent("load");
4287
- node.dispatchEvent( event, false );
4288
- }
4220
+ p.replaceEntities = true;
4221
+ $env.loadLocalScript(node, p);
4222
+
4223
+ // only fire event if we actually had something to load
4224
+ if (node.src && node.src.length > 0){
4225
+ var event = doc.createEvent();
4226
+ event.initEvent("load");
4227
+ node.dispatchEvent( event, false );
4289
4228
  }
4290
4229
  }
4291
4230
  else if (node.nodeName.toLowerCase() == 'frame' ||
@@ -4341,7 +4280,7 @@ __extend__(DOMImplementation.prototype,{
4341
4280
  createDocument : function(nsuri, qname, doctype){
4342
4281
  //TODO - this currently returns an empty doc
4343
4282
  //but needs to handle the args
4344
- return new HTMLDocument($implementation, null, "");
4283
+ return new HTMLDocument($implementation, null);
4345
4284
  },
4346
4285
  translateErrCode : function(code) {
4347
4286
  //convert DOMException Code to human readable error message;
@@ -4892,14 +4831,8 @@ var DOMDocument = function(implementation, docParentWindow) {
4892
4831
  this.doctype = null; // The Document Type Declaration (see DocumentType) associated with this document
4893
4832
  this.implementation = implementation; // The DOMImplementation object that handles this document.
4894
4833
  this._documentElement = null; // "private" variable providing the read-only document.documentElement property
4895
-
4896
- // "private" variable providing the read-only document.parentWindow property
4897
- this._parentWindow = docParentWindow;
4898
- try {
4899
- if (docParentWindow.$thisWindowsProxyObject)
4900
- this._parentWindow = docParentWindow.$thisWindowsProxyObject;
4901
- } catch(e){}
4902
-
4834
+ this._parentWindow = docParentWindow; // "private" variable providing the read-only document.parentWindow property
4835
+
4903
4836
  this.nodeName = "#document";
4904
4837
  this._id = 0;
4905
4838
  this._lastId = 0;
@@ -5640,14 +5573,13 @@ $debug("Defining HTMLDocument");
5640
5573
  *
5641
5574
  * @extends DOMDocument
5642
5575
  */
5643
- var HTMLDocument = function(implementation, docParentWindow, docReferrer) {
5576
+ var HTMLDocument = function(implementation, docParentWindow) {
5644
5577
  this.DOMDocument = DOMDocument;
5645
5578
  this.DOMDocument(implementation, docParentWindow);
5646
5579
 
5647
- this._referrer = docReferrer;
5580
+ this._refferer = "";
5648
5581
  this._domain;
5649
5582
  this._open = false;
5650
- this.$async = false;
5651
5583
  };
5652
5584
  HTMLDocument.prototype = new DOMDocument;
5653
5585
  __extend__(HTMLDocument.prototype, {
@@ -5784,7 +5716,14 @@ __extend__(HTMLDocument.prototype, {
5784
5716
  return $w.location
5785
5717
  },
5786
5718
  get referrer(){
5787
- return this._referrer;
5719
+ /* TODO */
5720
+ return this._refferer;
5721
+
5722
+ },
5723
+ get URL(){
5724
+ /* TODO*/
5725
+ return this._url;
5726
+
5788
5727
  },
5789
5728
  close : function(){
5790
5729
  /* TODO */
@@ -5826,12 +5765,7 @@ __extend__(HTMLDocument.prototype, {
5826
5765
  get __html__(){
5827
5766
  return true;
5828
5767
 
5829
- },
5830
- get async(){ return this.$async;},
5831
- set async(async){ this.$async = async; },
5832
- get baseURI(){ return $env.location('./'); },
5833
- get URL(){ return $w.location.href; },
5834
- set URL(url){ $w.location.href = url; }
5768
+ }
5835
5769
  });
5836
5770
 
5837
5771
  $w.HTMLDocument = HTMLDocument;
@@ -6195,275 +6129,7 @@ $w.HTMLCollection = HTMLCollection;
6195
6129
  });
6196
6130
  };*/
6197
6131
 
6198
- /*
6199
- * a set of convenience classes to centralize implementation of
6200
- * properties and methods across multiple in-form elements
6201
- *
6202
- * the hierarchy of related HTML elements and their members is as follows:
6203
- *
6204
- *
6205
- * HTMLInputCommon: common to all elements
6206
- * .form
6207
- *
6208
- * <legend>
6209
- * [common plus:]
6210
- * .align
6211
- *
6212
- * <fieldset>
6213
- * [identical to "legend" plus:]
6214
- * .margin
6215
- *
6216
- *
6217
- * ****
6218
- *
6219
- * <label>
6220
- * [common plus:]
6221
- * .dataFormatAs
6222
- * .htmlFor
6223
- * [plus data properties]
6224
- *
6225
- * <option>
6226
- * [common plus:]
6227
- * .defaultSelected
6228
- * .index
6229
- * .label
6230
- * .selected
6231
- * .text
6232
- * .value // unique implementation, not duplicated
6233
- *
6234
- * ****
6235
- *
6236
- * HTMLTypeValueInputs: common to remaining elements
6237
- * [common plus:]
6238
- * .name
6239
- * .type
6240
- * .value
6241
- * [plus data properties]
6242
- *
6243
- *
6244
- * <select>
6245
- * .length
6246
- * .multiple
6247
- * .options[]
6248
- * .selectedIndex
6249
- * .add()
6250
- * .remove()
6251
- * .item() // unimplemented
6252
- * .namedItem() // unimplemented
6253
- * [plus ".onchange"]
6254
- * [plus focus events]
6255
- * [plus data properties]
6256
- * [plus ".size"]
6257
- *
6258
- * <button>
6259
- * .dataFormatAs // duplicated from above, oh well....
6260
- * [plus ".status", ".createTextRange()"]
6261
- *
6262
- * ****
6263
- *
6264
- * HTMLInputAreaCommon: common to remaining elements
6265
- * .defaultValue
6266
- * .readOnly
6267
- * .handleEvent() // unimplemented
6268
- * .select()
6269
- * .onselect
6270
- * [plus ".size"]
6271
- * [plus ".status", ".createTextRange()"]
6272
- * [plus focus events]
6273
- * [plus ".onchange"]
6274
- *
6275
- * <textarea>
6276
- * .cols
6277
- * .rows
6278
- * .wrap // unimplemented
6279
- * .onscroll // unimplemented
6280
- *
6281
- * <input>
6282
- * .alt
6283
- * .accept // unimplemented
6284
- * .checked
6285
- * .complete // unimplemented
6286
- * .defaultChecked
6287
- * .dynsrc // unimplemented
6288
- * .height
6289
- * .hspace // unimplemented
6290
- * .indeterminate // unimplemented
6291
- * .loop // unimplemented
6292
- * .lowsrc // unimplemented
6293
- * .maxLength
6294
- * .src
6295
- * .start // unimplemented
6296
- * .useMap
6297
- * .vspace // unimplemented
6298
- * .width
6299
- * .onclick
6300
- * [plus ".size"]
6301
- * [plus ".status", ".createTextRange()"]
6302
-
6303
- * [data properties] // unimplemented
6304
- * .dataFld
6305
- * .dataSrc
6306
-
6307
- * [status stuff] // unimplemented
6308
- * .status
6309
- * .createTextRange()
6310
-
6311
- * [focus events]
6312
- * .onblur
6313
- * .onfocus
6314
-
6315
- */
6316
-
6317
-
6318
-
6319
-
6320
- $debug("Defining input element 'mix in' objects");
6321
- var inputElements_dataProperties = {};
6322
- var inputElements_status = {};
6323
-
6324
- var inputElements_onchange = {
6325
- onchange: function(event){
6326
- __eval__(this.getAttribute('onchange')||'', this)
6327
- }
6328
- };
6329
-
6330
- var inputElements_size = {
6331
- get size(){
6332
- return Number(this.getAttribute('size'));
6333
- },
6334
- set size(value){
6335
- this.setAttribute('size',value);
6336
- }
6337
- };
6338
-
6339
- var inputElements_focusEvents = {
6340
- blur: function(){
6341
- __blur__(this);
6342
-
6343
- if (this._oldValue != this.value){
6344
- var event = document.createEvent();
6345
- event.initEvent("change");
6346
- this.dispatchEvent( event );
6347
- }
6348
- },
6349
- focus: function(){
6350
- __focus__(this);
6351
- this._oldValue = this.value;
6352
- }
6353
- };
6354
-
6355
-
6356
- $debug("Defining HTMLInputCommon");
6357
-
6358
- /*
6359
- * HTMLInputCommon - convenience class, not DOM
6360
- */
6361
- var HTMLInputCommon = function(ownerDocument) {
6362
- this.HTMLElement = HTMLElement;
6363
- this.HTMLElement(ownerDocument);
6364
- };
6365
- HTMLInputCommon.prototype = new HTMLElement;
6366
- __extend__(HTMLInputCommon.prototype, {
6367
- get form(){
6368
- var parent = this.parentNode;
6369
- while(parent.nodeName.toLowerCase() != 'form'){
6370
- parent = parent.parentNode;
6371
- }
6372
- return parent;
6373
- },
6374
- get accessKey(){
6375
- return this.getAttribute('accesskey');
6376
- },
6377
- set accessKey(value){
6378
- this.setAttribute('accesskey',value);
6379
- },
6380
- get access(){
6381
- return this.getAttribute('access');
6382
- },
6383
- set access(value){
6384
- this.setAttribute('access', value);
6385
- },
6386
- get disabled(){
6387
- return (this.getAttribute('disabled')=='disabled');
6388
- },
6389
- set disabled(value){
6390
- this.setAttribute('disabled', (value ? 'disabled' :''));
6391
- }
6392
- });
6393
-
6394
- $w.HTMLInputCommon = HTMLInputCommon;
6395
-
6396
-
6397
- $debug("Defining HTMLTypeValueInputs");
6398
-
6399
- /*
6400
- * HTMLTypeValueInputs - convenience class, not DOM
6401
- */
6402
- var HTMLTypeValueInputs = function(ownerDocument) {
6403
- this.HTMLInputCommon = HTMLInputCommon;
6404
- this.HTMLInputCommon(ownerDocument);
6405
-
6406
- this._oldValue = "";
6407
- };
6408
- HTMLTypeValueInputs.prototype = new HTMLInputCommon;
6409
- __extend__(HTMLTypeValueInputs.prototype, inputElements_size);
6410
- __extend__(HTMLTypeValueInputs.prototype, inputElements_status);
6411
- __extend__(HTMLTypeValueInputs.prototype, inputElements_dataProperties);
6412
- __extend__(HTMLTypeValueInputs.prototype, {
6413
- get name(){
6414
- return this.getAttribute('name')||'';
6415
- },
6416
- set name(value){
6417
- this.setAttribute('name',value);
6418
- },
6419
- get type(){
6420
- return this.getAttribute('type');
6421
- },
6422
- get value(){
6423
- return this.getAttribute('value')||'';
6424
- },
6425
- set value(newValue){
6426
- this.setAttribute('value',newValue);
6427
- }
6428
- });
6429
-
6430
- $w.HTMLTypeValueInputs = HTMLTypeValueInputs;
6431
-
6432
-
6433
-
6434
- $debug("Defining HTMLInputAreaCommon");
6435
-
6436
- /*
6437
- * HTMLInputAreaCommon - convenience class, not DOM
6438
- */
6439
- var HTMLInputAreaCommon = function(ownerDocument) {
6440
- this.HTMLTypeValueInputs = HTMLTypeValueInputs;
6441
- this.HTMLTypeValueInputs(ownerDocument);
6442
- };
6443
- HTMLInputAreaCommon.prototype = new HTMLTypeValueInputs;
6444
- __extend__(HTMLInputAreaCommon.prototype, inputElements_focusEvents);
6445
- __extend__(HTMLInputAreaCommon.prototype, inputElements_onchange);
6446
- __extend__(HTMLInputAreaCommon.prototype, {
6447
- get defaultValue(){
6448
- return this.getAttribute('defaultValue');
6449
- },
6450
- set defaultValue(value){
6451
- this.setAttribute('defaultValue', value);
6452
- },
6453
- get readOnly(){
6454
- return (this.getAttribute('readonly')=='readonly');
6455
- },
6456
- set readOnly(value){
6457
- this.setAttribute('readonly', (value ? 'readonly' :''));
6458
- },
6459
- select:function(){
6460
- __select__(this);
6461
-
6462
- }
6463
- });
6464
-
6465
- $w.HTMLInputAreaCommon = HTMLInputAreaCommon;
6466
- $debug("Defining HTMLAnchorElement");
6132
+ $debug("Defining HTMLAnchorElement");
6467
6133
  /*
6468
6134
  * HTMLAnchorElement - DOM Level 2
6469
6135
  */
@@ -6763,35 +6429,54 @@ HTMLBodyElement.prototype = new HTMLElement;
6763
6429
  __extend__(HTMLBodyElement.prototype, {
6764
6430
  onload: function(event){
6765
6431
  __eval__(this.getAttribute('onload')||'', this)
6766
- },
6767
- onunload: function(event){
6768
- __eval__(this.getAttribute('onunload')||'', this)
6769
6432
  }
6770
6433
  });
6771
6434
 
6772
6435
  $w.HTMLBodyElement = HTMLBodyElement;
6773
6436
  $debug("Defining HTMLButtonElement");
6774
- /*
6437
+ /*
6775
6438
  * HTMLButtonElement - DOM Level 2
6776
6439
  */
6777
6440
  var HTMLButtonElement = function(ownerDocument) {
6778
- this.HTMLTypeValueInputs = HTMLTypeValueInputs;
6779
- this.HTMLTypeValueInputs(ownerDocument);
6441
+ this.HTMLElement = HTMLElement;
6442
+ this.HTMLElement(ownerDocument);
6780
6443
  };
6781
- HTMLButtonElement.prototype = new HTMLTypeValueInputs;
6782
- __extend__(HTMLButtonElement.prototype, inputElements_status);
6444
+ HTMLButtonElement.prototype = new HTMLElement;
6783
6445
  __extend__(HTMLButtonElement.prototype, {
6784
- get dataFormatAs(){
6785
- return this.getAttribute('dataFormatAs');
6446
+ get form(){
6447
+ var parent = this.parent;
6448
+ while(parent.nodeName.toLowerCase() != 'form'){
6449
+ parent = parent.parent;
6450
+ }
6451
+ return parent;
6452
+ },
6453
+ get accessKey(){
6454
+ return this.getAttribute('accesskey');
6455
+ },
6456
+ set accessKey(value){
6457
+ this.setAttribute('accesskey',value);
6458
+ },
6459
+ /*get tabIndex(){
6460
+ return Number(this.getAttribute('tabindex'));
6461
+ },
6462
+ set tabIndex(value){
6463
+ this.setAttribute('tabindex',Number(value));
6464
+ },*/
6465
+ get type(){
6466
+ return this.getAttribute('type');
6786
6467
  },
6787
- set dataFormatAs(value){
6788
- this.setAttribute('dataFormatAs',value);
6468
+ set type(value){
6469
+ this.setAttribute('type',value);
6470
+ },
6471
+ get value(){
6472
+ return this.getAttribute('value');
6473
+ },
6474
+ set value(value){
6475
+ this.setAttribute('value',value);
6789
6476
  }
6790
6477
  });
6791
6478
 
6792
- $w.HTMLButtonElement = HTMLButtonElement;
6793
-
6794
- $debug("Defining HTMLTableColElement");
6479
+ $w.HTMLButtonElement = HTMLButtonElement; $debug("Defining HTMLTableColElement");
6795
6480
  /*
6796
6481
  * HTMLTableColElement - DOM Level 2
6797
6482
  */
@@ -6892,45 +6577,26 @@ __extend__(HTMLDivElement.prototype, {
6892
6577
  });
6893
6578
 
6894
6579
  $w.HTMLDivElement = HTMLDivElement;
6895
- $debug("Defining HTMLLegendElement");
6896
- /*
6897
- * HTMLLegendElement - DOM Level 2
6898
- */
6899
- var HTMLLegendElement = function(ownerDocument) {
6900
- this.HTMLInputCommon = HTMLInputCommon;
6901
- this.HTMLInputCommon(ownerDocument);
6902
- };
6903
- HTMLLegendElement.prototype = new HTMLInputCommon;
6904
- __extend__(HTMLLegendElement.prototype, {
6905
- get align(){
6906
- return this.getAttribute('align');
6907
- },
6908
- set align(value){
6909
- this.setAttribute('align',value);
6910
- }
6911
- });
6912
-
6913
- $w.HTMLLegendElement = HTMLLegendElement;
6914
6580
  $debug("Defining HTMLFieldSetElement");
6915
- /*
6581
+ /*
6916
6582
  * HTMLFieldSetElement - DOM Level 2
6917
6583
  */
6918
6584
  var HTMLFieldSetElement = function(ownerDocument) {
6919
- this.HTMLLegendElement = HTMLLegendElement;
6920
- this.HTMLLegendElement(ownerDocument);
6585
+ this.HTMLElement = HTMLElement;
6586
+ this.HTMLElement(ownerDocument);
6921
6587
  };
6922
- HTMLFieldSetElement.prototype = new HTMLLegendElement;
6588
+ HTMLFieldSetElement.prototype = new HTMLElement;
6923
6589
  __extend__(HTMLFieldSetElement.prototype, {
6924
- get margin(){
6925
- return this.getAttribute('margin');
6926
- },
6927
- set margin(value){
6928
- this.setAttribute('margin',value);
6590
+ get form(){
6591
+ var parent = this.parent;
6592
+ while(parent.nodeName.toLowerCase() != 'form'){
6593
+ parent = parent.parent;
6594
+ }
6595
+ return parent;
6929
6596
  }
6930
6597
  });
6931
6598
 
6932
- $w.HTMLFieldSetElement = HTMLFieldSetElement;
6933
- $debug("Defining HTMLFormElement");
6599
+ $w.HTMLFieldSetElement = HTMLFieldSetElement; $debug("Defining HTMLFormElement");
6934
6600
  /*
6935
6601
  * HTMLFormElement - DOM Level 2
6936
6602
  */
@@ -7241,18 +6907,48 @@ __extend__(HTMLImageElement.prototype, {
7241
6907
  });
7242
6908
 
7243
6909
  $w.HTMLImageElement = HTMLImageElement;$debug("Defining HTMLInputElement");
7244
- /*
6910
+ /*
7245
6911
  * HTMLInputElement - DOM Level 2
7246
6912
  */
7247
6913
  var HTMLInputElement = function(ownerDocument) {
7248
- this.HTMLInputAreaCommon = HTMLInputAreaCommon;
7249
- this.HTMLInputAreaCommon(ownerDocument);
6914
+ this.HTMLElement = HTMLElement;
6915
+ this.HTMLElement(ownerDocument);
6916
+
6917
+ this._oldValue = "";
7250
6918
  };
7251
- HTMLInputElement.prototype = new HTMLInputAreaCommon;
6919
+ HTMLInputElement.prototype = new HTMLElement;
7252
6920
  __extend__(HTMLInputElement.prototype, {
7253
- get alt(){
7254
- return this.getAttribute('alt');
7255
- },
6921
+ get defaultValue(){
6922
+ return this.getAttribute('defaultValue');
6923
+ },
6924
+ set defaultValue(value){
6925
+ this.setAttribute('defaultValue', value);
6926
+ },
6927
+ get defaultChecked(){
6928
+ return this.getAttribute('defaultChecked');
6929
+ },
6930
+ get form(){
6931
+ var parent = this.parent;
6932
+ while(parent.nodeName.toLowerCase() != 'form'){
6933
+ parent = parent.parent;
6934
+ }
6935
+ return parent;
6936
+ },
6937
+ get accessKey(){
6938
+ return this.getAttribute('accesskey');
6939
+ },
6940
+ set accessKey(value){
6941
+ this.setAttribute('accesskey',value);
6942
+ },
6943
+ get access(){
6944
+ return this.getAttribute('access');
6945
+ },
6946
+ set access(value){
6947
+ this.setAttribute('access', value);
6948
+ },
6949
+ get alt(){
6950
+ return this.getAttribute('alt');
6951
+ },
7256
6952
  set alt(value){
7257
6953
  this.setAttribute('alt', value);
7258
6954
  },
@@ -7262,14 +6958,11 @@ __extend__(HTMLInputElement.prototype, {
7262
6958
  set checked(value){
7263
6959
  this.setAttribute('checked', (value ? 'checked' :''));
7264
6960
  },
7265
- get defaultChecked(){
7266
- return this.getAttribute('defaultChecked');
7267
- },
7268
- get height(){
7269
- return this.getAttribute('height');
6961
+ get disabled(){
6962
+ return (this.getAttribute('disabled')=='disabled');
7270
6963
  },
7271
- set height(value){
7272
- this.setAttribute('height',value);
6964
+ set disabled(value){
6965
+ this.setAttribute('disabled', (value ? 'disabled' :''));
7273
6966
  },
7274
6967
  get maxLength(){
7275
6968
  return Number(this.getAttribute('maxlength')||'0');
@@ -7277,55 +6970,136 @@ __extend__(HTMLInputElement.prototype, {
7277
6970
  set maxLength(value){
7278
6971
  this.setAttribute('maxlength', value);
7279
6972
  },
6973
+ get name(){
6974
+ return this.getAttribute('name')||'';
6975
+ },
6976
+ set name(value){
6977
+ this.setAttribute('name', value);
6978
+ },
6979
+ get readOnly(){
6980
+ return (this.getAttribute('readonly')=='readonly');
6981
+ },
6982
+ set readOnly(value){
6983
+ this.setAttribute('readonly', (value ? 'readonly' :''));
6984
+ },
6985
+ get size(){
6986
+ return this.getAttribute('size');
6987
+ },
6988
+ set size(value){
6989
+ this.setAttribute('size', value);
6990
+ },
7280
6991
  get src(){
7281
6992
  return this.getAttribute('src');
7282
6993
  },
7283
6994
  set src(value){
7284
6995
  this.setAttribute('src', value);
7285
6996
  },
6997
+ /*get tabIndex(){
6998
+ return Number(this.getAttribute('tabindex'));
6999
+ },
7000
+ set tabIndex(value){
7001
+ this.setAttribute('tabindex',Number(value));
7002
+ },*/
7003
+ get type(){
7004
+ return this.getAttribute('type');
7005
+ },
7006
+ set type(value){
7007
+ this.setAttribute('type',value);
7008
+ },
7286
7009
  get useMap(){
7287
7010
  return this.getAttribute('map');
7288
7011
  },
7289
- get width(){
7290
- return this.getAttribute('width');
7012
+ get value(){
7013
+ return this.getAttribute('value');
7291
7014
  },
7292
- set width(value){
7293
- this.setAttribute('width',value);
7015
+ set value(value){
7016
+ if(this.defaultValue===null&&this.value!==null)
7017
+ this.defaultValue = this.value;
7018
+ this.setAttribute('value',value);
7294
7019
  },
7295
- click:function(){
7296
- __click__(this);
7020
+ blur:function(){
7021
+ __blur__(this);
7022
+
7023
+ if (this._oldValue != this.value){
7024
+ var event = document.createEvent();
7025
+ event.initEvent("change");
7026
+ this.dispatchEvent( event );
7027
+ }
7028
+ },
7029
+ focus:function(){
7030
+ __focus__(this);
7031
+ this._oldValue = this.value;
7032
+ },
7033
+ select:function(){
7034
+ __select__(this);
7035
+
7036
+ },
7037
+ click:function(){
7038
+ __click__(this);
7039
+
7040
+ },
7041
+ onchange: function(event){
7042
+ __eval__(this.getAttribute('onchange')||'', this)
7297
7043
  }
7298
7044
  });
7299
7045
 
7300
- $w.HTMLInputElement = HTMLInputElement;
7301
-
7302
- $debug("Defining HTMLLabelElement");
7046
+ $w.HTMLInputElement = HTMLInputElement;$debug("Defining HTMLLabelElement");
7303
7047
  /*
7304
7048
  * HTMLLabelElement - DOM Level 2
7305
7049
  */
7306
7050
  var HTMLLabelElement = function(ownerDocument) {
7307
- this.HTMLInputCommon = HTMLInputCommon;
7308
- this.HTMLInputCommon(ownerDocument);
7051
+ this.HTMLElement = HTMLElement;
7052
+ this.HTMLElement(ownerDocument);
7309
7053
  };
7310
- HTMLLabelElement.prototype = new HTMLInputCommon;
7311
- __extend__(HTMLLabelElement.prototype, inputElements_dataProperties);
7054
+ HTMLLabelElement.prototype = new HTMLElement;
7312
7055
  __extend__(HTMLLabelElement.prototype, {
7056
+ get form(){
7057
+ var parent = this.parent;
7058
+ while(parent.nodeName.toLowerCase() != 'form'){
7059
+ parent = parent.parent;
7060
+ }
7061
+ return parent;
7062
+ },
7063
+ get accessKey(){
7064
+ return this.getAttribute('accesskey');
7065
+ },
7066
+ set accessKey(value){
7067
+ this.setAttribute('accesskey',value);
7068
+ },
7313
7069
  get htmlFor(){
7314
7070
  return this.getAttribute('for');
7315
7071
  },
7316
7072
  set htmlFor(value){
7317
7073
  this.setAttribute('for',value);
7074
+ }
7075
+ });
7076
+
7077
+ $w.HTMLLabelElement = HTMLLabelElement; $debug("Defining HTMLLegendElement");
7078
+ /*
7079
+ * HTMLLegendElement - DOM Level 2
7080
+ */
7081
+ var HTMLLegendElement = function(ownerDocument) {
7082
+ this.HTMLElement = HTMLElement;
7083
+ this.HTMLElement(ownerDocument);
7084
+ };
7085
+ HTMLLegendElement.prototype = new HTMLElement;
7086
+ __extend__(HTMLLegendElement.prototype, {
7087
+ get form(){
7088
+ var parent = this.parent;
7089
+ while(parent.nodeName.toLowerCase() != 'form'){
7090
+ parent = parent.parent;
7091
+ }
7092
+ return parent;
7318
7093
  },
7319
- get dataFormatAs(){
7320
- return this.getAttribute('dataFormatAs');
7094
+ get accessKey(){
7095
+ return this.getAttribute('accesskey');
7321
7096
  },
7322
- set dataFormatAs(value){
7323
- this.setAttribute('dataFormatAs',value);
7097
+ set accessKey(value){
7098
+ this.setAttribute('accesskey',value);
7324
7099
  }
7325
7100
  });
7326
7101
 
7327
- $w.HTMLLabelElement = HTMLLabelElement;
7328
- /**
7102
+ $w.HTMLLegendElement = HTMLLegendElement; /**
7329
7103
  * Link - HTMLElement
7330
7104
  */
7331
7105
  $w.__defineGetter__("Link", function(){
@@ -7576,21 +7350,33 @@ __extend__(HTMLOptGroupElement.prototype, {
7576
7350
  });
7577
7351
 
7578
7352
  $w.HTMLOptGroupElement = HTMLOptGroupElement; $debug("Defining HTMLOptionElement");
7579
- /*
7353
+ /*
7580
7354
  * HTMLOptionElement - DOM Level 2
7581
7355
  */
7582
7356
  var HTMLOptionElement = function(ownerDocument) {
7583
- this.HTMLInputCommon = HTMLInputCommon;
7584
- this.HTMLInputCommon(ownerDocument);
7357
+ this.HTMLElement = HTMLElement;
7358
+ this.HTMLElement(ownerDocument);
7585
7359
  };
7586
- HTMLOptionElement.prototype = new HTMLInputCommon;
7360
+ HTMLOptionElement.prototype = new HTMLElement;
7587
7361
  __extend__(HTMLOptionElement.prototype, {
7362
+ get form(){
7363
+ var parent = this.parent;
7364
+ while(parent.nodeName.toLowerCase() != 'form'){
7365
+ parent = parent.parent;
7366
+ }
7367
+ return parent;
7368
+ },
7588
7369
  get defaultSelected(){
7589
7370
  return this.getAttribute('defaultSelected');
7590
7371
  },
7591
7372
  set defaultSelected(value){
7592
7373
  this.setAttribute('defaultSelected',value);
7593
7374
  },
7375
+ get text(){
7376
+ return ((this.nodeValue === null) || (this.nodeValue ===undefined)) ?
7377
+ this.innerHTML :
7378
+ this.nodeValue;
7379
+ },
7594
7380
  get index(){
7595
7381
  var options = this.parent.childNodes;
7596
7382
  for(var i; i<options.length;i++){
@@ -7599,6 +7385,12 @@ __extend__(HTMLOptionElement.prototype, {
7599
7385
  }
7600
7386
  return -1;
7601
7387
  },
7388
+ get disabled(){
7389
+ return this.getAttribute('disabled');
7390
+ },
7391
+ set disabled(value){
7392
+ this.setAttribute('disabled',value);
7393
+ },
7602
7394
  get label(){
7603
7395
  return this.getAttribute('label');
7604
7396
  },
@@ -7613,14 +7405,9 @@ __extend__(HTMLOptionElement.prototype, {
7613
7405
  this.defaultSelected = this.selected;
7614
7406
  this.setAttribute('selected', (value ? 'selected' :''));
7615
7407
  },
7616
- get text(){
7617
- return ((this.nodeValue === null) || (this.nodeValue ===undefined)) ?
7618
- this.innerHTML :
7619
- this.nodeValue;
7620
- },
7621
7408
  get value(){
7622
7409
  return ((this.getAttribute('value') === undefined) || (this.getAttribute('value') === null)) ?
7623
- this.text :
7410
+ this.text :
7624
7411
  this.getAttribute('value');
7625
7412
  },
7626
7413
  set value(value){
@@ -7741,79 +7528,119 @@ $w.HTMLScriptElement = HTMLScriptElement;$debug("Defining HTMLSelectElement");
7741
7528
  * HTMLSelectElement - DOM Level 2
7742
7529
  */
7743
7530
  var HTMLSelectElement = function(ownerDocument) {
7744
- this.HTMLTypeValueInputs = HTMLTypeValueInputs;
7745
- this.HTMLTypeValueInputs(ownerDocument);
7531
+ this.HTMLElement = HTMLElement;
7532
+ this.HTMLElement(ownerDocument);
7746
7533
 
7747
7534
  this._oldIndex = -1;
7748
7535
  };
7749
- HTMLSelectElement.prototype = new HTMLTypeValueInputs;
7750
- __extend__(HTMLSelectElement.prototype, inputElements_dataProperties);
7751
- __extend__(HTMLButtonElement.prototype, inputElements_size);
7752
- __extend__(HTMLSelectElement.prototype, inputElements_onchange);
7753
- __extend__(HTMLSelectElement.prototype, inputElements_focusEvents);
7536
+ HTMLSelectElement.prototype = new HTMLElement;
7754
7537
  __extend__(HTMLSelectElement.prototype, {
7755
-
7756
- // over-ride the value setter in HTMLTypeValueInputs
7757
- set value(newValue) {
7538
+ get type(){
7539
+ return this.getAttribute('type');
7540
+ },
7541
+ get selectedIndex(){
7542
+ var options = this.options;
7543
+ for(var i=0;i<options.length;i++){
7544
+ if(options[i].selected){
7545
+ return i;
7546
+ }
7547
+ };
7548
+ return -1;
7549
+ },
7550
+ set selectedIndex(value){
7551
+ if (this.selectedIndex != -1) {
7552
+ this.options[this.selectedIndex].selected = '';
7553
+ }
7554
+ var option = this.options[Number(value)];
7555
+ if (option) {
7556
+ option.selected = 'selected';
7557
+ }
7558
+ },
7559
+ get value(){
7560
+ return this.getAttribute('value')||'';
7561
+ },
7562
+ set value(value) {
7758
7563
  var options = this.options,
7759
7564
  i, index;
7760
7565
  for (i=0; i<options.length; i++) {
7761
- if (options[i].value == newValue) {
7566
+ if (options[i].value == value) {
7762
7567
  index = i;
7763
7568
  break;
7764
7569
  }
7765
7570
  }
7766
7571
  if (index !== undefined) {
7767
- this.setAttribute('value', newValue);
7572
+ this.setAttribute('value', value);
7768
7573
  this.selectedIndex = index;
7769
7574
  }
7770
7575
  },
7771
- get value(){ // if we only over-ride one, then getter becomes undefined
7772
- return this.getAttribute('value')||'';
7773
- },
7774
-
7775
7576
  get length(){
7776
7577
  return this.options.length;
7777
7578
  },
7579
+ get form(){
7580
+ var parent = this.parent;
7581
+ while(parent.nodeName.toLowerCase() != 'form'){
7582
+ parent = parent.parent;
7583
+ }
7584
+ return parent;
7585
+ },
7586
+ get options(){
7587
+ return this.getElementsByTagName('option');
7588
+ },
7589
+ get disabled(){
7590
+ return (this.getAttribute('disabled')=='disabled');
7591
+ },
7592
+ set disabled(value){
7593
+ this.setAttribute('disabled', (value ? 'disabled' :''));
7594
+ },
7778
7595
  get multiple(){
7779
7596
  return this.getAttribute('multiple');
7780
7597
  },
7781
7598
  set multiple(value){
7782
7599
  this.setAttribute('multiple',value);
7783
7600
  },
7784
- get options(){
7785
- return this.getElementsByTagName('option');
7601
+ get name(){
7602
+ return this.getAttribute('name')||'';
7786
7603
  },
7787
- get selectedIndex(){
7788
- var options = this.options;
7789
- for(var i=0;i<options.length;i++){
7790
- if(options[i].selected){
7791
- return i;
7792
- }
7793
- };
7794
- return -1;
7604
+ set name(value){
7605
+ this.setAttribute('name',value);
7795
7606
  },
7796
- set selectedIndex(value){
7797
- if (this.selectedIndex != -1) {
7798
- this.options[this.selectedIndex].selected = '';
7799
- }
7800
- var option = this.options[Number(value)];
7801
- if (option) {
7802
- option.selected = 'selected';
7803
- }
7607
+ get size(){
7608
+ return Number(this.getAttribute('size'));
7804
7609
  },
7805
-
7610
+ set size(value){
7611
+ this.setAttribute('size',value);
7612
+ },
7613
+ /*get tabIndex(){
7614
+ return Number(this.getAttribute('tabindex'));
7615
+ },
7616
+ set tabIndex(value){
7617
+ this.setAttribute('tabindex',value);
7618
+ },*/
7806
7619
  add : function(){
7807
7620
  __add__(this);
7808
7621
  },
7809
7622
  remove : function(){
7810
7623
  __remove__(this);
7624
+ },
7625
+ blur: function(){
7626
+ __blur__(this);
7627
+
7628
+ if (this._oldIndex != this.selectedIndex){
7629
+ var event = document.createEvent();
7630
+ event.initEvent("change");
7631
+ this.dispatchEvent( event );
7632
+ }
7633
+ },
7634
+ focus: function(){
7635
+ __focus__(this);
7636
+ this._oldIndex = this.selectedIndex;
7637
+ },
7638
+ onchange: function(event){
7639
+ __eval__(this.getAttribute('onchange')||'', this)
7811
7640
  }
7812
7641
  });
7813
7642
 
7814
- $w.HTMLSelectElement = HTMLSelectElement;
7815
-
7816
- $debug("Defining HTMLStyleElement");
7643
+ $w.HTMLSelectElement = HTMLSelectElement;$debug("Defining HTMLStyleElement");
7817
7644
  /*
7818
7645
  * HTMLStyleElement - DOM Level 2
7819
7646
  */
@@ -8154,10 +7981,12 @@ $w.HTMLTableCellElement = HTMLTableCellElement;$debug("Defining HTMLTextAreaElem
8154
7981
  * HTMLTextAreaElement - DOM Level 2
8155
7982
  */
8156
7983
  var HTMLTextAreaElement = function(ownerDocument) {
8157
- this.HTMLInputAreaCommon = HTMLInputAreaCommon;
8158
- this.HTMLInputAreaCommon(ownerDocument);
7984
+ this.HTMLElement = HTMLElement;
7985
+ this.HTMLElement(ownerDocument);
7986
+
7987
+ this._oldValue = null;
8159
7988
  };
8160
- HTMLTextAreaElement.prototype = new HTMLInputAreaCommon;
7989
+ HTMLTextAreaElement.prototype = new HTMLElement;
8161
7990
  __extend__(HTMLTextAreaElement.prototype, {
8162
7991
  get cols(){
8163
7992
  return this.getAttribute('cols');
@@ -8170,6 +7999,100 @@ __extend__(HTMLTextAreaElement.prototype, {
8170
7999
  },
8171
8000
  set rows(value){
8172
8001
  this.setAttribute('rows', value);
8002
+ },
8003
+
8004
+ get defaultValue(){
8005
+ return this.getAttribute('defaultValue');
8006
+ },
8007
+ set defaultValue(value){
8008
+ this.setAttribute('defaultValue', value);
8009
+ },
8010
+ get form(){
8011
+ var parent = this.parent;
8012
+ while(parent.nodeName.toLowerCase() != 'form'){
8013
+ parent = parent.parent;
8014
+ }
8015
+ return parent;
8016
+ },
8017
+ get accessKey(){
8018
+ return this.getAttribute('accesskey');
8019
+ },
8020
+ set accessKey(value){
8021
+ this.setAttribute('accesskey',value);
8022
+ },
8023
+ get access(){
8024
+ return this.getAttribute('access');
8025
+ },
8026
+ set access(value){
8027
+ this.setAttribute('access', value);
8028
+ },
8029
+ get disabled(){
8030
+ return (this.getAttribute('disabled')=='disabled');
8031
+ },
8032
+ set disabled(value){
8033
+ this.setAttribute('disabled', (value ? 'disabled' :''));
8034
+ },
8035
+ get maxLength(){
8036
+ return Number(this.getAttribute('maxlength')||'0');
8037
+ },
8038
+ set maxLength(value){
8039
+ this.setAttribute('maxlength', value);
8040
+ },
8041
+ get name(){
8042
+ return this.getAttribute('name')||'';
8043
+ },
8044
+ set name(value){
8045
+ this.setAttribute('name', value);
8046
+ },
8047
+ get readOnly(){
8048
+ return (this.getAttribute('readonly')=='readonly');
8049
+ },
8050
+ set readOnly(value){
8051
+ this.setAttribute('readonly', (value ? 'readonly' :''));
8052
+ },
8053
+ /*get tabIndex(){
8054
+ return Number(this.getAttribute('tabindex'));
8055
+ },
8056
+ set tabIndex(value){
8057
+ this.setAttribute('tabindex',Number(value));
8058
+ },*/
8059
+ get type(){
8060
+ return this.getAttribute('type');
8061
+ },
8062
+ set type(value){
8063
+ this.setAttribute('type',value);
8064
+ },
8065
+ get value(){
8066
+ return this.text;
8067
+ },
8068
+ set value(value){
8069
+ if(this.defaultValue===null&&this.text!==null)
8070
+ this.defaultValue = this.text;
8071
+ return this.text = value;
8072
+ },
8073
+ blur:function(){
8074
+ __blur__(this);
8075
+
8076
+ if (this._oldValue != this.value){
8077
+ var event = document.createEvent();
8078
+ event.initEvent("change");
8079
+ this.dispatchEvent( event );
8080
+ }
8081
+ },
8082
+ focus:function(){
8083
+ __focus__(this);
8084
+ this._oldValue = this.value;
8085
+ },
8086
+ select:function(){
8087
+ __select__(this);
8088
+
8089
+ },
8090
+ click:function(){
8091
+ __click__(this);
8092
+
8093
+ },
8094
+ onchange: function(event){
8095
+ __eval__(this.getAttribute('onchange')||'', this)
8173
8096
  }
8174
8097
  });
8175
8098
 
@@ -8849,29 +8772,12 @@ $debug("Initializing Window Location.");
8849
8772
  var $location = '';
8850
8773
 
8851
8774
  $w.__defineSetter__("location", function(url){
8852
- if ($w.$isOriginalWindow){
8853
- if ($w.$haveCalledWindowLocationSetter)
8854
- throw new Error("Cannot call 'window.location=' multiple times " +
8855
- "from the context used to load 'env.js'. Try using " +
8856
- "'window.open()' to get a new context.");
8857
- $w.$haveCalledWindowLocationSetter = true;
8858
- $w.__loadAWindowsDocument__(url);
8859
- }
8860
- else {
8861
- $env.$unloadEventsFor($w);
8862
- var proxy = $w;
8863
- if (proxy.$thisWindowsProxyObject)
8864
- proxy = proxy.$thisWindowsProxyObject;
8865
- $env.reloadAWindowProxy(proxy, url);
8866
- }
8775
+ //$w.onunload();
8776
+ $location = $env.location(url);
8777
+ setHistory($location);
8778
+ $w.document.load($location);
8867
8779
  });
8868
8780
 
8869
- $w.__loadAWindowsDocument__ = function(url){
8870
- $location = $env.location(url);
8871
- setHistory($location);
8872
- $w.document.load($location);
8873
- };
8874
-
8875
8781
  $w.__defineGetter__("location", function(url){
8876
8782
  var hash = new RegExp('(\\#.*)'),
8877
8783
  hostname = new RegExp('\/\/([^\:\/]+)'),
@@ -8949,18 +8855,13 @@ $w.__defineGetter__("location", function(url){
8949
8855
  toString: function(){
8950
8856
  return this.href;
8951
8857
  },
8952
- reload: function(force){
8953
- // ignore 'force': we don't implement a cache
8954
- var thisWindow = $w;
8955
- $env.$unloadEventsFor(thisWindow);
8956
- try { thisWindow = thisWindow.$thisWindowsProxyObject; }catch (e){}
8957
- $env.reloadAWindowProxy(thisWindow, thisWindow.location.href);
8958
- },
8959
- replace: function(url){
8960
- $location = url;
8961
- $w.location.reload();
8962
- }
8963
- };
8858
+ reload: function(force){
8859
+ //TODO
8860
+ },
8861
+ replace: function(url){
8862
+ //TODO
8863
+ }
8864
+ };
8964
8865
  });
8965
8866
 
8966
8867
  /*
@@ -9162,10 +9063,7 @@ $w.dispatchEvent = function(event, bubbles){
9162
9063
  event.target = this;
9163
9064
  }
9164
9065
  $debug("event target: " + event.target);
9165
- if ( event.type && (this.nodeType ||
9166
- this === window ||
9167
- this.__proto__ === window ||
9168
- this.$thisWindowsProxyObject === window)) {
9066
+ if ( event.type && this.nodeType || this===window) {
9169
9067
  $debug("nodeType: " + this.nodeType);
9170
9068
  if ( this.uuid && $events[this.uuid][event.type] ) {
9171
9069
  var _this = this;
@@ -9226,7 +9124,6 @@ $debug("Initializing Window XMLHttpRequest.");
9226
9124
  $w.XMLHttpRequest = function(){
9227
9125
  this.headers = {};
9228
9126
  this.responseHeaders = {};
9229
- this.$continueProcessing = true;
9230
9127
  $debug("creating xhr");
9231
9128
  };
9232
9129
 
@@ -9247,41 +9144,36 @@ XMLHttpRequest.prototype = {
9247
9144
  var _this = this;
9248
9145
 
9249
9146
  function makeRequest(){
9250
- $env.connection(_this, function(){
9251
- if (_this.$continueProcessing){
9252
- var responseXML = null;
9253
- _this.__defineGetter__("responseXML", function(){
9254
- if ( _this.responseText.match(/^\s*</) ) {
9255
- if(responseXML){
9256
- return responseXML;
9257
-
9258
- }else{
9259
- try {
9260
- $debug("parsing response text into xml document");
9261
- responseXML = $domparser.parseFromString(_this.responseText+"");
9262
- return responseXML;
9263
- } catch(e) {
9264
- $error('response XML does not apear to be well formed xml', e);
9265
- responseXML = $domparser.parseFromString("<html>"+
9266
- "<head/><body><p> parse error </p></body></html>");
9267
- return responseXML;
9268
- }
9147
+ $env.connection(_this, function(){
9148
+ var responseXML = null;
9149
+ _this.__defineGetter__("responseXML", function(){
9150
+ if ( _this.responseText.match(/^\s*</) ) {
9151
+ if(responseXML){
9152
+ return responseXML;
9153
+
9154
+ }else{
9155
+ try {
9156
+ $debug("parsing response text into xml document");
9157
+ responseXML = $domparser.parseFromString(_this.responseText+"");
9158
+ return responseXML;
9159
+ } catch(e) {
9160
+ $error('response XML does not apear to be well formed xml', e);
9161
+ responseXML = $domparser.parseFromString("<html>"+
9162
+ "<head/><body><p> parse error </p></body></html>");
9163
+ return responseXML;
9269
9164
  }
9270
- }else{
9271
- $env.warn('response XML does not apear to be xml');
9272
- return null;
9273
- }
9274
- });
9275
- _this.__defineSetter__("responseXML",function(xml){
9276
- responseXML = xml;
9277
- });
9278
- }
9165
+ }
9166
+ }else{
9167
+ $env.warn('response XML does not apear to be xml');
9168
+ return null;
9169
+ }
9170
+ });
9171
+ _this.__defineSetter__("responseXML",function(xml){
9172
+ responseXML = xml;
9173
+ });
9279
9174
  }, data);
9280
-
9281
- if (_this.$continueProcessing)
9282
- _this.onreadystatechange();
9175
+ _this.onreadystatechange();
9283
9176
  }
9284
-
9285
9177
  if (this.async){
9286
9178
  $debug("XHR sending asynch;");
9287
9179
  $env.runAsync(makeRequest);
@@ -9291,7 +9183,7 @@ XMLHttpRequest.prototype = {
9291
9183
  }
9292
9184
  },
9293
9185
  abort: function(){
9294
- this.$continueProcessing = false;
9186
+ //TODO
9295
9187
  },
9296
9188
  onreadystatechange: function(){
9297
9189
  //TODO
@@ -10060,15 +9952,19 @@ if($env.profile){
10060
9952
  */
10061
9953
 
10062
9954
  // read only reference to the Document object
10063
- var $document;
10064
- { // a temporary scope, nothing more
10065
- var referrer = "";
10066
- try {
10067
- referrer = $openingWindow.location.href;
10068
- } catch (e){ /* or not */ }
10069
- $document = new HTMLDocument($implementation, $w, referrer);
10070
- }
10071
9955
 
9956
+ $debug("Initializing window.document.");
9957
+ var $async = false;
9958
+ __extend__(HTMLDocument.prototype, {
9959
+ get async(){ return $async;},
9960
+ set async(async){ $async = async; },
9961
+ get baseURI(){ return $env.location('./'); },
9962
+ get URL(){ return $w.location.href; }
9963
+ });
9964
+
9965
+
9966
+
9967
+ var $document = new HTMLDocument($implementation, $w);
10072
9968
  $w.__defineGetter__("document", function(){
10073
9969
  return $document;
10074
9970
  });
@@ -10213,14 +10109,8 @@ try{
10213
10109
 
10214
10110
 
10215
10111
  // turn "original" JS interpreter global object into the
10216
- // "root" window object
10217
- Envjs.window(this, // object to "window-ify"
10218
- Envjs, // our scope for globals
10219
- this, // a root window's parent is itself
10220
- null, // "opener" for new window
10221
- this, // "top" for new window
10222
- true // identify this as the original (not reloadable) win
10223
- );
10112
+ // "root" window object; third param value for new window's "parent"
10113
+ Envjs.window(this, Envjs, null, this);
10224
10114
 
10225
10115
  } catch(e){
10226
10116
  Envjs.error("ERROR LOADING ENV : " + e + "\nLINE SOURCE:\n" +