otherinbox-capybara-webkit 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Appraisals +7 -0
- data/CONTRIBUTING.md +47 -0
- data/ChangeLog +70 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +68 -0
- data/LICENSE +19 -0
- data/NEWS.md +36 -0
- data/README.md +114 -0
- data/Rakefile +65 -0
- data/bin/Info.plist +22 -0
- data/capybara-webkit.gemspec +28 -0
- data/extconf.rb +2 -0
- data/gemfiles/1.0.gemfile +7 -0
- data/gemfiles/1.0.gemfile.lock +70 -0
- data/gemfiles/1.1.gemfile +7 -0
- data/gemfiles/1.1.gemfile.lock +70 -0
- data/lib/capybara-webkit.rb +1 -0
- data/lib/capybara/driver/webkit.rb +135 -0
- data/lib/capybara/driver/webkit/browser.rb +168 -0
- data/lib/capybara/driver/webkit/connection.rb +120 -0
- data/lib/capybara/driver/webkit/cookie_jar.rb +55 -0
- data/lib/capybara/driver/webkit/node.rb +118 -0
- data/lib/capybara/driver/webkit/socket_debugger.rb +43 -0
- data/lib/capybara/driver/webkit/version.rb +7 -0
- data/lib/capybara/webkit.rb +11 -0
- data/lib/capybara/webkit/matchers.rb +37 -0
- data/lib/capybara_webkit_builder.rb +68 -0
- data/spec/browser_spec.rb +248 -0
- data/spec/capybara_webkit_builder_spec.rb +37 -0
- data/spec/connection_spec.rb +54 -0
- data/spec/cookie_jar_spec.rb +48 -0
- data/spec/driver_rendering_spec.rb +80 -0
- data/spec/driver_resize_window_spec.rb +59 -0
- data/spec/driver_spec.rb +1552 -0
- data/spec/integration/driver_spec.rb +20 -0
- data/spec/integration/session_spec.rb +137 -0
- data/spec/self_signed_ssl_cert.rb +42 -0
- data/spec/spec_helper.rb +46 -0
- data/src/Body.h +12 -0
- data/src/ClearCookies.cpp +15 -0
- data/src/ClearCookies.h +11 -0
- data/src/Command.cpp +19 -0
- data/src/Command.h +31 -0
- data/src/CommandFactory.cpp +38 -0
- data/src/CommandFactory.h +16 -0
- data/src/CommandParser.cpp +76 -0
- data/src/CommandParser.h +33 -0
- data/src/Connection.cpp +71 -0
- data/src/Connection.h +37 -0
- data/src/ConsoleMessages.cpp +10 -0
- data/src/ConsoleMessages.h +12 -0
- data/src/CurrentUrl.cpp +68 -0
- data/src/CurrentUrl.h +16 -0
- data/src/Evaluate.cpp +84 -0
- data/src/Evaluate.h +22 -0
- data/src/Execute.cpp +16 -0
- data/src/Execute.h +12 -0
- data/src/Find.cpp +19 -0
- data/src/Find.h +13 -0
- data/src/FrameFocus.cpp +66 -0
- data/src/FrameFocus.h +28 -0
- data/src/GetCookies.cpp +20 -0
- data/src/GetCookies.h +14 -0
- data/src/Header.cpp +18 -0
- data/src/Header.h +11 -0
- data/src/Headers.cpp +10 -0
- data/src/Headers.h +12 -0
- data/src/IgnoreSslErrors.cpp +12 -0
- data/src/IgnoreSslErrors.h +12 -0
- data/src/JavascriptInvocation.cpp +14 -0
- data/src/JavascriptInvocation.h +19 -0
- data/src/NetworkAccessManager.cpp +29 -0
- data/src/NetworkAccessManager.h +19 -0
- data/src/NetworkCookieJar.cpp +101 -0
- data/src/NetworkCookieJar.h +15 -0
- data/src/Node.cpp +14 -0
- data/src/Node.h +13 -0
- data/src/NullCommand.cpp +10 -0
- data/src/NullCommand.h +11 -0
- data/src/PageLoadingCommand.cpp +46 -0
- data/src/PageLoadingCommand.h +40 -0
- data/src/Render.cpp +18 -0
- data/src/Render.h +12 -0
- data/src/RequestedUrl.cpp +12 -0
- data/src/RequestedUrl.h +12 -0
- data/src/Reset.cpp +29 -0
- data/src/Reset.h +15 -0
- data/src/ResizeWindow.cpp +16 -0
- data/src/ResizeWindow.h +12 -0
- data/src/Response.cpp +24 -0
- data/src/Response.h +15 -0
- data/src/Server.cpp +24 -0
- data/src/Server.h +21 -0
- data/src/SetCookie.cpp +16 -0
- data/src/SetCookie.h +11 -0
- data/src/SetProxy.cpp +22 -0
- data/src/SetProxy.h +11 -0
- data/src/SetSkipImageLoading.cpp +11 -0
- data/src/SetSkipImageLoading.h +11 -0
- data/src/Source.cpp +18 -0
- data/src/Source.h +19 -0
- data/src/Status.cpp +12 -0
- data/src/Status.h +12 -0
- data/src/UnsupportedContentHandler.cpp +32 -0
- data/src/UnsupportedContentHandler.h +18 -0
- data/src/Url.cpp +12 -0
- data/src/Url.h +12 -0
- data/src/Visit.cpp +12 -0
- data/src/Visit.h +12 -0
- data/src/WebPage.cpp +246 -0
- data/src/WebPage.h +58 -0
- data/src/body.cpp +10 -0
- data/src/capybara.js +315 -0
- data/src/find_command.h +30 -0
- data/src/main.cpp +31 -0
- data/src/webkit_server.pro +87 -0
- data/src/webkit_server.qrc +5 -0
- data/templates/Command.cpp +10 -0
- data/templates/Command.h +12 -0
- data/webkit_server.pro +4 -0
- metadata +300 -0
data/bin/Info.plist
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
3
|
+
<plist version="0.9">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleIconFile</key>
|
6
|
+
<string></string>
|
7
|
+
<key>CFBundlePackageType</key>
|
8
|
+
<string>APPL</string>
|
9
|
+
<key>CFBundleGetInfoString</key>
|
10
|
+
<string>Created by Qt/QMake</string>
|
11
|
+
<key>CFBundleSignature</key>
|
12
|
+
<string>????</string>
|
13
|
+
<key>CFBundleExecutable</key>
|
14
|
+
<string>webkit_server</string>
|
15
|
+
<key>CFBundleIdentifier</key>
|
16
|
+
<string>com.yourcompany.webkit_server</string>
|
17
|
+
<key>NOTE</key>
|
18
|
+
<string>This file was generated by Qt/QMake.</string>
|
19
|
+
<key>LSUIElement</key>
|
20
|
+
<string>1</string>
|
21
|
+
</dict>
|
22
|
+
</plist>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "capybara/driver/webkit/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "otherinbox-capybara-webkit"
|
6
|
+
s.version = Capybara::Driver::Webkit::VERSION.dup
|
7
|
+
s.authors = ["thoughtbot", "Joe Ferris", "Matt Mongeau", "Mike Burns", "Jason Morrison"]
|
8
|
+
s.email = "support@thoughtbot.com"
|
9
|
+
s.homepage = "http://github.com/thoughtbot/capybara-webkit"
|
10
|
+
s.summary = "Headless Webkit driver for Capybara"
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
14
|
+
s.require_path = "lib"
|
15
|
+
|
16
|
+
s.extensions = "extconf.rb"
|
17
|
+
|
18
|
+
s.add_runtime_dependency("capybara", [">= 1.0.0", "< 1.2"])
|
19
|
+
s.add_runtime_dependency("json")
|
20
|
+
|
21
|
+
s.add_development_dependency("rspec", "~> 2.6.0")
|
22
|
+
# Sinatra is used by Capybara's TestApp
|
23
|
+
s.add_development_dependency("sinatra")
|
24
|
+
s.add_development_dependency("mini_magick")
|
25
|
+
s.add_development_dependency("rake")
|
26
|
+
s.add_development_dependency("appraisal", "~> 0.4.0")
|
27
|
+
end
|
28
|
+
|
data/extconf.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/jferris/Source/capybara-webkit
|
3
|
+
specs:
|
4
|
+
capybara-webkit (0.8.0)
|
5
|
+
capybara (>= 1.0.0, < 1.2)
|
6
|
+
json
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
appraisal (0.4.0)
|
12
|
+
bundler
|
13
|
+
rake
|
14
|
+
capybara (1.0.1)
|
15
|
+
mime-types (>= 1.16)
|
16
|
+
nokogiri (>= 1.3.3)
|
17
|
+
rack (>= 1.0.0)
|
18
|
+
rack-test (>= 0.5.4)
|
19
|
+
selenium-webdriver (~> 2.0)
|
20
|
+
xpath (~> 0.1.4)
|
21
|
+
childprocess (0.2.2)
|
22
|
+
ffi (~> 1.0.6)
|
23
|
+
diff-lcs (1.1.3)
|
24
|
+
ffi (1.0.10)
|
25
|
+
json (1.6.3)
|
26
|
+
json_pure (1.6.1)
|
27
|
+
mime-types (1.17.2)
|
28
|
+
mini_magick (3.3)
|
29
|
+
subexec (~> 0.1.0)
|
30
|
+
nokogiri (1.5.0)
|
31
|
+
rack (1.3.5)
|
32
|
+
rack-protection (1.1.4)
|
33
|
+
rack
|
34
|
+
rack-test (0.6.1)
|
35
|
+
rack (>= 1.0)
|
36
|
+
rake (0.9.2.2)
|
37
|
+
rspec (2.6.0)
|
38
|
+
rspec-core (~> 2.6.0)
|
39
|
+
rspec-expectations (~> 2.6.0)
|
40
|
+
rspec-mocks (~> 2.6.0)
|
41
|
+
rspec-core (2.6.4)
|
42
|
+
rspec-expectations (2.6.0)
|
43
|
+
diff-lcs (~> 1.1.2)
|
44
|
+
rspec-mocks (2.6.0)
|
45
|
+
rubyzip (0.9.4)
|
46
|
+
selenium-webdriver (2.12.1)
|
47
|
+
childprocess (>= 0.2.1)
|
48
|
+
ffi (~> 1.0.9)
|
49
|
+
json_pure
|
50
|
+
rubyzip
|
51
|
+
sinatra (1.3.1)
|
52
|
+
rack (~> 1.3, >= 1.3.4)
|
53
|
+
rack-protection (~> 1.1, >= 1.1.2)
|
54
|
+
tilt (~> 1.3, >= 1.3.3)
|
55
|
+
subexec (0.1.0)
|
56
|
+
tilt (1.3.3)
|
57
|
+
xpath (0.1.4)
|
58
|
+
nokogiri (~> 1.3)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
appraisal (~> 0.4.0)
|
65
|
+
capybara (~> 1.0.0)
|
66
|
+
capybara-webkit!
|
67
|
+
mini_magick
|
68
|
+
rake
|
69
|
+
rspec (~> 2.6.0)
|
70
|
+
sinatra
|
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/jferris/Source/capybara-webkit
|
3
|
+
specs:
|
4
|
+
capybara-webkit (0.8.0)
|
5
|
+
capybara (>= 1.0.0, < 1.2)
|
6
|
+
json
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
appraisal (0.4.0)
|
12
|
+
bundler
|
13
|
+
rake
|
14
|
+
capybara (1.1.1)
|
15
|
+
mime-types (>= 1.16)
|
16
|
+
nokogiri (>= 1.3.3)
|
17
|
+
rack (>= 1.0.0)
|
18
|
+
rack-test (>= 0.5.4)
|
19
|
+
selenium-webdriver (~> 2.0)
|
20
|
+
xpath (~> 0.1.4)
|
21
|
+
childprocess (0.2.2)
|
22
|
+
ffi (~> 1.0.6)
|
23
|
+
diff-lcs (1.1.3)
|
24
|
+
ffi (1.0.10)
|
25
|
+
json (1.6.3)
|
26
|
+
json_pure (1.6.1)
|
27
|
+
mime-types (1.17.2)
|
28
|
+
mini_magick (3.3)
|
29
|
+
subexec (~> 0.1.0)
|
30
|
+
nokogiri (1.5.0)
|
31
|
+
rack (1.3.5)
|
32
|
+
rack-protection (1.1.4)
|
33
|
+
rack
|
34
|
+
rack-test (0.6.1)
|
35
|
+
rack (>= 1.0)
|
36
|
+
rake (0.9.2.2)
|
37
|
+
rspec (2.6.0)
|
38
|
+
rspec-core (~> 2.6.0)
|
39
|
+
rspec-expectations (~> 2.6.0)
|
40
|
+
rspec-mocks (~> 2.6.0)
|
41
|
+
rspec-core (2.6.4)
|
42
|
+
rspec-expectations (2.6.0)
|
43
|
+
diff-lcs (~> 1.1.2)
|
44
|
+
rspec-mocks (2.6.0)
|
45
|
+
rubyzip (0.9.4)
|
46
|
+
selenium-webdriver (2.12.1)
|
47
|
+
childprocess (>= 0.2.1)
|
48
|
+
ffi (~> 1.0.9)
|
49
|
+
json_pure
|
50
|
+
rubyzip
|
51
|
+
sinatra (1.3.1)
|
52
|
+
rack (~> 1.3, >= 1.3.4)
|
53
|
+
rack-protection (~> 1.1, >= 1.1.2)
|
54
|
+
tilt (~> 1.3, >= 1.3.3)
|
55
|
+
subexec (0.1.0)
|
56
|
+
tilt (1.3.3)
|
57
|
+
xpath (0.1.4)
|
58
|
+
nokogiri (~> 1.3)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
appraisal (~> 0.4.0)
|
65
|
+
capybara (~> 1.1.0)
|
66
|
+
capybara-webkit!
|
67
|
+
mini_magick
|
68
|
+
rake
|
69
|
+
rspec (~> 2.6.0)
|
70
|
+
sinatra
|
@@ -0,0 +1 @@
|
|
1
|
+
require "capybara/webkit"
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require "capybara"
|
2
|
+
require "capybara/driver/webkit/version"
|
3
|
+
require "capybara/driver/webkit/node"
|
4
|
+
require "capybara/driver/webkit/connection"
|
5
|
+
require "capybara/driver/webkit/browser"
|
6
|
+
require "capybara/driver/webkit/socket_debugger"
|
7
|
+
require "capybara/driver/webkit/cookie_jar"
|
8
|
+
|
9
|
+
class Capybara::Driver::Webkit
|
10
|
+
class WebkitInvalidResponseError < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
class WebkitNoResponseError < StandardError
|
14
|
+
end
|
15
|
+
|
16
|
+
class NodeNotAttachedError < Capybara::ElementNotFound
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :browser
|
20
|
+
|
21
|
+
def initialize(app, options={})
|
22
|
+
@app = app
|
23
|
+
@options = options
|
24
|
+
@rack_server = Capybara::Server.new(@app)
|
25
|
+
@rack_server.boot if Capybara.run_server
|
26
|
+
@browser = options[:browser] || Browser.new(Connection.new(options))
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_url
|
30
|
+
browser.current_url
|
31
|
+
end
|
32
|
+
|
33
|
+
def requested_url
|
34
|
+
browser.requested_url
|
35
|
+
end
|
36
|
+
|
37
|
+
def visit(path)
|
38
|
+
browser.visit(url(path))
|
39
|
+
end
|
40
|
+
|
41
|
+
def find(query)
|
42
|
+
browser.find(query).map { |native| Node.new(self, native) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def source
|
46
|
+
browser.source
|
47
|
+
end
|
48
|
+
|
49
|
+
def body
|
50
|
+
browser.body
|
51
|
+
end
|
52
|
+
|
53
|
+
def header(key, value)
|
54
|
+
browser.header(key, value)
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute_script(script)
|
58
|
+
value = browser.execute_script script
|
59
|
+
value.empty? ? nil : value
|
60
|
+
end
|
61
|
+
|
62
|
+
def evaluate_script(script)
|
63
|
+
browser.evaluate_script script
|
64
|
+
end
|
65
|
+
|
66
|
+
def console_messages
|
67
|
+
browser.console_messages
|
68
|
+
end
|
69
|
+
|
70
|
+
def error_messages
|
71
|
+
browser.error_messages
|
72
|
+
end
|
73
|
+
|
74
|
+
def response_headers
|
75
|
+
browser.response_headers
|
76
|
+
end
|
77
|
+
|
78
|
+
def status_code
|
79
|
+
browser.status_code
|
80
|
+
end
|
81
|
+
|
82
|
+
def resize_window(width, height)
|
83
|
+
browser.resize_window(width, height)
|
84
|
+
end
|
85
|
+
|
86
|
+
def within_frame(frame_id_or_index)
|
87
|
+
browser.frame_focus(frame_id_or_index)
|
88
|
+
begin
|
89
|
+
yield
|
90
|
+
ensure
|
91
|
+
browser.frame_focus
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def within_window(handle)
|
96
|
+
raise Capybara::NotSupportedByDriverError
|
97
|
+
end
|
98
|
+
|
99
|
+
def wait?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def wait_until(*args)
|
104
|
+
end
|
105
|
+
|
106
|
+
def reset!
|
107
|
+
browser.reset!
|
108
|
+
end
|
109
|
+
|
110
|
+
def has_shortcircuit_timeout?
|
111
|
+
false
|
112
|
+
end
|
113
|
+
|
114
|
+
def render(path, options={})
|
115
|
+
options[:width] ||= 1000
|
116
|
+
options[:height] ||= 10
|
117
|
+
|
118
|
+
browser.render path, options[:width], options[:height]
|
119
|
+
end
|
120
|
+
|
121
|
+
def server_port
|
122
|
+
@rack_server.port
|
123
|
+
end
|
124
|
+
|
125
|
+
def cookies
|
126
|
+
@cookie_jar ||= CookieJar.new(browser)
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def url(path)
|
132
|
+
@rack_server.url(path)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Capybara::Driver::Webkit
|
4
|
+
class Browser
|
5
|
+
def initialize(connection)
|
6
|
+
@connection = connection
|
7
|
+
end
|
8
|
+
|
9
|
+
def visit(url)
|
10
|
+
command "Visit", url
|
11
|
+
end
|
12
|
+
|
13
|
+
def header(key, value)
|
14
|
+
command("Header", key, value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(query)
|
18
|
+
command("Find", query).split(",")
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset!
|
22
|
+
command("Reset")
|
23
|
+
end
|
24
|
+
|
25
|
+
def body
|
26
|
+
command("Body")
|
27
|
+
end
|
28
|
+
|
29
|
+
def source
|
30
|
+
command("Source")
|
31
|
+
end
|
32
|
+
|
33
|
+
def status_code
|
34
|
+
command("Status").to_i
|
35
|
+
end
|
36
|
+
|
37
|
+
def console_messages
|
38
|
+
command("ConsoleMessages").split("\n").map do |messages|
|
39
|
+
parts = messages.split("|", 3)
|
40
|
+
{ :source => parts.first, :line_number => Integer(parts[1]), :message => parts.last }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def error_messages
|
45
|
+
console_messages.select do |message|
|
46
|
+
message[:message] =~ /Error:/
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def response_headers
|
51
|
+
Hash[command("Headers").split("\n").map { |header| header.split(": ") }]
|
52
|
+
end
|
53
|
+
|
54
|
+
def url
|
55
|
+
command("Url")
|
56
|
+
end
|
57
|
+
|
58
|
+
def requested_url
|
59
|
+
command("RequestedUrl")
|
60
|
+
end
|
61
|
+
|
62
|
+
def current_url
|
63
|
+
command("CurrentUrl")
|
64
|
+
end
|
65
|
+
|
66
|
+
def frame_focus(frame_id_or_index=nil)
|
67
|
+
if frame_id_or_index.is_a? Fixnum
|
68
|
+
command("FrameFocus", "", frame_id_or_index.to_s)
|
69
|
+
elsif frame_id_or_index
|
70
|
+
command("FrameFocus", frame_id_or_index)
|
71
|
+
else
|
72
|
+
command("FrameFocus")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def ignore_ssl_errors
|
77
|
+
command("IgnoreSslErrors")
|
78
|
+
end
|
79
|
+
|
80
|
+
def set_skip_image_loading(skip_image_loading)
|
81
|
+
command("SetSkipImageLoading", skip_image_loading)
|
82
|
+
end
|
83
|
+
|
84
|
+
def command(name, *args)
|
85
|
+
@connection.puts name
|
86
|
+
@connection.puts args.size
|
87
|
+
args.each do |arg|
|
88
|
+
@connection.puts arg.to_s.bytesize
|
89
|
+
@connection.print arg.to_s
|
90
|
+
end
|
91
|
+
check
|
92
|
+
read_response
|
93
|
+
end
|
94
|
+
|
95
|
+
def evaluate_script(script)
|
96
|
+
json = command('Evaluate', script)
|
97
|
+
JSON.parse("[#{json}]").first
|
98
|
+
end
|
99
|
+
|
100
|
+
def execute_script(script)
|
101
|
+
command('Execute', script)
|
102
|
+
end
|
103
|
+
|
104
|
+
def render(path, width, height)
|
105
|
+
command "Render", path, width, height
|
106
|
+
end
|
107
|
+
|
108
|
+
def set_cookie(cookie)
|
109
|
+
command "SetCookie", cookie
|
110
|
+
end
|
111
|
+
|
112
|
+
def clear_cookies
|
113
|
+
command "ClearCookies"
|
114
|
+
end
|
115
|
+
|
116
|
+
def get_cookies
|
117
|
+
command("GetCookies").lines.map{ |line| line.strip }.select{ |line| !line.empty? }
|
118
|
+
end
|
119
|
+
|
120
|
+
def set_proxy(options = {})
|
121
|
+
options = default_proxy_options.merge(options)
|
122
|
+
command("SetProxy", options[:host], options[:port], options[:user], options[:pass])
|
123
|
+
end
|
124
|
+
|
125
|
+
def clear_proxy
|
126
|
+
command("SetProxy")
|
127
|
+
end
|
128
|
+
|
129
|
+
def resize_window(width, height)
|
130
|
+
command("ResizeWindow", width.to_i, height.to_i)
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def check
|
136
|
+
result = @connection.gets
|
137
|
+
result.strip! if result
|
138
|
+
|
139
|
+
if result.nil?
|
140
|
+
raise WebkitNoResponseError, "No response received from the server."
|
141
|
+
elsif result != 'ok'
|
142
|
+
raise WebkitInvalidResponseError, read_response
|
143
|
+
end
|
144
|
+
|
145
|
+
result
|
146
|
+
end
|
147
|
+
|
148
|
+
def read_response
|
149
|
+
response_length = @connection.gets.to_i
|
150
|
+
if response_length > 0
|
151
|
+
response = @connection.read(response_length)
|
152
|
+
response.force_encoding("UTF-8") if response.respond_to?(:force_encoding)
|
153
|
+
response
|
154
|
+
else
|
155
|
+
""
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def default_proxy_options
|
160
|
+
{
|
161
|
+
:host => "localhost",
|
162
|
+
:port => "0",
|
163
|
+
:user => "",
|
164
|
+
:pass => ""
|
165
|
+
}
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|