vapir-firefox 1.7.0 → 1.7.1.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/vapir-firefox/container.rb +1 -380
- data/lib/vapir-firefox/element.rb +5 -31
- data/lib/vapir-firefox/jssh_socket.rb +47 -16
- data/lib/vapir-firefox/modal_dialog.rb +1 -1
- data/lib/vapir-firefox/page_container.rb +10 -55
- data/lib/vapir-firefox/version.rb +1 -1
- metadata +13 -9
@@ -54,7 +54,7 @@ module Vapir
|
|
54
54
|
elements=[]
|
55
55
|
result=document_object.evaluate(xpath, containing_object, nil, jssh_socket.Components.interfaces.nsIDOMXPathResult.ORDERED_NODE_ITERATOR_TYPE, nil)
|
56
56
|
while element=result.iterateNext
|
57
|
-
elements << element
|
57
|
+
elements << element
|
58
58
|
end
|
59
59
|
elements
|
60
60
|
end
|
@@ -79,384 +79,5 @@ module Vapir
|
|
79
79
|
base_element_class.factory(element_object, extra_for_contained)
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
83
|
-
=begin
|
84
|
-
#
|
85
|
-
# Description:
|
86
|
-
# Used to access a frame element. Usually an <frame> or <iframe> HTML tag.
|
87
|
-
#
|
88
|
-
# Input:
|
89
|
-
# - how - The attribute used to identify the framet.
|
90
|
-
# - what - The value of that attribute.
|
91
|
-
# If only one parameter is supplied, "how" is by default taken as name and the
|
92
|
-
# parameter supplied becomes the value of the name attribute.
|
93
|
-
#
|
94
|
-
# Typical usage:
|
95
|
-
#
|
96
|
-
# ff.frame(:index, 1)
|
97
|
-
# ff.frame(:name , 'main_frame')
|
98
|
-
# ff.frame('main_frame') # in this case, just a name is supplied.
|
99
|
-
#
|
100
|
-
# Output:
|
101
|
-
# Frame object or nil if the specified frame does not exist.
|
102
|
-
#
|
103
|
-
def frame(how, what = nil)
|
104
|
-
element_by_howwhat(Firefox::Frame, how, what)
|
105
|
-
end
|
106
|
-
|
107
|
-
#
|
108
|
-
# Description:
|
109
|
-
# Used to access a form element. Usually an <form> HTML tag.
|
110
|
-
#
|
111
|
-
# Input:
|
112
|
-
# - how - The attribute used to identify the form.
|
113
|
-
# - what - The value of that attribute.
|
114
|
-
# If only one parameter is supplied, "how" is by default taken as name and the
|
115
|
-
# parameter supplied becomes the value of the name attribute.
|
116
|
-
#
|
117
|
-
# Typical usage:
|
118
|
-
#
|
119
|
-
# ff.form(:index, 1)
|
120
|
-
# ff.form(:name , 'main_form')
|
121
|
-
# ff.form('main_form') # in this case, just a name is supplied.
|
122
|
-
#
|
123
|
-
# Output:
|
124
|
-
# Form object.
|
125
|
-
#
|
126
|
-
def form(how, what=nil)
|
127
|
-
element_by_howwhat(Firefox::Form, how, what)
|
128
|
-
end
|
129
|
-
|
130
|
-
#
|
131
|
-
# Description:
|
132
|
-
# Used to access a table. Usually an <table> HTML tag.
|
133
|
-
#
|
134
|
-
# Input:
|
135
|
-
# - how - The attribute used to identify the table.
|
136
|
-
# - what - The value of that attribute.
|
137
|
-
#
|
138
|
-
# Typical usage:
|
139
|
-
#
|
140
|
-
# ff.table(:index, 1) #index starts from 1.
|
141
|
-
# ff.table(:id, 'main_table')
|
142
|
-
#
|
143
|
-
# Output:
|
144
|
-
# Table object.
|
145
|
-
#
|
146
|
-
def table(how, what=nil)
|
147
|
-
element_by_howwhat(Firefox::Table, how, what)
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# Description:
|
152
|
-
# Used to access a table cell. Usually an <td> HTML tag.
|
153
|
-
#
|
154
|
-
# Input:
|
155
|
-
# - how - The attribute used to identify the cell.
|
156
|
-
# - what - The value of that attribute.
|
157
|
-
#
|
158
|
-
# Typical Usage:
|
159
|
-
# ff.table_cell(:id, 'tb_cell')
|
160
|
-
# ff.table_cell(:index, 1)
|
161
|
-
#
|
162
|
-
# Output:
|
163
|
-
# TableCell Object
|
164
|
-
#
|
165
|
-
def table_cell(how, what=nil)
|
166
|
-
element_by_howwhat(Firefox::TableCell, how, what)
|
167
|
-
end
|
168
|
-
|
169
|
-
#
|
170
|
-
# Description:
|
171
|
-
# Used to access a table row. Usually an <tr> HTML tag.
|
172
|
-
#
|
173
|
-
# Input:
|
174
|
-
# - how - The attribute used to identify the row.
|
175
|
-
# - what - The value of that attribute.
|
176
|
-
#
|
177
|
-
# Typical Usage:
|
178
|
-
# ff.row(:id, 'tb_row')
|
179
|
-
# ff.row(:index, 1)
|
180
|
-
#
|
181
|
-
# Output:
|
182
|
-
# TableRow object
|
183
|
-
#
|
184
|
-
def table_row(how, what=nil)
|
185
|
-
element_by_howwhat(Firefox::TableRow, how, what)
|
186
|
-
end
|
187
|
-
|
188
|
-
#
|
189
|
-
# Description:
|
190
|
-
# Used to access a button element. Usually an <input type = "button"> HTML tag.
|
191
|
-
#
|
192
|
-
# Input:
|
193
|
-
# - how - The attribute used to identify the row.
|
194
|
-
# - what - The value of that attribute.
|
195
|
-
#
|
196
|
-
# Typical Usage:
|
197
|
-
# ff.button(:id, 'b_1') # access the button with an ID of b_1
|
198
|
-
# ff.button(:name, 'verify_data') # access the button with a name of verify_data
|
199
|
-
#
|
200
|
-
# if only a single parameter is supplied, then :value is used as 'how' and parameter supplied is used as what.
|
201
|
-
#
|
202
|
-
# ff.button('Click Me') # access the button with a value of Click Me
|
203
|
-
#
|
204
|
-
# Output:
|
205
|
-
# Button element.
|
206
|
-
#
|
207
|
-
def button(how, what=nil)
|
208
|
-
element_by_howwhat(Firefox::Button, how, what)
|
209
|
-
end
|
210
|
-
|
211
|
-
#
|
212
|
-
# Description:
|
213
|
-
# Used for accessing a file field. Usually an <input type = file> HTML tag.
|
214
|
-
#
|
215
|
-
# Input:
|
216
|
-
# - how - Attribute used to identify the file field element
|
217
|
-
# - what - Value of that attribute.
|
218
|
-
#
|
219
|
-
# Typical Usage:
|
220
|
-
# ff.file_field(:id, 'up_1') # access the file upload fff.d with an ID of up_1
|
221
|
-
# ff.file_field(:name, 'upload') # access the file upload fff.d with a name of upload
|
222
|
-
#
|
223
|
-
# Output:
|
224
|
-
# FileField object
|
225
|
-
#
|
226
|
-
def file_field(how, what = nil)
|
227
|
-
element_by_howwhat(Firefox::FileField, how, what)
|
228
|
-
end
|
229
|
-
|
230
|
-
#
|
231
|
-
# Description:
|
232
|
-
# Used for accessing a text field. Usually an <input type = text> HTML tag. or a text area - a <textarea> tag
|
233
|
-
#
|
234
|
-
# Input:
|
235
|
-
# - how - Attribute used to identify the text field element.
|
236
|
-
# - what - Value of that attribute.
|
237
|
-
#
|
238
|
-
# Typical Usage:
|
239
|
-
#
|
240
|
-
# ff.text_field(:id, 'user_name') # access the text field with an ID of user_name
|
241
|
-
# ff.text_field(:name, 'address') # access the text field with a name of address
|
242
|
-
#
|
243
|
-
# Output:
|
244
|
-
# TextField object.
|
245
|
-
#
|
246
|
-
def text_field(how, what = nil)
|
247
|
-
element_by_howwhat(Firefox::TextField, how, what)
|
248
|
-
end
|
249
|
-
|
250
|
-
#
|
251
|
-
# Description:
|
252
|
-
# Used to access hidden field element. Usually an <input type = hidden> HTML tag
|
253
|
-
#
|
254
|
-
# Input:
|
255
|
-
# - how - Attribute used to identify the hidden element.
|
256
|
-
# - what - Value of that attribute.
|
257
|
-
#
|
258
|
-
# Typical Usage:
|
259
|
-
#
|
260
|
-
# ff.hidden(:id, 'user_name') # access the hidden element with an ID of user_name
|
261
|
-
# ff.hidden(:name, 'address') # access the hidden element with a name of address
|
262
|
-
#
|
263
|
-
# Output:
|
264
|
-
# Hidden object.
|
265
|
-
#
|
266
|
-
def hidden(how, what=nil)
|
267
|
-
element_by_howwhat(Firefox::Hidden, how, what)
|
268
|
-
end
|
269
|
-
|
270
|
-
#
|
271
|
-
# Description:
|
272
|
-
# Used to access select list element. Usually an <select> HTML tag.
|
273
|
-
#
|
274
|
-
# Input:
|
275
|
-
# - how - Attribute used to identify the select element.
|
276
|
-
# - what - Value of that attribute.
|
277
|
-
#
|
278
|
-
# Typical Usage:
|
279
|
-
#
|
280
|
-
# ff.select_list(:id, 'user_name') # access the select list with an ID of user_name
|
281
|
-
# ff.select_list(:name, 'address') # access the select list with a name of address
|
282
|
-
#
|
283
|
-
# Output:
|
284
|
-
# Select List object.
|
285
|
-
#
|
286
|
-
def select_list(how, what=nil)
|
287
|
-
element_by_howwhat(Firefox::SelectList, how, what)
|
288
|
-
end
|
289
|
-
def option(how, what=nil)
|
290
|
-
element_by_howwhat(Firefox::Option, how, what)
|
291
|
-
end
|
292
|
-
=end
|
293
|
-
#
|
294
|
-
# Description:
|
295
|
-
# Used to access checkbox element. Usually an <input type = checkbox> HTML tag.
|
296
|
-
#
|
297
|
-
# Input:
|
298
|
-
# - how - Attribute used to identify the check box element.
|
299
|
-
# - what - Value of that attribute.
|
300
|
-
#
|
301
|
-
# Typical Usage:
|
302
|
-
#
|
303
|
-
# ff.checkbox(:id, 'user_name') # access the checkbox element with an ID of user_name
|
304
|
-
# ff.checkbox(:name, 'address') # access the checkbox element with a name of address
|
305
|
-
# In many instances, checkboxes on an html page have the same name, but are identified by different values. An example is shown next.
|
306
|
-
#
|
307
|
-
# <input type = checkbox name = email_frequency value = 'daily' > Daily Email
|
308
|
-
# <input type = checkbox name = email_frequency value = 'Weekly'> Weekly Email
|
309
|
-
# <input type = checkbox name = email_frequency value = 'monthly'>Monthly Email
|
310
|
-
#
|
311
|
-
# Vapir can access these using the following:
|
312
|
-
#
|
313
|
-
# ff.checkbox(:id, 'day_to_send' , 'monday' ) # access the check box with an id of day_to_send and a value of monday
|
314
|
-
# ff.checkbox(:name ,'email_frequency', 'weekly') # access the check box with a name of email_frequency and a value of 'weekly'
|
315
|
-
#
|
316
|
-
# Output:
|
317
|
-
# Checkbox object.
|
318
|
-
#
|
319
|
-
# def checkbox(how, what=nil, value=nil)
|
320
|
-
# element_by_howwhat(Firefox::CheckBox, how, what, {:other_attributes => value ? {:value => value} : nil})
|
321
|
-
# end
|
322
|
-
|
323
|
-
#
|
324
|
-
# Description:
|
325
|
-
# Used to access radio button element. Usually an <input type = radio> HTML tag.
|
326
|
-
#
|
327
|
-
# Input:
|
328
|
-
# - how - Attribute used to identify the radio button element.
|
329
|
-
# - what - Value of that attribute.
|
330
|
-
#
|
331
|
-
# Typical Usage:
|
332
|
-
#
|
333
|
-
# ff.radio(:id, 'user_name') # access the radio button element with an ID of user_name
|
334
|
-
# ff.radio(:name, 'address') # access the radio button element with a name of address
|
335
|
-
# In many instances, radio buttons on an html page have the same name, but are identified by different values. An example is shown next.
|
336
|
-
#
|
337
|
-
# <input type = radio name = email_frequency value = 'daily' > Daily Email
|
338
|
-
# <input type = radio name = email_frequency value = 'Weekly'> Weekly Email
|
339
|
-
# <input type = radio name = email_frequency value = 'monthly'>Monthly Email
|
340
|
-
#
|
341
|
-
# Vapir can access these using the following:
|
342
|
-
#
|
343
|
-
# ff.radio(:id, 'day_to_send' , 'monday' ) # access the radio button with an id of day_to_send and a value of monday
|
344
|
-
# ff.radio(:name ,'email_frequency', 'weekly') # access the radio button with a name of email_frequency and a value of 'weekly'
|
345
|
-
#
|
346
|
-
# Output:
|
347
|
-
# Radio button object.
|
348
|
-
#
|
349
|
-
# def radio(how, what=nil, value=nil)
|
350
|
-
# element_by_howwhat(Firefox::Radio, how, what, {:other_attributes => value ? {:value => value} : nil})
|
351
|
-
# end
|
352
|
-
|
353
|
-
#
|
354
|
-
# Description:
|
355
|
-
# Used to access link element. Usually an <a> HTML tag.
|
356
|
-
#
|
357
|
-
# Input:
|
358
|
-
# - how - Attribute used to identify the link element.
|
359
|
-
# - what - Value of that attribute.
|
360
|
-
#
|
361
|
-
# Typical Usage:
|
362
|
-
#
|
363
|
-
# ff.link(:id, 'user_name') # access the link element with an ID of user_name
|
364
|
-
# ff.link(:name, 'address') # access the link element with a name of address
|
365
|
-
#
|
366
|
-
# Output:
|
367
|
-
# Link object.
|
368
|
-
#
|
369
|
-
# def link(how, what=nil)
|
370
|
-
# element_by_howwhat(Firefox::Link, how, what)
|
371
|
-
# end
|
372
|
-
|
373
|
-
#
|
374
|
-
# Description:
|
375
|
-
# Used to access image element. Usually an <img> HTML tag.
|
376
|
-
#
|
377
|
-
# Input:
|
378
|
-
# - how - Attribute used to identify the image element.
|
379
|
-
# - what - Value of that attribute.
|
380
|
-
#
|
381
|
-
# Typical Usage:
|
382
|
-
#
|
383
|
-
# ff.image(:id, 'user_name') # access the image element with an ID of user_name
|
384
|
-
# ff.image(:name, 'address') # access the image element with a name of address
|
385
|
-
#
|
386
|
-
# Output:
|
387
|
-
# Image object.
|
388
|
-
#
|
389
|
-
# def image(how, what = nil)
|
390
|
-
# element_by_howwhat(Firefox::Image, how, what)
|
391
|
-
# end
|
392
|
-
|
393
|
-
|
394
|
-
#
|
395
|
-
# Description:
|
396
|
-
# Used to access a definition list element - a <dl> HTML tag.
|
397
|
-
#
|
398
|
-
# Input:
|
399
|
-
# - how - Attribute used to identify the definition list element.
|
400
|
-
# - what - Value of that attribute.
|
401
|
-
#
|
402
|
-
# Typical Usage:
|
403
|
-
#
|
404
|
-
# ff.dl(:id, 'user_name') # access the dl element with an ID of user_name
|
405
|
-
# ff.dl(:title, 'address') # access the dl element with a title of address
|
406
|
-
#
|
407
|
-
# Returns:
|
408
|
-
# Dl object.
|
409
|
-
#
|
410
|
-
# def dl(how, what = nil)
|
411
|
-
# element_by_howwhat(Firefox::Dl, how, what)
|
412
|
-
# end
|
413
|
-
|
414
|
-
#
|
415
|
-
# Description:
|
416
|
-
# Used to access a definition term element - a <dt> HTML tag.
|
417
|
-
#
|
418
|
-
# Input:
|
419
|
-
# - how - Attribute used to identify the image element.
|
420
|
-
# - what - Value of that attribute.
|
421
|
-
#
|
422
|
-
# Typical Usage:
|
423
|
-
#
|
424
|
-
# ff.dt(:id, 'user_name') # access the dt element with an ID of user_name
|
425
|
-
# ff.dt(:title, 'address') # access the dt element with a title of address
|
426
|
-
#
|
427
|
-
# Returns:
|
428
|
-
# Dt object.
|
429
|
-
#
|
430
|
-
# def dt(how, what = nil)
|
431
|
-
# element_by_howwhat(Firefox::Dt, how, what)
|
432
|
-
# end
|
433
|
-
|
434
|
-
#
|
435
|
-
# Description:
|
436
|
-
# Used to access a definition description element - a <dd> HTML tag.
|
437
|
-
#
|
438
|
-
# Input:
|
439
|
-
# - how - Attribute used to identify the image element.
|
440
|
-
# - what - Value of that attribute.
|
441
|
-
#
|
442
|
-
# Typical Usage:
|
443
|
-
#
|
444
|
-
# ff.dd(:id, 'user_name') # access the dd element with an ID of user_name
|
445
|
-
# ff.dd(:title, 'address') # access the dd element with a title of address
|
446
|
-
#
|
447
|
-
# Returns:
|
448
|
-
# Dd object.
|
449
|
-
#
|
450
|
-
# def dd(how, what = nil)
|
451
|
-
# element_by_howwhat(Firefox::Dd, how, what)
|
452
|
-
# end
|
453
|
-
|
454
|
-
# Description:
|
455
|
-
# Searching for Page Elements. Not for external consumption.
|
456
|
-
#
|
457
|
-
# def ole_inner_elements
|
458
|
-
# return document.body.all
|
459
|
-
# end
|
460
|
-
# private :ole_inner_elements
|
461
82
|
end
|
462
83
|
end # module
|
@@ -23,30 +23,15 @@ module Vapir
|
|
23
23
|
attr_reader :jssh_socket
|
24
24
|
|
25
25
|
def outer_html
|
26
|
-
|
27
|
-
# todo/fix: can use cloneNode instead of all this?
|
28
|
-
if parentNode=element_object.parentNode
|
29
|
-
parentNode=parentNode.store_rand_temp
|
30
|
-
orig_siblings=jssh_socket.object('[]').store_rand_prefix('firewatir_elements')
|
31
|
-
parentNode.childNodes.to_array.each do |node|
|
32
|
-
orig_siblings.push node
|
33
|
-
end
|
34
|
-
end
|
26
|
+
orig_siblings_length = (parentNode = element_object.parentNode) && parentNode.childNodes.length
|
35
27
|
|
36
28
|
temp_parent_element=document_object.createElement('div')
|
37
|
-
temp_parent_element.appendChild(element_object)
|
29
|
+
temp_parent_element.appendChild(element_object.cloneNode(true))
|
38
30
|
self_outer_html=temp_parent_element.innerHTML
|
39
31
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
parentNode.removeChild(parentNode.childNodes[0])
|
44
|
-
end
|
45
|
-
while orig_siblings.length > 0
|
46
|
-
parentNode.appendChild orig_siblings.shift
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
32
|
+
new_siblings_length = (parentNode = element_object.parentNode) && parentNode.childNodes.length
|
33
|
+
#debug code:
|
34
|
+
raise "the parent somehow changed - had #{orig_siblings_length} children; now has #{new_siblings_length}" unless orig_siblings_length==new_siblings_length
|
50
35
|
return self_outer_html
|
51
36
|
end
|
52
37
|
alias outerHTML outer_html
|
@@ -55,8 +40,6 @@ module Vapir
|
|
55
40
|
# this is generally the same as the dom object, but different for Browser and Frame.
|
56
41
|
alias containing_object element_object
|
57
42
|
|
58
|
-
# alias ole_object element_object
|
59
|
-
|
60
43
|
private
|
61
44
|
def base_element_class
|
62
45
|
Firefox::Element
|
@@ -264,14 +247,5 @@ module Vapir
|
|
264
247
|
})").call(@element_object, container.document_object) # use the container's document so that frames look at their parent document, not their own document
|
265
248
|
end
|
266
249
|
|
267
|
-
# def invoke(js_method)
|
268
|
-
# element_object.invoke(js_method)
|
269
|
-
# end
|
270
|
-
|
271
|
-
# def assign(property, value)
|
272
|
-
# locate
|
273
|
-
# element_object.attr(property).assign(value)
|
274
|
-
# end
|
275
|
-
|
276
250
|
end # Element
|
277
251
|
end # Vapir
|
@@ -45,14 +45,14 @@ class Object
|
|
45
45
|
end
|
46
46
|
|
47
47
|
|
48
|
-
class JsshError < StandardError
|
49
|
-
attr_accessor :source, :lineNumber, :stack, :fileName
|
50
|
-
end
|
48
|
+
class JsshError < StandardError;end
|
51
49
|
# this exception covers all connection errors either on startup or during usage
|
52
50
|
class JsshConnectionError < JsshError;end
|
53
51
|
# This exception is thrown if we are unable to connect to JSSh.
|
54
52
|
class JsshUnableToStart < JsshConnectionError;end
|
55
|
-
class JsshJavascriptError < JsshError
|
53
|
+
class JsshJavascriptError < JsshError
|
54
|
+
attr_accessor :source, :js_err, :lineNumber, :stack, :fileName
|
55
|
+
end
|
56
56
|
class JsshSyntaxError < JsshJavascriptError;end
|
57
57
|
class JsshUndefinedValueError < JsshJavascriptError;end
|
58
58
|
|
@@ -134,6 +134,16 @@ class JsshSocket
|
|
134
134
|
end
|
135
135
|
|
136
136
|
private
|
137
|
+
# sets the error state if an exception is encountered while running the given block. the
|
138
|
+
# exception is not rescued.
|
139
|
+
def ensuring_extra_handled
|
140
|
+
begin
|
141
|
+
yield
|
142
|
+
rescue Exception
|
143
|
+
@expecting_extra_maybe = true
|
144
|
+
raise
|
145
|
+
end
|
146
|
+
end
|
137
147
|
# reads from the socket and returns what seems to be the value that should be returned, by stripping prompts
|
138
148
|
# from the beginning and end where appropriate.
|
139
149
|
#
|
@@ -164,8 +174,8 @@ class JsshSocket
|
|
164
174
|
already_read_length=false
|
165
175
|
expected_size=nil
|
166
176
|
# logger.add(-1) { "RECV_SOCKET is starting. timeout=#{timeout}" }
|
167
|
-
while size_to_read > 0 && Kernel.select([@socket] , nil , nil, timeout)
|
168
|
-
data = @socket.recv(size_to_read)
|
177
|
+
while size_to_read > 0 && ensuring_extra_handled { Kernel.select([@socket] , nil , nil, timeout) }
|
178
|
+
data = ensuring_extra_handled { @socket.recv(size_to_read) }
|
169
179
|
received_data << data
|
170
180
|
value_string << data
|
171
181
|
if @expecting_prompt && utf8_length_safe(value_string) > PROMPT.length
|
@@ -290,6 +300,7 @@ class JsshSocket
|
|
290
300
|
end
|
291
301
|
err=errclass.new("#{message}\nEvaluating:\n#{source}\n\nOther stuff:\n#{stuff.inspect}")
|
292
302
|
err.source=source
|
303
|
+
err.js_err=stuff
|
293
304
|
["lineNumber", "stack", "fileName"].each do |attr|
|
294
305
|
if stuff.key?(attr)
|
295
306
|
err.send(:"#{attr}=", stuff[attr])
|
@@ -504,6 +515,9 @@ class JsshSocket
|
|
504
515
|
def object(ref)
|
505
516
|
JsshObject.new(ref, self, :debug_name => ref)
|
506
517
|
end
|
518
|
+
def object_in_temp(ref)
|
519
|
+
object(ref).store_rand_temp
|
520
|
+
end
|
507
521
|
|
508
522
|
def temp_object
|
509
523
|
@temp_object ||= object('JsshTemp')
|
@@ -623,19 +637,14 @@ class JsshObject
|
|
623
637
|
else
|
624
638
|
case self.type
|
625
639
|
when 'undefined'
|
626
|
-
if
|
640
|
+
if !options[:error_on_undefined]
|
627
641
|
nil
|
628
|
-
elsif !options[:error_on_undefined]
|
629
|
-
self
|
630
642
|
else
|
631
643
|
raise JsshUndefinedValueError, "undefined expression #{ref}"
|
632
644
|
end
|
633
645
|
when 'boolean','number','string','null'
|
634
646
|
val
|
635
|
-
|
636
|
-
self
|
637
|
-
else
|
638
|
-
# here we perhaps could (but won't for now) raise JsshError, "Unknown type: #{type}"
|
647
|
+
else # 'function','object', or anything else
|
639
648
|
self
|
640
649
|
end
|
641
650
|
end
|
@@ -785,7 +794,7 @@ class JsshObject
|
|
785
794
|
binary_operator('%', operand)
|
786
795
|
end
|
787
796
|
def ==(operand)
|
788
|
-
binary_operator('==', operand)
|
797
|
+
operand.is_a?(JsshObject) && binary_operator('==', operand)
|
789
798
|
end
|
790
799
|
def >(operand)
|
791
800
|
binary_operator('>', operand)
|
@@ -999,9 +1008,31 @@ class JsshObject
|
|
999
1008
|
end
|
1000
1009
|
|
1001
1010
|
class JsshDOMNode < JsshObject
|
1011
|
+
def inspect_stuff
|
1012
|
+
[:nodeName, :nodeType, :nodeValue, :tagName, :textContent, :id, :name, :value, :type, :className, :hidden].map do |attrn|
|
1013
|
+
attr=attr(attrn)
|
1014
|
+
if ['undefined','null'].include?(attr.type)
|
1015
|
+
nil
|
1016
|
+
else
|
1017
|
+
[attrn, attr.val_or_object(:error_on_undefined => false)]
|
1018
|
+
end
|
1019
|
+
end.compact
|
1020
|
+
end
|
1002
1021
|
def inspect
|
1003
|
-
|
1004
|
-
|
1022
|
+
"\#<#{self.class.name} #{inspect_stuff.map{|(k,v)| "#{k}=#{v.inspect}"}.join(', ')}>"
|
1023
|
+
end
|
1024
|
+
def pretty_print(pp)
|
1025
|
+
pp.object_address_group(self) do
|
1026
|
+
pp.seplist(inspect_stuff, lambda { pp.text ',' }) do |attr_val|
|
1027
|
+
pp.breakable ' '
|
1028
|
+
pp.group(0) do
|
1029
|
+
pp.text attr_val.first.to_s
|
1030
|
+
pp.text ': '
|
1031
|
+
#pp.breakable
|
1032
|
+
pp.text attr_val.last.inspect
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
end
|
1005
1036
|
end
|
1006
1037
|
def dump(options={})
|
1007
1038
|
options={:recurse => nil, :level => 0}.merge(options)
|
@@ -125,7 +125,7 @@ module Vapir
|
|
125
125
|
containing_modal_dialog.modal_window
|
126
126
|
end
|
127
127
|
def locate!(options={})
|
128
|
-
exists? || raise(Vapir::Exception::
|
128
|
+
exists? || raise(Vapir::Exception::WindowGoneException, "The modal dialog seems to have stopped existing.")
|
129
129
|
end
|
130
130
|
|
131
131
|
def exists?
|
@@ -1,20 +1,10 @@
|
|
1
1
|
require 'vapir-firefox/container'
|
2
|
+
require 'vapir-common/page_container'
|
2
3
|
|
3
4
|
module Vapir
|
4
5
|
module Firefox::PageContainer
|
5
|
-
|
6
|
-
document_object
|
7
|
-
end
|
6
|
+
include Vapir::PageContainer
|
8
7
|
include Firefox::Container
|
9
|
-
def url
|
10
|
-
document_object.location.href
|
11
|
-
end
|
12
|
-
def title
|
13
|
-
document_object.title
|
14
|
-
end
|
15
|
-
def document_element
|
16
|
-
document_object.documentElement
|
17
|
-
end
|
18
8
|
#def content_window_object
|
19
9
|
# document_object.parentWindow
|
20
10
|
#end
|
@@ -22,10 +12,6 @@ module Vapir
|
|
22
12
|
document_element.textContent
|
23
13
|
end
|
24
14
|
|
25
|
-
def page_container
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
15
|
# returns nil or raises an error if the given javascript errors.
|
30
16
|
#
|
31
17
|
# todo/fix: this should return the last evaluated value, like ie's?
|
@@ -42,50 +28,19 @@ module Vapir
|
|
42
28
|
end
|
43
29
|
|
44
30
|
# Returns the html of the document
|
45
|
-
def
|
46
|
-
jssh_socket.
|
47
|
-
|
48
|
-
var
|
49
|
-
while(document.childNodes.length > 0)
|
50
|
-
{ orig_childs.push(document.childNodes[0]);
|
51
|
-
document.removeChild(document.childNodes[0]);
|
52
|
-
/* we remove each childNode here because doing appendChild on temp_el removes it
|
53
|
-
* from document anyway (at least when appendChild works), so we just remove all
|
54
|
-
* childNodes so that adding them back in the right order is simpler (using orig_childs)
|
55
|
-
*/
|
56
|
-
}
|
57
|
-
for(var i in orig_childs)
|
31
|
+
def outer_html
|
32
|
+
jssh_socket.object("(function(document)
|
33
|
+
{ var temp_el=document.createElement('div');
|
34
|
+
for(var i in document.childNodes)
|
58
35
|
{ try
|
59
|
-
{ temp_el.appendChild(
|
36
|
+
{ temp_el.appendChild(document.childNodes[i].cloneNode(true));
|
60
37
|
}
|
61
38
|
catch(e)
|
62
39
|
{}
|
63
40
|
}
|
64
|
-
|
65
|
-
|
66
|
-
{ document.appendChild(orig_childs.shift());
|
67
|
-
}
|
68
|
-
return retval;
|
69
|
-
})(#{document_object.ref})")
|
70
|
-
=begin
|
71
|
-
temp_el=document_object.createElement('div') # make a temporary element
|
72
|
-
orig_childs=jssh_socket.object('[]').store_rand_object_key(@browser_jssh_objects)
|
73
|
-
while document_object.childNodes.length > 0
|
74
|
-
orig_childs.push(document_object.childNodes[0])
|
75
|
-
document_object.removeChild(document_object.childNodes[0])
|
76
|
-
end
|
77
|
-
orig_childs.to_array.each do |child|
|
78
|
-
begin
|
79
|
-
temp_el.appendChild(child)
|
80
|
-
rescue JsshError
|
81
|
-
end
|
82
|
-
end
|
83
|
-
result=temp_el.innerHTML
|
84
|
-
while orig_childs.length > 0
|
85
|
-
document_object.appendChild(orig_childs.shift())
|
86
|
-
end
|
87
|
-
return result
|
88
|
-
=end
|
41
|
+
return temp_el.innerHTML;
|
42
|
+
})").call(document_object)
|
89
43
|
end
|
44
|
+
alias html outer_html
|
90
45
|
end
|
91
46
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vapir-firefox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
|
8
|
+
- 1
|
9
|
+
- rc1
|
10
|
+
version: 1.7.1.rc1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ethan
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-06
|
18
|
+
date: 2010-08-06 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +28,9 @@ dependencies:
|
|
27
28
|
segments:
|
28
29
|
- 1
|
29
30
|
- 7
|
30
|
-
-
|
31
|
-
|
31
|
+
- 1
|
32
|
+
- rc1
|
33
|
+
version: 1.7.1.rc1
|
32
34
|
type: :runtime
|
33
35
|
version_requirements: *id001
|
34
36
|
- !ruby/object:Gem::Dependency
|
@@ -119,11 +121,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
121
|
version: "0"
|
120
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
123
|
requirements:
|
122
|
-
- - "
|
124
|
+
- - ">"
|
123
125
|
- !ruby/object:Gem::Version
|
124
126
|
segments:
|
125
|
-
-
|
126
|
-
|
127
|
+
- 1
|
128
|
+
- 3
|
129
|
+
- 1
|
130
|
+
version: 1.3.1
|
127
131
|
requirements:
|
128
132
|
- Firefox browser with JSSH extension installed
|
129
133
|
rubyforge_project:
|