… | |
… | |
72 | sub req_ { |
72 | sub req_ { |
73 | my ($self, $method, $ep, $body, $cb) = @_; |
73 | my ($self, $method, $ep, $body, $cb) = @_; |
74 | |
74 | |
75 | AnyEvent::HTTP::http_request $method => "$self->{_ep}$ep", |
75 | AnyEvent::HTTP::http_request $method => "$self->{_ep}$ep", |
76 | body => $body, |
76 | body => $body, |
|
|
77 | $self->{persistent} ? (persistent => 1) : (), |
|
|
78 | $self->{proxy} eq "default" ? () : (proxy => $self->{proxy}), |
77 | timeout => $self->{timeout}, |
79 | timeout => $self->{timeout}, |
78 | headers => { "content-type" => "application/json; charset=utf-8", "cache-control" => "no-cache" }, |
80 | headers => { "content-type" => "application/json; charset=utf-8", "cache-control" => "no-cache" }, |
79 | ($self->{proxy} eq "default" ? () : (proxy => $self->{proxy})), |
|
|
80 | sub { |
81 | sub { |
81 | my ($res, $hdr) = @_; |
82 | my ($res, $hdr) = @_; |
82 | |
83 | |
83 | $res = eval { $json->decode ($res) }; |
84 | $res = eval { $json->decode ($res) }; |
84 | $hdr->{Status} = 500 unless exists $res->{value}; |
85 | $hdr->{Status} = 500 unless exists $res->{value}; |
… | |
… | |
181 | The HTTP timeout, in (fractional) seconds (default: C<300>, but this will |
182 | The HTTP timeout, in (fractional) seconds (default: C<300>, but this will |
182 | likely drastically reduce). This timeout is reset on any activity, so it |
183 | likely drastically reduce). This timeout is reset on any activity, so it |
183 | is not an overall request timeout. Also, individual requests might extend |
184 | is not an overall request timeout. Also, individual requests might extend |
184 | this timeout if they are known to take longer. |
185 | this timeout if they are known to take longer. |
185 | |
186 | |
|
|
187 | =item persistent => C<1> | C<undef> |
|
|
188 | |
|
|
189 | If true (the default) then persistent connections will be used for all |
|
|
190 | requests, which assumes you have a reasonably stable connection (such as |
|
|
191 | to C<localhost> :) and that the WebDriver has a persistent timeout much |
|
|
192 | higher than what L<AnyEvent::HTTP> uses. |
|
|
193 | |
|
|
194 | You can force connections to be closed for non-idempotent requests by |
|
|
195 | setting this to C<undef>. |
|
|
196 | |
186 | =back |
197 | =back |
187 | |
198 | |
188 | =cut |
199 | =cut |
189 | |
200 | |
190 | sub new { |
201 | sub new { |
191 | my ($class, %kv) = @_; |
202 | my ($class, %kv) = @_; |
192 | |
203 | |
193 | bless { |
204 | bless { |
194 | endpoint => "http://localhost:4444", |
205 | endpoint => "http://localhost:4444", |
195 | proxy => undef, |
206 | proxy => undef, |
|
|
207 | persistent => 1, |
196 | autodelete => 1, |
208 | autodelete => 1, |
197 | timeout => 300, |
209 | timeout => 300, |
198 | %kv, |
210 | %kv, |
199 | }, $class |
211 | }, $class |
200 | } |
212 | } |
… | |
… | |
326 | "moz:firefoxOptions" => { |
338 | "moz:firefoxOptions" => { |
327 | binary => "firefox/firefox", |
339 | binary => "firefox/firefox", |
328 | args => ["-devtools"], |
340 | args => ["-devtools"], |
329 | prefs => { |
341 | prefs => { |
330 | "dom.webnotifications.enabled" => \0, |
342 | "dom.webnotifications.enabled" => \0, |
|
|
343 | "dom.push.enabled" => \0, |
331 | "dom.disable_beforeunload" => \1, |
344 | "dom.disable_beforeunload" => \1, |
332 | "browser.link.open_newwindow" => 3, |
345 | "browser.link.open_newwindow" => 3, |
333 | "browser.link.open_newwindow.restrictions" => 0, |
346 | "browser.link.open_newwindow.restrictions" => 0, |
334 | "dom.popup_allowed_events" => "", |
347 | "dom.popup_allowed_events" => "", |
335 | "dom.disable_open_during_load" => \1, |
348 | "dom.disable_open_during_load" => \1, |