harmony 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitignore +5 -0
  2. data/LICENSE +19 -0
  3. data/Manifest +117 -0
  4. data/README.md +155 -0
  5. data/Rakefile +39 -0
  6. data/docs.watchr +25 -0
  7. data/harmony.gemspec +18 -0
  8. data/lib/harmony.rb +5 -0
  9. data/lib/harmony/page.rb +123 -0
  10. data/specs.watchr +36 -0
  11. data/test/harmony_test.rb +8 -0
  12. data/test/page_test.rb +73 -0
  13. data/test/test_helper.rb +13 -0
  14. data/vendor/README +1 -0
  15. data/vendor/envjs/README +36 -0
  16. data/vendor/envjs/bin/envjsrb +255 -0
  17. data/vendor/envjs/bin/jquery-1.2.6-test.js +33 -0
  18. data/vendor/envjs/bin/jquery-1.3.1-test.js +33 -0
  19. data/vendor/envjs/bin/jquery-1.3.2-test.js +106 -0
  20. data/vendor/envjs/bin/prototype-1.6.0.3-test.js +82 -0
  21. data/vendor/envjs/bin/prototype_1.6.0.3_tmpl.txt +27 -0
  22. data/vendor/envjs/bin/test-jquery.sh +58 -0
  23. data/vendor/envjs/bin/test-prototype.sh +54 -0
  24. data/vendor/envjs/bin/tidy +0 -0
  25. data/vendor/envjs/lib/envjs.rb +23 -0
  26. data/vendor/envjs/lib/envjs/env.js +21665 -0
  27. data/vendor/envjs/lib/envjs/net.rb +3 -0
  28. data/vendor/envjs/lib/envjs/net/cgi.rb +94 -0
  29. data/vendor/envjs/lib/envjs/net/file.rb +75 -0
  30. data/vendor/envjs/lib/envjs/options.rb +11 -0
  31. data/vendor/envjs/lib/envjs/runtime.rb +351 -0
  32. data/vendor/envjs/lib/envjs/tempfile.rb +24 -0
  33. data/vendor/envjs/test/base64.js +80 -0
  34. data/vendor/envjs/test/call-load-test.js +15 -0
  35. data/vendor/envjs/test/data.js +45 -0
  36. data/vendor/envjs/test/debug.js +53 -0
  37. data/vendor/envjs/test/firebug/errorIcon.png +0 -0
  38. data/vendor/envjs/test/firebug/firebug.css +209 -0
  39. data/vendor/envjs/test/firebug/firebug.html +23 -0
  40. data/vendor/envjs/test/firebug/firebug.js +672 -0
  41. data/vendor/envjs/test/firebug/firebugx.js +10 -0
  42. data/vendor/envjs/test/firebug/infoIcon.png +0 -0
  43. data/vendor/envjs/test/firebug/warningIcon.png +0 -0
  44. data/vendor/envjs/test/fixtures/html/events.html +171 -0
  45. data/vendor/envjs/test/fixtures/html/iframe1.html +46 -0
  46. data/vendor/envjs/test/fixtures/html/iframe1a.html +46 -0
  47. data/vendor/envjs/test/fixtures/html/iframe2.html +45 -0
  48. data/vendor/envjs/test/fixtures/html/iframe3.html +28 -0
  49. data/vendor/envjs/test/fixtures/html/iframeN.html +57 -0
  50. data/vendor/envjs/test/fixtures/html/malformed.html +181 -0
  51. data/vendor/envjs/test/fixtures/html/scope.html +81 -0
  52. data/vendor/envjs/test/fixtures/html/trivial.html +19 -0
  53. data/vendor/envjs/test/fixtures/html/with_js.html +26 -0
  54. data/vendor/envjs/test/fixtures/images/icon-blue.png +0 -0
  55. data/vendor/envjs/test/fixtures/js/external_script.js +1 -0
  56. data/vendor/envjs/test/fixtures/js/script.js +1 -0
  57. data/vendor/envjs/test/fixtures/js/script_error.js +2 -0
  58. data/vendor/envjs/test/html/events.html +171 -0
  59. data/vendor/envjs/test/html/iframe1.html +46 -0
  60. data/vendor/envjs/test/html/iframe1a.html +46 -0
  61. data/vendor/envjs/test/html/iframe2.html +45 -0
  62. data/vendor/envjs/test/html/iframe3.html +30 -0
  63. data/vendor/envjs/test/html/iframeN.html +57 -0
  64. data/vendor/envjs/test/html/malformed.html +181 -0
  65. data/vendor/envjs/test/html/scope.html +87 -0
  66. data/vendor/envjs/test/html/script.js +1 -0
  67. data/vendor/envjs/test/html/trivial.html +19 -0
  68. data/vendor/envjs/test/html/with_js.html +26 -0
  69. data/vendor/envjs/test/index.html +328 -0
  70. data/vendor/envjs/test/java-prototype.js +9 -0
  71. data/vendor/envjs/test/primary-tests.js +24 -0
  72. data/vendor/envjs/test/prototype-test.js +13 -0
  73. data/vendor/envjs/test/qunit.js +61 -0
  74. data/vendor/envjs/test/qunit/qunit/qunit.css +17 -0
  75. data/vendor/envjs/test/qunit/qunit/qunit.js +997 -0
  76. data/vendor/envjs/test/scope.rb +25 -0
  77. data/vendor/envjs/test/specs/dist/env.spec.js +1534 -0
  78. data/vendor/envjs/test/specs/envjs.spec.css +46 -0
  79. data/vendor/envjs/test/specs/parser/html.js +31 -0
  80. data/vendor/envjs/test/specs/parser/spec.html +40 -0
  81. data/vendor/envjs/test/specs/parser/xml.js +31 -0
  82. data/vendor/envjs/test/specs/qunit.bdd.js +210 -0
  83. data/vendor/envjs/test/specs/qunit.css +17 -0
  84. data/vendor/envjs/test/specs/qunit.js +997 -0
  85. data/vendor/envjs/test/specs/template/spec-0.js +31 -0
  86. data/vendor/envjs/test/specs/template/spec-1.js +31 -0
  87. data/vendor/envjs/test/specs/template/spec.html +40 -0
  88. data/vendor/envjs/test/specs/window/css.js +23 -0
  89. data/vendor/envjs/test/specs/window/dialog.js +25 -0
  90. data/vendor/envjs/test/specs/window/document.js +23 -0
  91. data/vendor/envjs/test/specs/window/event.js +25 -0
  92. data/vendor/envjs/test/specs/window/history.js +34 -0
  93. data/vendor/envjs/test/specs/window/location.js +34 -0
  94. data/vendor/envjs/test/specs/window/navigator.js +71 -0
  95. data/vendor/envjs/test/specs/window/screen.js +42 -0
  96. data/vendor/envjs/test/specs/window/spec.html +48 -0
  97. data/vendor/envjs/test/specs/window/timer.js +26 -0
  98. data/vendor/envjs/test/specs/window/window.js +53 -0
  99. data/vendor/envjs/test/specs/xhr/spec.html +47 -0
  100. data/vendor/envjs/test/specs/xhr/xhr.js +31 -0
  101. data/vendor/envjs/test/test.js +10 -0
  102. data/vendor/envjs/test/unit/dom.js +44 -0
  103. data/vendor/envjs/test/unit/elementmembers.js +60 -0
  104. data/vendor/envjs/test/unit/events.js +195 -0
  105. data/vendor/envjs/test/unit/fixtures/external_script.js +1 -0
  106. data/vendor/envjs/test/unit/iframe.js +234 -0
  107. data/vendor/envjs/test/unit/multi-window.js +212 -0
  108. data/vendor/envjs/test/unit/nu.validator.js +34 -0
  109. data/vendor/envjs/test/unit/onload.js +90 -0
  110. data/vendor/envjs/test/unit/parser.js +121 -0
  111. data/vendor/envjs/test/unit/prototypecompat.js +22 -0
  112. data/vendor/envjs/test/unit/proxy.js +6 -0
  113. data/vendor/envjs/test/unit/scope.js +209 -0
  114. data/vendor/envjs/test/unit/timer.js +115 -0
  115. data/vendor/envjs/test/unit/window.js +41 -0
  116. data/vendor/envjs/test/vendor/jQuery/README +2 -0
  117. data/vendor/envjs/test/vendor/prototype-1.6.0.3.js +4320 -0
  118. metadata +200 -0
