cuprite 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 117f25092d57e0e61feeec4d161d3b9da6cdde4ea6963e624dca22af48de75fa
|
4
|
+
data.tar.gz: aae39fa9139563a5870e66be1d564c69136df2e7d73c72ff744edf4bb5cccc8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f77ad45ba3abe3a1a4dec994566cbf1d0ab0c7364fbc879bf89583e1602a5a5c16da3cc1d6e1d6b8c2b5eee601409d1c8cf31f291f01cc83217f495ae313e56a
|
7
|
+
data.tar.gz: 2a976e8a5ece9441ba281b2521c43cf8ed209258bbb386254539341157dad7245933292458c7ccb7a1f019119b2334d15f3c68fb0d9af9df0061f74879d62cfb
|
data/README.md
CHANGED
@@ -13,25 +13,6 @@ have consistent design with other browsers. The design of the driver will be as
|
|
13
13
|
close to [Poltergeist](https://github.com/teampoltergeist/poltergeist) as
|
14
14
|
possible but it's not a goal.
|
15
15
|
|
16
|
-
## Speed comparison and missing features ##
|
17
|
-
|
18
|
-
Almost all capybara tests are passing with quite good speed in comparison with
|
19
|
-
Poltergest/PhantomJS:
|
20
|
-
|
21
|
-
```
|
22
|
-
cuprite:
|
23
|
-
Finished in 8 minutes 58 seconds (files took 0.89959 seconds to load)
|
24
|
-
1555 examples, 0 failures, 27 pending
|
25
|
-
|
26
|
-
selenium headless chrome:
|
27
|
-
Finished in 9 minutes 13 seconds (files took 0.97749 seconds to load)
|
28
|
-
1445 examples, 0 failures, 3 pending
|
29
|
-
|
30
|
-
poltergeist:
|
31
|
-
Finished in 11 minutes 49 seconds (files took 0.54019 seconds to load)
|
32
|
-
1560 examples, 0 failures, 6 pending
|
33
|
-
```
|
34
|
-
|
35
16
|
## Installation ##
|
36
17
|
|
37
18
|
``` ruby
|
@@ -47,10 +28,6 @@ require "capybara/cuprite"
|
|
47
28
|
Capybara.javascript_driver = :cuprite
|
48
29
|
```
|
49
30
|
|
50
|
-
If you were previously using the `:rack_test` driver, be aware that
|
51
|
-
your app will now run in a separate thread and this can have
|
52
|
-
consequences for transactional tests. [See the Capybara README for more detail](https://github.com/jnicklas/capybara/blob/master/README.md#transactions-and-database-setup).
|
53
|
-
|
54
31
|
## Installing Chromium ##
|
55
32
|
|
56
33
|
As Chromium is stopped being built as a package for Linux don't even try to
|
@@ -155,6 +132,7 @@ end
|
|
155
132
|
* `:host` (String) - Remote debugging address for headless Chrome
|
156
133
|
* `:url_blacklist` (Array) - array of strings to match against requested URLs
|
157
134
|
* `:url_whitelist` (Array) - array of strings to match against requested URLs
|
135
|
+
* `:process_timeout` (Integer) - How long to wait for the Chrome process to respond on startup
|
158
136
|
|
159
137
|
|
160
138
|
### URL Blacklisting & Whitelisting ###
|
@@ -154,7 +154,7 @@ module Capybara::Cuprite
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def find_modal(options)
|
157
|
-
start_time =
|
157
|
+
start_time = Capybara::Helpers.monotonic_time
|
158
158
|
timeout_sec = options.fetch(:wait) { session_wait_time }
|
159
159
|
expect_text = options[:text]
|
160
160
|
expect_regexp = expect_text.is_a?(Regexp) ? expect_text : Regexp.escape(expect_text.to_s)
|
@@ -165,7 +165,7 @@ module Capybara::Cuprite
|
|
165
165
|
modal_text = @modal_messages.shift
|
166
166
|
raise Capybara::ModalNotFound if modal_text.nil? || (expect_text && !modal_text.match(expect_regexp))
|
167
167
|
rescue Capybara::ModalNotFound => e
|
168
|
-
raise e, not_found_msg if (
|
168
|
+
raise e, not_found_msg if (Capybara::Helpers.monotonic_time - start_time) >= timeout_sec
|
169
169
|
sleep(0.05)
|
170
170
|
retry
|
171
171
|
end
|
@@ -184,9 +184,9 @@ module Capybara::Cuprite
|
|
184
184
|
|
185
185
|
@mutex.synchronize do
|
186
186
|
id = @client.command(*args)
|
187
|
-
stop_at =
|
187
|
+
stop_at = Capybara::Helpers.monotonic_time + @wait
|
188
188
|
|
189
|
-
while @wait > 0 && (remain = stop_at -
|
189
|
+
while @wait > 0 && (remain = stop_at - Capybara::Helpers.monotonic_time) > 0
|
190
190
|
@resource.wait(@mutex, remain)
|
191
191
|
end
|
192
192
|
|
@@ -279,6 +279,19 @@ module Capybara::Cuprite
|
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
|
+
@client.subscribe("Network.loadingFinished") do |params|
|
283
|
+
if request = @network_traffic.find { |r| r.id == params["requestId"] }
|
284
|
+
# Sometimes we never get the Network.responseReceived event.
|
285
|
+
# See https://crbug.com/883475
|
286
|
+
#
|
287
|
+
# Network.loadingFinished's encodedDataLength contains both body and headers
|
288
|
+
# sizes received by wire. See https://crbug.com/764946
|
289
|
+
if response = request.response
|
290
|
+
response.body_size = params["encodedDataLength"] - response.headers_size
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
282
295
|
@client.subscribe("Log.entryAdded") do |params|
|
283
296
|
source = params.dig("entry", "source")
|
284
297
|
level = params.dig("entry", "level")
|
@@ -6,6 +6,7 @@ module Capybara::Cuprite
|
|
6
6
|
class Browser
|
7
7
|
class Process
|
8
8
|
KILL_TIMEOUT = 2
|
9
|
+
PROCESS_TIMEOUT = 1
|
9
10
|
BROWSER_PATH = ENV["BROWSER_PATH"]
|
10
11
|
BROWSER_HOST = "127.0.0.1"
|
11
12
|
BROWSER_PORT = "0"
|
@@ -59,10 +60,10 @@ module Capybara::Cuprite
|
|
59
60
|
::Process.kill("KILL", pid)
|
60
61
|
else
|
61
62
|
::Process.kill("USR1", pid)
|
62
|
-
start =
|
63
|
+
start = Capybara::Helpers.monotonic_time
|
63
64
|
while ::Process.wait(pid, ::Process::WNOHANG).nil?
|
64
65
|
sleep 0.05
|
65
|
-
next unless (
|
66
|
+
next unless (Capybara::Helpers.monotonic_time - start) > KILL_TIMEOUT
|
66
67
|
::Process.kill("KILL", pid)
|
67
68
|
::Process.wait(pid)
|
68
69
|
break
|
@@ -96,6 +97,8 @@ module Capybara::Cuprite
|
|
96
97
|
@options.delete("disable-gpu")
|
97
98
|
end
|
98
99
|
|
100
|
+
@process_timeout = options.fetch(:process_timeout, PROCESS_TIMEOUT)
|
101
|
+
|
99
102
|
@options.merge!(options.fetch(:browser_options, {}))
|
100
103
|
|
101
104
|
@logger = options.fetch(:logger, nil)
|
@@ -115,7 +118,7 @@ module Capybara::Cuprite
|
|
115
118
|
ObjectSpace.define_finalizer(self, self.class.process_killer(@pid))
|
116
119
|
end
|
117
120
|
|
118
|
-
parse_ws_url(read_io)
|
121
|
+
parse_ws_url(read_io, @process_timeout)
|
119
122
|
ensure
|
120
123
|
close_io(read_io, write_io)
|
121
124
|
end
|
@@ -143,7 +146,7 @@ module Capybara::Cuprite
|
|
143
146
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
144
147
|
].find { |path| File.exist?(path) }
|
145
148
|
else
|
146
|
-
%w[chromium google-chrome-unstable google-chrome-beta google-chrome chrome chromium-browser].reduce(nil) do |path, exe|
|
149
|
+
%w[chromium google-chrome-unstable google-chrome-beta google-chrome chrome chromium-browser google-chrome-stable].reduce(nil) do |path, exe|
|
147
150
|
path = Cliver.detect(exe)
|
148
151
|
break path if path
|
149
152
|
end
|
@@ -180,7 +183,7 @@ module Capybara::Cuprite
|
|
180
183
|
@pid = nil
|
181
184
|
end
|
182
185
|
|
183
|
-
def parse_ws_url(read_io, timeout =
|
186
|
+
def parse_ws_url(read_io, timeout = PROCESS_TIMEOUT)
|
184
187
|
output = ""
|
185
188
|
start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
186
189
|
max_time = start + timeout
|
@@ -190,9 +190,10 @@ module Capybara::Cuprite
|
|
190
190
|
browser.clear_network_traffic
|
191
191
|
end
|
192
192
|
|
193
|
-
def set_proxy(ip, port, type =
|
193
|
+
def set_proxy(ip, port, type = nil, user = nil, password = nil, bypass = nil)
|
194
194
|
@options[:browser_options] ||= {}
|
195
|
-
|
195
|
+
server = type ? "#{type}=#{ip}:#{port}" : "#{ip}:#{port}"
|
196
|
+
@options[:browser_options].merge!("proxy-server" => server)
|
196
197
|
@options[:browser_options].merge!("proxy-bypass-list" => bypass) if bypass
|
197
198
|
browser.proxy_authorize(user, password)
|
198
199
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Capybara::Cuprite::Network
|
4
4
|
class Response
|
5
|
+
attr_accessor :body_size
|
6
|
+
|
5
7
|
def initialize(data)
|
6
8
|
@data = data
|
7
9
|
end
|
@@ -26,15 +28,15 @@ module Capybara::Cuprite::Network
|
|
26
28
|
@data["headers"]
|
27
29
|
end
|
28
30
|
|
31
|
+
def headers_size
|
32
|
+
@data["encodedDataLength"]
|
33
|
+
end
|
34
|
+
|
29
35
|
# FIXME: didn't check if we have it on redirect response
|
30
36
|
def redirect_url
|
31
37
|
@data["redirectURL"]
|
32
38
|
end
|
33
39
|
|
34
|
-
def body_size
|
35
|
-
@body_size ||= @data.dig("headers", "Content-Length").to_i
|
36
|
-
end
|
37
|
-
|
38
40
|
def content_type
|
39
41
|
@content_type ||= @data.dig("headers", "contentType").sub(/;.*\z/, "")
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuprite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Vorotilin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|