terminus 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.rdoc +25 -19
  2. data/bin/terminus +1 -1
  3. data/lib/capybara/driver/terminus.rb +28 -17
  4. data/lib/terminus.rb +29 -15
  5. data/lib/terminus/application.rb +5 -11
  6. data/lib/terminus/browser.rb +97 -44
  7. data/lib/terminus/client.rb +43 -0
  8. data/lib/terminus/client/browser.rb +30 -0
  9. data/lib/terminus/client/phantom.js +6 -0
  10. data/lib/terminus/client/phantomjs.rb +20 -0
  11. data/lib/terminus/connector.rb +9 -0
  12. data/lib/terminus/connector/server.rb +142 -0
  13. data/lib/terminus/connector/socket_handler.rb +72 -0
  14. data/lib/terminus/controller.rb +22 -5
  15. data/lib/terminus/host.rb +7 -2
  16. data/lib/terminus/node.rb +11 -5
  17. data/lib/terminus/proxy.rb +35 -1
  18. data/lib/terminus/proxy/driver_body.rb +26 -6
  19. data/lib/terminus/proxy/external.rb +9 -0
  20. data/lib/terminus/proxy/rewrite.rb +4 -2
  21. data/lib/terminus/public/compiled/terminus-min.js +3 -0
  22. data/lib/terminus/public/compiled/terminus.js +5270 -0
  23. data/lib/terminus/public/loader.js +1 -1
  24. data/lib/terminus/public/pathology.js +3174 -0
  25. data/lib/terminus/public/syn/browsers.js +2 -2
  26. data/lib/terminus/public/syn/drag/drag.js +3 -4
  27. data/lib/terminus/public/syn/key.js +130 -111
  28. data/lib/terminus/public/syn/mouse.js +2 -2
  29. data/lib/terminus/public/syn/synthetic.js +45 -34
  30. data/lib/terminus/public/terminus.js +183 -70
  31. data/lib/terminus/server.rb +6 -0
  32. data/lib/terminus/timeouts.rb +4 -2
  33. data/lib/terminus/views/bootstrap.erb +12 -27
  34. data/lib/terminus/views/index.erb +1 -1
  35. data/spec/reports/android.txt +875 -0
  36. data/spec/reports/chrome.txt +137 -8
  37. data/spec/reports/firefox.txt +137 -9
  38. data/spec/reports/opera.txt +142 -13
  39. data/spec/reports/phantomjs.txt +871 -0
  40. data/spec/reports/safari.txt +137 -8
  41. data/spec/spec_helper.rb +19 -17
  42. data/spec/terminus_driver_spec.rb +8 -6
  43. data/spec/terminus_session_spec.rb +4 -4
  44. metadata +209 -117
@@ -1,4 +1,4 @@
1
- steal.then(function(){
1
+ (function() {
2
2
  Syn.key.browsers = {
3
3
  webkit : {
4
4
  'prevent':
@@ -147,4 +147,4 @@ steal.then(function(){
147
147
  }
148
148
  return Syn.mouse.browsers.gecko;
149
149
  })();
150
- })
150
+ })()
@@ -131,8 +131,8 @@
131
131
  var j = Syn.jquery()(el),
132
132
  o = j.offset();
133
133
  return {
134
- pageX: o.left + (j.width() / 2),
135
- pageY: o.top + (j.height() / 2)
134
+ pageX: o.left + (j.outerWidth() / 2),
135
+ pageY: o.top + (j.outerHeight() / 2)
136
136
  }
137
137
  },
138
138
  convertOption = function( option, win, from ) {
@@ -192,7 +192,6 @@
192
192
  top =0;
193
193
  diff = -off.top;
194
194
  }
195
- console.log("moving", from.clientY,from.clientY - diff, off.top, top )
196
195
  from.clientY = from.clientY - diff;
197
196
  to.clientY = to.clientY - diff;
198
197
  Syn.helpers.scrollOffset(win,{top: top, left: off.left});
