Module: Vapir::Firefox::Window

Included in:
Vapir::Firefox, ModalDialog
Defined in:
lib/vapir-firefox/window.rb

Overview

this contains methods for an object that represnts a thing that has its own window. that includes a Browser and a ModalDialog. this assumes that #browser_window_object is defined on the includer.

Instance Method Summary collapse

Instance Method Details

#bring_to_frontObject

sets this window as the foreground window (MS Windows only)



34
35
36
# File 'lib/vapir-firefox/window.rb', line 34

def bring_to_front
  win_window.really_set_foreground!
end

#hwndObject

returns the hWnd of this window. (MS Windows-only)



8
9
10
# File 'lib/vapir-firefox/window.rb', line 8

def hwnd
  win_window.hwnd
end

#win_windowObject

returns an instance of WinWindow representing this window. (MS Windows only)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vapir-firefox/window.rb', line 13

def win_window
  Vapir.require_winwindow
  @win_window||=begin
    orig_browser_window_title=browser_window_object.document.title
    browser_window_object.document.title=orig_browser_window_title+(rand(36**16).to_s(36))
    begin
      candidates=::Waiter.try_for(2, :condition => proc{|ret| ret.size > 0}, :exception => nil) do
        WinWindow::All.select do |win|
          [mozilla_window_class_name].include?(win.class_name) && win.text==browser_window_object.document.title
        end
      end
      unless candidates.size==1
        raise ::WinWindow::MatchError, "Found #{candidates.size} Mozilla windows titled #{browser_window_object.document.title}"
      end
      candidates.first
    ensure
      browser_window_object.document.title=orig_browser_window_title
    end
  end
end