6
def supported?; true; end
13
Config::CONFIG['host']
17
host.include?('darwin')
21
host.include?('mswin')
25
host.include?('linux')
28
def applescript(script)
29
raise "Can't run AppleScript on #{host}" unless macos?
30
system "osascript -e '#{script}' 2>&1 >/dev/null"
34
class FirefoxBrowser < Browser
35
def initialize(path='c:\Program Files\Mozilla Firefox\firefox.exe')
40
applescript('tell application "Firefox" to Get URL "' + url + '"') if macos?
41
system("#{@path} #{url}") if windows?
42
system("firefox #{url}") if linux?
50
class SafariBrowser < Browser
56
applescript('tell application "Safari" to make new document')
60
applescript('tell application "Safari" to set URL of front document to "' + url + '"')
64
#applescript('tell application "Safari" to close front document')
72
class IEBrowser < Browser
73
def initialize(path='C:\Program Files\Internet Explorer\IEXPLORE.EXE')
80
MAJOR ANNOYANCE on Windows.
81
You have to shut down the Internet Explorer manually after each test
82
for the script to proceed.
83
Any suggestions on fixing this is GREATLY appreaciated!
84
Thank you for your understanding.
94
system("#{@path} #{url}") if windows?
102
class KonquerorBrowser < Browser
108
system("kfmclient openURL #{url}")
116
# shut up, webrick :-)
117
class ::WEBrick::HTTPServer
118
def access_log(config, req, res)
122
class ::WEBrick::BasicLog
128
class JavaScriptTestTask < ::Rake::TaskLib
130
def initialize(name=:test)
139
@server = WEBrick::HTTPServer.new(:Port => 4711) # TODO: make port configurable
140
@server.mount_proc("/results") do |req, res|
141
@queue.push(req.query['result'])
144
yield self if block_given?
150
trap("INT") { @server.shutdown }
151
t = Thread.new { @server.start }
153
# run all combinations of browsers and tests
154
@browsers.each do |browser|
155
if browser.supported?
157
@tests.each do |test|
158
browser.visit("http://localhost:4711#{test}?resultsURL=http://localhost:4711/results&t=" + ("%.6f" % Time.now.to_f))
160
puts "#{test} on #{browser}: #{result}"
164
puts "Skipping #{browser}, not supported on this OS"
174
def mount(path, dir=nil)
175
dir = Dir.pwd + path unless dir
177
@server.mount(path, WEBrick::HTTPServlet::FileHandler, dir)
180
# test should be specified as a url