@@ -319,4 +318,4 @@
319
318
 
320
319
  }
321
320
  })
322
- }());
321
+ })()
@@ -1,4 +1,4 @@
1
- steal.then(function(){
1
+ (function() {
2
2
  var h = Syn.helpers,
3
3
  S = Syn,
4
4
 
@@ -82,7 +82,6 @@ steal.then(function(){
82
82
 
83
83
 
84
84
  };
85
-
86
85
  /**
87
86
  * @add Syn static
88
87
  */
@@ -129,124 +128,124 @@ steal.then(function(){
129
128
  */
130
129
  keycodes: {
131
130
  //backspace
132
- '\b': '8',
131
+ '\b': 8,
133
132
 
134
133
  //tab
135
- '\t': '9',
134
+ '\t': 9,
136
135
 
137
136
  //enter
138
- '\r': '13',
137
+ '\r': 13,
139
138
 
140
139
  //special
141
- 'shift': '16',
142
- 'ctrl': '17',
143
- 'alt': '18',
140
+ 'shift': 16,
141
+ 'ctrl': 17,
142
+ 'alt': 18,
144
143
 
145
144
  //weird
146
- 'pause-break': '19',
147
- 'caps': '20',
148
- 'escape': '27',
149
- 'num-lock': '144',
150
- 'scroll-lock': '145',
151
- 'print': '44',
145
+ 'pause-break': 19,
146
+ 'caps': 20,
147
+ 'escape': 27,
148
+ 'num-lock': 144,
149
+ 'scroll-lock': 145,
150
+ 'print': 44,
152
151
 
153
152
  //navigation
154
- 'page-up': '33',
155
- 'page-down': '34',
156
- 'end': '35',
157
- 'home': '36',
158
- 'left': '37',
159
- 'up': '38',
160
- 'right': '39',
161
- 'down': '40',
162
- 'insert': '45',
163
- 'delete': '46',
153
+ 'page-up': 33,
154
+ 'page-down': 34,
155
+ 'end': 35,
156
+ 'home': 36,
157
+ 'left': 37,
158
+ 'up': 38,
159
+ 'right': 39,
160
+ 'down': 40,
161
+ 'insert': 45,
162
+ 'delete': 46,
164
163
 
165
164
  //normal characters
166
- ' ': '32',
167
- '0': '48',
168
- '1': '49',
169
- '2': '50',
170
- '3': '51',
171
- '4': '52',
172
- '5': '53',
173
- '6': '54',
174
- '7': '55',
175
- '8': '56',
176
- '9': '57',
177
- 'a': '65',
178
- 'b': '66',
179
- 'c': '67',
180
- 'd': '68',
181
- 'e': '69',
182
- 'f': '70',
183
- 'g': '71',
184
- 'h': '72',
185
- 'i': '73',
186
- 'j': '74',
187
- 'k': '75',
188
- 'l': '76',
189
- 'm': '77',
190
- 'n': '78',
191
- 'o': '79',
192
- 'p': '80',
193
- 'q': '81',
194
- 'r': '82',
195
- 's': '83',
196
- 't': '84',
197
- 'u': '85',
198
- 'v': '86',
199
- 'w': '87',
200
- 'x': '88',
201
- 'y': '89',
202
- 'z': '90',
165
+ ' ': 32,
166
+ '0': 48,
167
+ '1': 49,
168
+ '2': 50,
169
+ '3': 51,
170
+ '4': 52,
171
+ '5': 53,
172
+ '6': 54,
173
+ '7': 55,
174
+ '8': 56,
175
+ '9': 57,
176
+ 'a': 65,
177
+ 'b': 66,
178
+ 'c': 67,
179
+ 'd': 68,
180
+ 'e': 69,
181
+ 'f': 70,
182
+ 'g': 71,
183
+ 'h': 72,
184
+ 'i': 73,
185
+ 'j': 74,
186
+ 'k': 75,
187
+ 'l': 76,
188
+ 'm': 77,
189
+ 'n': 78,
190
+ 'o': 79,
191
+ 'p': 80,
192
+ 'q': 81,
193
+ 'r': 82,
194
+ 's': 83,
195
+ 't': 84,
196
+ 'u': 85,
197
+ 'v': 86,
198
+ 'w': 87,
199
+ 'x': 88,
200
+ 'y': 89,
201
+ 'z': 90,
203
202
  //normal-characters, numpad
204
- 'num0': '96',
205
- 'num1': '97',
206
- 'num2': '98',
207
- 'num3': '99',
208
- 'num4': '100',
209
- 'num5': '101',
210
- 'num6': '102',
211
- 'num7': '103',
212
- 'num8': '104',
213
- 'num9': '105',
214
- '*': '106',
215
- '+': '107',
216
- '-': '109',
217
- '.': '110',
203
+ 'num0': 96,
204
+ 'num1': 97,
205
+ 'num2': 98,
206
+ 'num3': 99,
207
+ 'num4': 100,
208
+ 'num5': 101,
209
+ 'num6': 102,
210
+ 'num7': 103,
211
+ 'num8': 104,
212
+ 'num9': 105,
213
+ '*': 106,
214
+ '+': 107,
215
+ '-': 109,
216
+ '.': 110,
218
217
  //normal-characters, others
219
- '/': '111',
220
- ';': '186',
221
- '=': '187',
222
- ',': '188',
223
- '-': '189',
224
- '.': '190',
225
- '/': '191',
226
- '`': '192',
227
- '[': '219',
228
- '\\': '220',
229
- ']': '221',
230
- "'": '222',
218
+ '/': 111,
219
+ ';': 186,
220
+ '=': 187,
221
+ ',': 188,
222
+ '-': 189,
223
+ '.': 190,
224
+ '/': 191,
225
+ '`': 192,
226
+ '[': 219,
227
+ '\\': 220,
228
+ ']': 221,
229
+ "'": 222,
231
230
 
232
231
  //ignore these, you shouldn't use them
233
- 'left window key': '91',
234
- 'right window key': '92',
235
- 'select key': '93',
236
-
237
-
238
- 'f1': '112',
239
- 'f2': '113',
240
- 'f3': '114',
241
- 'f4': '115',
242
- 'f5': '116',
243
- 'f6': '117',
244
- 'f7': '118',
245
- 'f8': '119',
246
- 'f9': '120',
247
- 'f10': '121',
248
- 'f11': '122',
249
- 'f12': '123'
232
+ 'left window key': 91,
233
+ 'right window key': 92,
234
+ 'select key': 93,
235
+
236
+
237
+ 'f1': 112,
238
+ 'f2': 113,
239
+ 'f3': 114,
240
+ 'f4': 115,
241
+ 'f5': 116,
242
+ 'f6': 117,
243
+ 'f7': 118,
244
+ 'f8': 119,
245
+ 'f9': 120,
246
+ 'f10': 121,
247
+ 'f11': 122,
248
+ 'f12': 123
250
249
  },
251
250
 
252
251
  // what we can type in
@@ -349,6 +348,13 @@ steal.then(function(){
349
348
  result.charCode = charCode;
350
349
  }
351
350
 
351
+ // all current browsers have which property to normalize keyCode/charCode
352
+ if(result.keyCode){
353
+ result.which = result.keyCode;
354
+ } else {
355
+ result.which = result.charCode;
356
+ }
357
+
352
358
 
353
359
  return result
354
360
  },
@@ -360,6 +366,8 @@ steal.then(function(){
360
366
  'function': ['f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
361
367
  },
362
368
  //returns the default function
369
+ // some keys have default functions
370
+ // some 'kinds' of keys have default functions
363
371
  getDefault: function( key ) {
364
372
  //check if it is described directly
365
373
  if ( Syn.key.defaults[key] ) {
@@ -727,8 +735,9 @@ steal.then(function(){
727
735
  return;
728
736
  }
729
737
 
730
-
731
- var caret = Syn.typeable.test(element.nodeName) && getSelection(element),
738
+ // keep reference to current activeElement
739
+ var activeElement = h.getWindow(element).document.activeElement,
740
+ caret = Syn.typeable.test(element.nodeName) && getSelection(element),
732
741
  key = convert[options] || options,
733
742
  // should we run default events
734
743
  runDefaults = Syn.trigger('keydown', key, element),
@@ -741,9 +750,8 @@ steal.then(function(){
741
750
 
742
751
  // the result of the default event
743
752
  defaultResult,
744
-
745
- // options for keypress
746
- keypressOptions = Syn.key.options(key, 'keypress')
753
+
754
+ keypressOptions = Syn.key.options(key, 'keypress');
747
755
 
748
756
 
749
757
  if ( runDefaults ) {
@@ -752,6 +760,11 @@ steal.then(function(){
752
760
  defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret)
753
761
  } else {
754
762
  //do keypress
763
+ // check if activeElement changed b/c someone called focus in keydown
764
+ if( activeElement !== h.getWindow(element).document.activeElement ) {
765
+ element = h.getWindow(element).document.activeElement;
766
+ }
767
+
755
768
  runDefaults = Syn.trigger('keypress', keypressOptions, element)
756
769
  if ( runDefaults ) {
757
770
  defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret)
@@ -760,6 +773,11 @@ steal.then(function(){
760
773
  } else {
761
774
  //canceled ... possibly don't run keypress
762
775
  if ( keypressOptions && h.inArray('keypress', prevent.keydown) == -1 ) {
776
+ // check if activeElement changed b/c someone called focus in keydown
777
+ if( activeElement !== h.getWindow(element).document.activeElement ) {
778
+ element = h.getWindow(element).document.activeElement;
779
+ }
780
+
763
781
  Syn.trigger('keypress', keypressOptions, element)
764
782
  }
765
783
  }
@@ -897,9 +915,10 @@ steal.then(function(){
897
915
  })
898
916
  Syn.trigger("keypress", "\r", anchor);
899
917
 
900
- S.support.textareaCarriage = textarea.value.length == 4
918
+ S.support.textareaCarriage = textarea.value.length == 4;
919
+
901
920
  document.documentElement.removeChild(div);
902
921
 
903
922
  S.support.ready++;
904
923
  })();
905
- })
924
+ })()
@@ -1,4 +1,4 @@
1
- steal.then(function(){
1
+ (function() {
2
2
  //handles mosue events
3
3
 
4
4
  var h = Syn.helpers,
@@ -281,4 +281,4 @@ steal.then(function(){
281
281
  window.__synthTest = oldSynth;
282
282
  Syn.support.ready++;
283
283
  })();
284
- })
284
+ })()
@@ -1,4 +1,4 @@
1
- steal.then(function(){
1
+ (function(){
2
2
  var extend = function( d, s ) {
3
3
  var p;
4
4
  for (p in s) {
@@ -186,8 +186,8 @@ steal.then(function(){
186
186
  }
187
187
  },
188
188
  jquery: function( el, fast ) {
189
- if ( window.FuncUnit && window.FuncUnit.jquery ) {
190
- return window.FuncUnit.jquery;
189
+ if ( window.FuncUnit && window.FuncUnit.jQuery ) {
190
+ return window.FuncUnit.jQuery;
191
191
  }
192
192
  if ( el ) {
193
193
  return Syn.helpers.getWindow(el).jQuery || window.jQuery;
@@ -529,19 +529,26 @@ steal.then(function(){
529
529
  },
530
530
  /**
531
531
  * @attribute support
532
+ *
532
533
  * Feature detected properties of a browser's event system.
533
534
  * Support has the following properties:
534
- * <ul>
535
- * <li><code>clickChanges</code> - clicking on an option element creates a change event.</li>
536
- * <li><code>clickSubmits</code> - clicking on a form button submits the form.</li>
537
- * <li><code>mouseupSubmits</code> - a mouseup on a form button submits the form.</li>
538
- * <li><code>radioClickChanges</code> - clicking a radio button changes the radio.</li>
539
- * <li><code>focusChanges</code> - focus/blur creates a change event.</li>
540
- * <li><code>linkHrefJS</code> - An achor's href JavaScript is run.</li>
541
- * <li><code>mouseDownUpClicks</code> - A mousedown followed by mouseup creates a click event.</li>
542
- * <li><code>tabKeyTabs</code> - A tab key changes tabs.</li>
543
- * <li><code>keypressOnAnchorClicks</code> - Keying enter on an anchor triggers a click.</li>
544
- * </ul>
535
+ *
536
+ * - `backspaceWorks` - typing a backspace removes a character
537
+ * - `clickChanges` - clicking on an option element creates a change event.
538
+ * - `clickSubmits` - clicking on a form button submits the form.
539
+ * - `focusChanges` - focus/blur creates a change event.
540
+ * - `keypressOnAnchorClicks` - Keying enter on an anchor triggers a click.
541
+ * - `keypressSubmits` - enter key submits
542
+ * - `keyCharacters` - typing a character shows up
543
+ * - `keysOnNotFocused` - enters keys when not focused.
544
+ * - `linkHrefJS` - An achor's href JavaScript is run.
545
+ * - `mouseDownUpClicks` - A mousedown followed by mouseup creates a click event.
546
+ * - `mouseupSubmits` - a mouseup on a form button submits the form.
547
+ * - `radioClickChanges` - clicking a radio button changes the radio.
548
+ * - `tabKeyTabs` - A tab key changes tabs.
549
+ * - `textareaCarriage` - a new line in a textarea creates a carriage return.
550
+ *
551
+ *
545
552
  */
546
553
  support: {
547
554
  clickChanges: false,
@@ -807,24 +814,28 @@ steal.then(function(){
807
814
  };
808
815
  },
809
816
  i = 0;
810
- for ( ; i < actions.length; i++ ) {
811
- makeAction(actions[i]);
812
- }
813
- /**
814
- * Used for creating and dispatching synthetic events.
815
- * @codestart
816
- * new MVC.Syn('click').send(MVC.$E('id'))
817
- * @codeend
818
- * @constructor Sets up a synthetic event.
819
- * @param {String} type type of event, ex: 'click'
820
- * @param {optional:Object} options
821
- */
822
- if ( window.jQuery || (window.FuncUnit && window.FuncUnit.jquery) ) {
823
- ((window.FuncUnit && window.FuncUnit.jquery) || window.jQuery).fn.triggerSyn = function( type, options, callback ) {
824
- Syn(type, options, this[0], callback);
825
- return this;
826
- };
827
- }
828
817
 
829
- window.Syn = Syn;
830
- })
818
+ for ( ; i < actions.length; i++ ) {
819
+ makeAction(actions[i]);
820
+ }
821
+ /**
822
+ * Used for creating and dispatching synthetic events.
823
+ * @codestart
824
+ * new MVC.Syn('click').send(MVC.$E('id'))
825
+ * @codeend
826
+ * @constructor Sets up a synthetic event.
827
+ * @param {String} type type of event, ex: 'click'
828
+ * @param {optional:Object} options
829
+ */
830
+ if ( (window.FuncUnit && window.FuncUnit.jQuery) || window.jQuery ) {
831
+ ((window.FuncUnit && window.FuncUnit.jQuery) || window.jQuery).fn.triggerSyn = function( type, options, callback ) {
832
+ if(!this[0]){
833
+ throw "Can't "+type.substring(1)+" because no element matching '"+this.selector+"' was found"
834
+ }
835
+ Syn(type, options, this[0], callback);
836
+ return this;
837
+ };
838
+ }
839
+
840
+ window.Syn = Syn;
841
+ })()