@@ -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
@@ -0,0 +1,80 @@
1
+ // This code was written by Tyler Akins and has been placed in the
2
+ // public domain. It would be nice if you left this header intact.
3
+ // Base64 code from Tyler Akins -- http://rumkin.com
4
+
5
+ var Base64 = (function () {
6
+ var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
7
+
8
+ var obj = {
9
+ /**
10
+ * Encodes a string in base64
11
+ * @param {String} input The string to encode in base64.
12
+ */
13
+ encode: function (input) {
14
+ var output = "";
15
+ var chr1, chr2, chr3;
16
+ var enc1, enc2, enc3, enc4;
17
+ var i = 0;
18
+
19
+ do {
20
+ chr1 = input.charCodeAt(i++);
21
+ chr2 = input.charCodeAt(i++);
22
+ chr3 = input.charCodeAt(i++);
23
+
24
+ enc1 = chr1 >> 2;
25
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
26
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
27
+ enc4 = chr3 & 63;
28
+
29
+ if (isNaN(chr2)) {
30
+ enc3 = enc4 = 64;
31
+ } else if (isNaN(chr3)) {
32
+ enc4 = 64;
33
+ }
34
+
35
+ output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
36
+ keyStr.charAt(enc3) + keyStr.charAt(enc4);
37
+ } while (i < input.length);
38
+
39
+ return output;
40
+ },
41
+
42
+ /**
43
+ * Decodes a base64 string.
44
+ * @param {String} input The string to decode.
45
+ */
46
+ decode: function (input) {
47
+ var output = "";
48
+ var chr1, chr2, chr3;
49
+ var enc1, enc2, enc3, enc4;
50
+ var i = 0;
51
+
52
+ // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
53
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
54
+
55
+ do {
56
+ enc1 = keyStr.indexOf(input.charAt(i++));
57
+ enc2 = keyStr.indexOf(input.charAt(i++));
58
+ enc3 = keyStr.indexOf(input.charAt(i++));
59
+ enc4 = keyStr.indexOf(input.charAt(i++));
60
+
61
+ chr1 = (enc1 << 2) | (enc2 >> 4);
62
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
63
+ chr3 = ((enc3 & 3) << 6) | enc4;
64
+
65
+ output = output + String.fromCharCode(chr1);
66
+
67
+ if (enc3 != 64) {
68
+ output = output + String.fromCharCode(chr2);
69
+ }
70
+ if (enc4 != 64) {
71
+ output = output + String.fromCharCode(chr3);
72
+ }
73
+ } while (i < input.length);
74
+
75
+ return output;
76
+ }
77
+ };
78
+
79
+ return obj;
80
+ })();
@@ -0,0 +1,15 @@
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
+ });
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env envjsrb
2
+ load('base64.js');
3
+ inner = "<head><title>Hello, World from a data uri!</title></head><body></body>";
4
+ doc = "<html>"+inner+"</html>";
5
+ url_escaped = "data:text/html,"+escape(doc);
6
+ base64 = "data:text/html;base64,"+Base64.encode(doc);
7
+ debug(url_escaped);
8
+ window.location = "about:blank";
9
+ Envjs.wait();
10
+ window.location = url_escaped;
11
+ Envjs.wait();
12
+ debug(window.document.documentElement.innerHTML);
13
+ if(window.document.documentElement.innerHTML != inner){
14
+ debug(window.document.documentElement.innerHTML);
15
+ debug(inner);
16
+ throw new Error(window.document.documentElement.innerHTML);
17
+ }
18
+ debug(base64);
19
+ window.location = "about:blank";
20
+ Envjs.wait();
21
+ window.location = base64;
22
+ Envjs.wait();
23
+ debug(window.document.documentElement.innerHTML);
24
+ if(window.document.documentElement.innerHTML != inner){
25
+ throw new Error("b"+window.document.documentElement.innerHTML);
26
+ }
27
+ window.location = "about:blank";
28
+ Envjs.wait();
29
+ window.location = "data:,"+escape("Hello, World from a data uri!");
30
+ Envjs.wait();
31
+ debug(window.location+"");
32
+ debug(window.document.documentElement.innerHTML);
33
+ inner = "<head><title></title></head><body>Hello, World from a data uri!</body>";
34
+ if(window.document.documentElement.innerHTML != inner){
35
+ throw new Error("c"+window.document.documentElement.innerHTML);
36
+ }
37
+
38
+ /* not implemented yet ...
39
+ w = open("about:blank");
40
+ w.foo = 10;
41
+ debug(w.foo);
42
+ uri = "data:text/javascript;base64,"+"foo = 20;";
43
+ w.load(uri);
44
+ debug(w.foo);
45
+ */
@@ -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,209 @@
1
+
2
+ html, body {
3
+ margin: 0;
4
+ background: #FFFFFF;
5
+ font-family: Lucida Grande, Tahoma, sans-serif;
6
+ font-size: 11px;
7
+ overflow: hidden;
8
+ }
9
+
10
+ a {
11
+ text-decoration: none;
12
+ }
13
+
14
+ a:hover {
15
+ text-decoration: underline;
16
+ }
17
+
18
+ .toolbar {
19
+ height: 14px;
20
+ border-top: 1px solid ThreeDHighlight;
21
+ border-bottom: 1px solid ThreeDShadow;
22
+ padding: 2px 6px;
23
+ background: ThreeDFace;
24
+ }
25
+
26
+ .toolbarRight {
27
+ position: absolute;
28
+ top: 4px;
29
+ right: 6px;
30
+ }
31
+
32
+ #log {
33
+ overflow: auto;
34
+ position: absolute;
35
+ left: 0;
36
+ width: 100%;
37
+ }
38
+
39
+ #commandLine {
40
+ position: absolute;
41
+ bottom: 0;
42
+ left: 0;
43
+ width: 100%;
44
+ height: 18px;
45
+ border: none;
46
+ border-top: 1px solid ThreeDShadow;
47
+ }
48
+
49
+ /************************************************************************************************/
50
+
51
+ .logRow {
52
+ position: relative;
53
+ border-bottom: 1px solid #D7D7D7;
54
+ padding: 2px 4px 1px 6px;
55
+ background-color: #FFFFFF;
56
+ }
57
+
58
+ .logRow-command {
59
+ font-family: Monaco, monospace;
60
+ color: blue;
61
+ }
62
+
63
+ .objectBox-null {
64
+ padding: 0 2px;
65
+ border: 1px solid #666666;
66
+ background-color: #888888;
67
+ color: #FFFFFF;
68
+ }
69
+
70
+ .objectBox-string {
71
+ font-family: Monaco, monospace;
72
+ color: red;
73
+ white-space: pre;
74
+ }
75
+
76
+ .objectBox-number {
77
+ color: #000088;
78
+ }
79
+
80
+ .objectBox-function {
81
+ font-family: Monaco, monospace;
82
+ color: DarkGreen;
83
+ }
84
+
85
+ .objectBox-object {
86
+ color: DarkGreen;
87
+ font-weight: bold;
88
+ }
89
+
90
+ /************************************************************************************************/
91
+
92
+ .logRow-info,
93
+ .logRow-error,
94
+ .logRow-warning {
95
+ background: #FFFFFF no-repeat 2px 2px;
96
+ padding-left: 20px;
97
+ padding-bottom: 3px;
98
+ }
99
+
100
+ .logRow-info {
101
+ background-image: url(infoIcon.png);
102
+ }
103
+
104
+ .logRow-warning {
105
+ background-color: cyan;
106
+ background-image: url(warningIcon.png);
107
+ }
108
+
109
+ .logRow-error {
110
+ background-color: LightYellow;
111
+ background-image: url(errorIcon.png);
112
+ }
113
+
114
+ .errorMessage {
115
+ vertical-align: top;
116
+ color: #FF0000;
117
+ }
118
+
119
+ .objectBox-sourceLink {
120
+ position: absolute;
121
+ right: 4px;
122
+ top: 2px;
123
+ padding-left: 8px;
124
+ font-family: Lucida Grande, sans-serif;
125
+ font-weight: bold;
126
+ color: #0000FF;
127
+ }
128
+
129
+ /************************************************************************************************/
130
+
131
+ .logRow-group {
132
+ background: #EEEEEE;
133
+ border-bottom: none;
134
+ }
135
+
136
+ .logGroup {
137
+ background: #EEEEEE;
138
+ }
139
+
140
+ .logGroupBox {
141
+ margin-left: 24px;
142
+ border-top: 1px solid #D7D7D7;
143
+ border-left: 1px solid #D7D7D7;
144
+ }
145
+
146
+ /************************************************************************************************/
147
+
148
+ .selectorTag,
149
+ .selectorId,
150
+ .selectorClass {
151
+ font-family: Monaco, monospace;
152
+ font-weight: normal;
153
+ }
154
+
155
+ .selectorTag {
156
+ color: #0000FF;
157
+ }
158
+
159
+ .selectorId {
160
+ color: DarkBlue;
161
+ }
162
+
163
+ .selectorClass {
164
+ color: red;
165
+ }
166
+
167
+ /************************************************************************************************/
168
+
169
+ .objectBox-element {
170
+ font-family: Monaco, monospace;
171
+ color: #000088;
172
+ }
173
+
174
+ .nodeChildren {
175
+ margin-left: 16px;
176
+ }
177
+
178
+ .nodeTag {
179
+ color: blue;
180
+ }
181
+
182
+ .nodeValue {
183
+ color: #FF0000;
184
+ font-weight: normal;
185
+ }
186
+
187
+ .nodeText,
188
+ .nodeComment {
189
+ margin: 0 2px;
190
+ vertical-align: top;
191
+ }
192
+
193
+ .nodeText {
194
+ color: #333333;
195
+ }
196
+
197
+ .nodeComment {
198
+ color: DarkGreen;
199
+ }
200
+
201
+ /************************************************************************************************/
202
+
203
+ .propertyNameCell {
204
+ vertical-align: top;
205
+ }
206
+
207
+ .propertyName {
208
+ font-weight: bold;
209
+ }
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml">
5
+
6
+ <head>
7
+ <title>Firebug</title>
8
+ <link rel="stylesheet" type="text/css" href="firebug.css">
9
+ </head>
10
+
11
+ <body>
12
+ <div id="toolbar" class="toolbar">
13
+ <a href="#" onclick="parent.console.clear()">Clear</a>
14
+ <span class="toolbarRight">
15
+ <a href="#" onclick="parent.console.close()">Close</a>
16
+ </span>
17
+ </div>
18
+ <div id="log"></div>
19
+ <input type="text" id="commandLine">
20
+
21
+ <script>parent.onFirebugReady(document);</script>
22
+ </body>
23
+ </html>