Module: Vapir::Firefox::PageContainer

Includes:
Container, PageContainer
Included in:
Vapir::Firefox, Frame, ModalDialogDocument
Defined in:
lib/vapir-firefox/page_container.rb

Instance Method Summary collapse

Methods included from Container

#element_by_xpath, #element_object_by_xpath, #element_objects_by_xpath, #elements_by_xpath, #extra_for_contained

Instance Method Details

#execute_script(javascript) ⇒ Object

returns nil or raises an error if the given javascript errors.

todo/fix: this should return the last evaluated value, like ie’s?



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vapir-firefox/page_container.rb', line 18

def execute_script(javascript)
  jssh_socket.value_json("(function()
  { with(#{content_window_object.ref})
    { #{javascript} }
    return null;
  })()")
  #sandbox=jssh_socket.Components.utils.Sandbox(content_window_object)
  #sandbox.window=content_window_object
  #sandbox.document=content_window_object.document
  #return jssh_socket.Components.utils.evalInSandbox(javascript, sandbox)
end

#outer_htmlObject Also known as: html

Returns the html of the document



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vapir-firefox/page_container.rb', line 31

def outer_html
  jssh_socket.object("(function(document)
  { var temp_el=document.createElement('div');
    for(var i in document.childNodes)
    { try
      { temp_el.appendChild(document.childNodes[i].cloneNode(true));
      }
      catch(e)
      {}
    }
    return temp_el.innerHTML;
  })").call(document_object)
end

#textObject

def content_window_object

document_object.parentWindow

end



11
12
13
# File 'lib/vapir-firefox/page_container.rb', line 11

def text
  document_element.textContent
end