capybara-webkit 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/Appraisals +0 -8
- data/Gemfile.lock +5 -5
- data/NEWS.md +7 -0
- data/capybara-webkit.gemspec +1 -1
- data/extconf.rb +18 -0
- data/gemfiles/2.3.gemfile.lock +2 -2
- data/gemfiles/2.4.gemfile.lock +2 -2
- data/lib/capybara/webkit/browser.rb +14 -0
- data/lib/capybara/webkit/driver.rb +12 -0
- data/lib/capybara/webkit/version.rb +1 -1
- data/lib/capybara_webkit_builder.rb +18 -2
- data/spec/driver_spec.rb +99 -28
- data/spec/support/app_runner.rb +4 -4
- data/spec/support/output_writer.rb +15 -0
- data/src/AllowUrl.cpp +16 -0
- data/src/AllowUrl.h +10 -0
- data/src/BlacklistedRequestHandler.cpp +56 -0
- data/src/BlacklistedRequestHandler.h +22 -0
- data/src/BlockUrl.cpp +16 -0
- data/src/BlockUrl.h +10 -0
- data/src/CommandFactory.cpp +3 -0
- data/src/CustomHeadersRequestHandler.cpp +37 -0
- data/src/CustomHeadersRequestHandler.h +21 -0
- data/src/Header.cpp +1 -2
- data/src/MissingContentHeaderRequestHandler.cpp +23 -0
- data/src/MissingContentHeaderRequestHandler.h +15 -0
- data/src/NetworkAccessManager.cpp +35 -53
- data/src/NetworkAccessManager.h +14 -9
- data/src/NetworkRequestFactory.cpp +15 -0
- data/src/NetworkRequestFactory.h +12 -0
- data/src/NoOpReply.cpp +1 -1
- data/src/NoOpReply.h +1 -1
- data/src/RequestHandler.cpp +4 -0
- data/src/RequestHandler.h +25 -0
- data/src/SetUnknownUrlMode.cpp +27 -0
- data/src/SetUnknownUrlMode.h +10 -0
- data/src/SetUrlBlacklist.cpp +1 -2
- data/src/SetUrlBlacklist.h +0 -2
- data/src/UnknownUrlHandler.cpp +70 -0
- data/src/UnknownUrlHandler.h +28 -0
- data/src/WebPageManager.cpp +41 -1
- data/src/WebPageManager.h +12 -1
- data/src/capybara.js +2 -1
- data/src/find_command.h +3 -0
- data/src/webkit_server.pro +20 -2
- metadata +23 -10
- data/gemfiles/2.0.gemfile +0 -7
- data/gemfiles/2.0.gemfile.lock +0 -76
- data/gemfiles/2.1.gemfile +0 -7
- data/gemfiles/2.1.gemfile.lock +0 -83
- data/gemfiles/2.2.gemfile +0 -7
- data/gemfiles/2.2.gemfile.lock +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b148922bff655cfceedb08dcae431c0bed0cad26
|
4
|
+
data.tar.gz: b3dc9996d98dd05e943092e4bd20be8303c4cc64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b706abb8a485e9903dae782e60197643a7cdba29a96eed8fcc16550973f1144a176cf2a285e5cd9a81f6c4134bafad2a6a868f6e13af0f7adcdf3d1a36875652
|
7
|
+
data.tar.gz: 960b0b5dbe21488c2ee3163c9fe88715dca6e0a540b16e82d660762f1d7b4b9ba18413213a2bddad956e0b0e87cf948c10660ad339dab5d442875d310d0f10c8
|
data/.travis.yml
CHANGED
@@ -12,9 +12,6 @@ env:
|
|
12
12
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
13
13
|
matrix:
|
14
14
|
include:
|
15
|
-
- rvm: 1.9.3
|
16
|
-
gemfile: gemfiles/2.2.gemfile
|
17
|
-
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
|
18
15
|
- rvm: 1.9.3
|
19
16
|
gemfile: gemfiles/2.3.gemfile
|
20
17
|
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
|
@@ -22,7 +19,6 @@ matrix:
|
|
22
19
|
gemfile: gemfiles/2.4.gemfile
|
23
20
|
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
|
24
21
|
gemfile:
|
25
|
-
- gemfiles/2.2.gemfile
|
26
22
|
- gemfiles/2.3.gemfile
|
27
23
|
- gemfiles/2.4.gemfile
|
28
24
|
before_install:
|
data/Appraisals
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capybara-webkit (1.
|
5
|
-
capybara (>= 2.0
|
4
|
+
capybara-webkit (1.4.0)
|
5
|
+
capybara (>= 2.3.0, < 2.5.0)
|
6
6
|
json
|
7
7
|
|
8
8
|
GEM
|
@@ -33,10 +33,10 @@ GEM
|
|
33
33
|
mime-types (2.4.3)
|
34
34
|
mini_magick (3.2.1)
|
35
35
|
subexec (~> 0.0.4)
|
36
|
-
mini_portile (0.6.
|
36
|
+
mini_portile (0.6.1)
|
37
37
|
multi_json (1.8.4)
|
38
|
-
nokogiri (1.6.
|
39
|
-
mini_portile (
|
38
|
+
nokogiri (1.6.4)
|
39
|
+
mini_portile (~> 0.6.0)
|
40
40
|
rack (1.5.2)
|
41
41
|
rack-protection (1.3.2)
|
42
42
|
rack
|
data/NEWS.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
New for 1.4.0:
|
2
|
+
|
3
|
+
* Fix returning invisible text on a hidden page
|
4
|
+
* Expose INCLUDEPATH and LIBS qmake variables
|
5
|
+
* Drop support for older Capybara versions
|
6
|
+
* Introduce allowed, blocked URL filters
|
7
|
+
|
1
8
|
New for 1.3.1:
|
2
9
|
|
3
10
|
* Inherit from Capybara::Driver::Base for Capybara 2.4.4 compatibility.
|
data/capybara-webkit.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.required_ruby_version = ">= 1.9.0"
|
21
21
|
|
22
|
-
s.add_runtime_dependency("capybara", ">= 2.0
|
22
|
+
s.add_runtime_dependency("capybara", ">= 2.3.0", "< 2.5.0")
|
23
23
|
s.add_runtime_dependency("json")
|
24
24
|
|
25
25
|
s.add_development_dependency("rspec", "~> 2.14.0")
|
data/extconf.rb
CHANGED
@@ -1,2 +1,20 @@
|
|
1
|
+
require "mkmf"
|
2
|
+
|
3
|
+
$CPPFLAGS = ""
|
4
|
+
|
5
|
+
dir_config("gl")
|
6
|
+
dir_config("zlib")
|
7
|
+
|
8
|
+
include_path = $CPPFLAGS.gsub("-I", "").strip
|
9
|
+
libs = $LIBPATH.map { |path| "-L#{path}"}.join(" ").strip
|
10
|
+
|
11
|
+
unless include_path.empty?
|
12
|
+
ENV["CAPYBARA_WEBKIT_INCLUDE_PATH"] = include_path
|
13
|
+
end
|
14
|
+
|
15
|
+
unless libs.empty?
|
16
|
+
ENV["CAPYBARA_WEBKIT_LIBS"] = libs
|
17
|
+
end
|
18
|
+
|
1
19
|
require File.join(File.expand_path(File.dirname(__FILE__)), "lib", "capybara_webkit_builder")
|
2
20
|
CapybaraWebkitBuilder.build_all
|
data/gemfiles/2.3.gemfile.lock
CHANGED
data/gemfiles/2.4.gemfile.lock
CHANGED
@@ -195,6 +195,8 @@ module Capybara::Webkit
|
|
195
195
|
end
|
196
196
|
|
197
197
|
def url_blacklist=(black_list)
|
198
|
+
warn '[DEPRECATION] Capybara::Webkit::Browser#url_blacklist= ' \
|
199
|
+
'is deprecated. Please use page.driver.block_url instead.'
|
198
200
|
command("SetUrlBlacklist", *Array(black_list))
|
199
201
|
end
|
200
202
|
|
@@ -263,6 +265,18 @@ module Capybara::Webkit
|
|
263
265
|
command("GoForward")
|
264
266
|
end
|
265
267
|
|
268
|
+
def allow_url(url)
|
269
|
+
command("AllowUrl", url)
|
270
|
+
end
|
271
|
+
|
272
|
+
def block_url(url)
|
273
|
+
command("BlockUrl", url)
|
274
|
+
end
|
275
|
+
|
276
|
+
def block_unknown_urls
|
277
|
+
command("SetUnknownUrlMode", "block")
|
278
|
+
end
|
279
|
+
|
266
280
|
private
|
267
281
|
|
268
282
|
def check
|
@@ -21,6 +21,18 @@ module Capybara::Webkit
|
|
21
21
|
browser.enable_logging
|
22
22
|
end
|
23
23
|
|
24
|
+
def allow_url(url)
|
25
|
+
browser.allow_url(url)
|
26
|
+
end
|
27
|
+
|
28
|
+
def block_url(url)
|
29
|
+
browser.block_url(url)
|
30
|
+
end
|
31
|
+
|
32
|
+
def block_unknown_urls
|
33
|
+
browser.block_unknown_urls
|
34
|
+
end
|
35
|
+
|
24
36
|
def current_url
|
25
37
|
browser.current_url
|
26
38
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require "rbconfig"
|
3
|
+
require "shellwords"
|
3
4
|
|
4
5
|
module CapybaraWebkitBuilder
|
5
6
|
extend self
|
@@ -52,8 +53,10 @@ module CapybaraWebkitBuilder
|
|
52
53
|
success
|
53
54
|
end
|
54
55
|
|
55
|
-
def makefile(
|
56
|
-
|
56
|
+
def makefile(*configs)
|
57
|
+
configs += default_configs
|
58
|
+
configs = configs.map { |config| config.shellescape}.join(" ")
|
59
|
+
sh("#{qmake_bin} -spec #{spec} #{configs}")
|
57
60
|
end
|
58
61
|
|
59
62
|
def qmake
|
@@ -82,6 +85,19 @@ module CapybaraWebkitBuilder
|
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
88
|
+
def default_configs
|
89
|
+
configs = []
|
90
|
+
libpath = ENV["CAPYBARA_WEBKIT_LIBS"]
|
91
|
+
cppflags = ENV["CAPYBARA_WEBKIT_INCLUDE_PATH"]
|
92
|
+
if libpath
|
93
|
+
configs << "LIBS += #{libpath}"
|
94
|
+
end
|
95
|
+
if cppflags
|
96
|
+
configs << "INCLUDEPATH += #{cppflags}"
|
97
|
+
end
|
98
|
+
configs
|
99
|
+
end
|
100
|
+
|
85
101
|
def build_all
|
86
102
|
makefile &&
|
87
103
|
qmake &&
|
data/spec/driver_spec.rb
CHANGED
@@ -561,6 +561,24 @@ describe Capybara::Webkit::Driver do
|
|
561
561
|
end
|
562
562
|
end
|
563
563
|
|
564
|
+
context "hidden text app" do
|
565
|
+
let(:driver) do
|
566
|
+
driver_for_html(<<-HTML)
|
567
|
+
<html>
|
568
|
+
<body>
|
569
|
+
<h1 style="display: none">Hello</h1>
|
570
|
+
</body>
|
571
|
+
</html>
|
572
|
+
HTML
|
573
|
+
end
|
574
|
+
|
575
|
+
before { visit("/") }
|
576
|
+
|
577
|
+
it "has no visible text" do
|
578
|
+
driver.find_xpath("/html").first.text.should be_empty
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
564
582
|
context "console messages app" do
|
565
583
|
let(:driver) do
|
566
584
|
driver_for_html(<<-HTML)
|
@@ -2568,10 +2586,10 @@ CACHE MANIFEST
|
|
2568
2586
|
end
|
2569
2587
|
|
2570
2588
|
before do
|
2571
|
-
driver.
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2589
|
+
driver.block_url "http://example.org/path/to/file"
|
2590
|
+
driver.block_url "http://example.*/foo/*"
|
2591
|
+
driver.block_url "http://example.com"
|
2592
|
+
driver.block_url "#{AppRunner.app_host}/script"
|
2575
2593
|
end
|
2576
2594
|
|
2577
2595
|
it "should not fetch urls blocked by host" do
|
@@ -2615,6 +2633,69 @@ CACHE MANIFEST
|
|
2615
2633
|
end
|
2616
2634
|
end
|
2617
2635
|
|
2636
|
+
describe "url whitelisting" do
|
2637
|
+
it_behaves_like "output writer" do
|
2638
|
+
let(:driver) do
|
2639
|
+
driver_for_html(<<-HTML, browser)
|
2640
|
+
<<-HTML
|
2641
|
+
<html>
|
2642
|
+
<body>
|
2643
|
+
<iframe src="http://example.com/path" id="frame"></iframe>
|
2644
|
+
<iframe src="http://www.example.com" id="frame2"></iframe>
|
2645
|
+
</body>
|
2646
|
+
</html>
|
2647
|
+
HTML
|
2648
|
+
end
|
2649
|
+
|
2650
|
+
it "prints a warning for remote requests by default" do
|
2651
|
+
visit("/")
|
2652
|
+
|
2653
|
+
expect(stderr).to include("http://example.com/path")
|
2654
|
+
expect(stderr).not_to include(driver.current_url)
|
2655
|
+
end
|
2656
|
+
|
2657
|
+
it "can allow specific hosts" do
|
2658
|
+
driver.allow_url("example.com")
|
2659
|
+
driver.allow_url("www.example.com")
|
2660
|
+
visit("/")
|
2661
|
+
|
2662
|
+
expect(stderr).not_to include("http://example.com/path")
|
2663
|
+
expect(stderr).not_to include(driver.current_url)
|
2664
|
+
driver.within_frame("frame") do
|
2665
|
+
expect(driver.find("//body").first.text).not_to be_empty
|
2666
|
+
end
|
2667
|
+
end
|
2668
|
+
|
2669
|
+
it "can block unknown hosts" do
|
2670
|
+
driver.block_unknown_urls
|
2671
|
+
visit("/")
|
2672
|
+
|
2673
|
+
expect(stderr).not_to include("http://example.com/path")
|
2674
|
+
expect(stderr).not_to include(driver.current_url)
|
2675
|
+
driver.within_frame("frame") do
|
2676
|
+
expect(driver.find("//body").first.text).to be_empty
|
2677
|
+
end
|
2678
|
+
end
|
2679
|
+
|
2680
|
+
it "can allow urls with wildcards" do
|
2681
|
+
driver.allow_url("*/path")
|
2682
|
+
visit("/")
|
2683
|
+
|
2684
|
+
expect(stderr).to include("www.example.com")
|
2685
|
+
expect(stderr).not_to include("example.com/path")
|
2686
|
+
expect(stderr).not_to include(driver.current_url)
|
2687
|
+
end
|
2688
|
+
|
2689
|
+
it "whitelists localhost on reset" do
|
2690
|
+
driver.reset!
|
2691
|
+
|
2692
|
+
visit("/")
|
2693
|
+
|
2694
|
+
expect(stderr).not_to include(driver.current_url)
|
2695
|
+
end
|
2696
|
+
end
|
2697
|
+
end
|
2698
|
+
|
2618
2699
|
describe "timeout for long requests" do
|
2619
2700
|
let(:driver) do
|
2620
2701
|
driver_for_app do
|
@@ -2688,33 +2769,23 @@ CACHE MANIFEST
|
|
2688
2769
|
end
|
2689
2770
|
|
2690
2771
|
describe "logger app" do
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
end
|
2696
|
-
|
2697
|
-
it "logs its commands after turning on the logger" do
|
2698
|
-
driver.enable_logging
|
2699
|
-
visit("/")
|
2700
|
-
@write.close
|
2701
|
-
log.should include logging_message
|
2702
|
-
end
|
2703
|
-
|
2704
|
-
before do
|
2705
|
-
@read, @write = IO.pipe
|
2706
|
-
end
|
2772
|
+
it_behaves_like "output writer" do
|
2773
|
+
let(:driver) do
|
2774
|
+
driver_for_html("<html><body>Hello</body></html>", browser)
|
2775
|
+
end
|
2707
2776
|
|
2708
|
-
|
2777
|
+
it "logs nothing before turning on the logger" do
|
2778
|
+
visit("/")
|
2779
|
+
stderr.should_not include logging_message
|
2780
|
+
end
|
2709
2781
|
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
|
2782
|
+
it "logs its commands after turning on the logger" do
|
2783
|
+
driver.enable_logging
|
2784
|
+
visit("/")
|
2785
|
+
stderr.should include logging_message
|
2786
|
+
end
|
2715
2787
|
|
2716
|
-
|
2717
|
-
@read.read
|
2788
|
+
let(:logging_message) { 'Wrote response true' }
|
2718
2789
|
end
|
2719
2790
|
end
|
2720
2791
|
|
data/spec/support/app_runner.rb
CHANGED
@@ -31,9 +31,9 @@ module AppRunner
|
|
31
31
|
build_driver
|
32
32
|
end
|
33
33
|
|
34
|
-
def driver_for_html(html)
|
34
|
+
def driver_for_html(html, *driver_args)
|
35
35
|
run_application_for_html html
|
36
|
-
build_driver
|
36
|
+
build_driver(*driver_args)
|
37
37
|
end
|
38
38
|
|
39
39
|
def session_for_app(&body)
|
@@ -50,8 +50,8 @@ module AppRunner
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
def build_driver
|
54
|
-
Capybara::Webkit::Driver.new(AppRunner.app, :browser =>
|
53
|
+
def build_driver(browser = $webkit_browser)
|
54
|
+
Capybara::Webkit::Driver.new(AppRunner.app, :browser => browser)
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.included(example_group)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
shared_examples_for "output writer" do
|
2
|
+
before do
|
3
|
+
@read, @write = IO.pipe
|
4
|
+
end
|
5
|
+
|
6
|
+
let(:browser) do
|
7
|
+
connection = Capybara::Webkit::Connection.new(:stderr => @write)
|
8
|
+
Capybara::Webkit::Browser.new(connection)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:stderr) do
|
12
|
+
@write.close
|
13
|
+
@read.read
|
14
|
+
end
|
15
|
+
end
|
data/src/AllowUrl.cpp
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#include "AllowUrl.h"
|
2
|
+
#include "SocketCommand.h"
|
3
|
+
#include "WebPage.h"
|
4
|
+
#include "WebPageManager.h"
|
5
|
+
|
6
|
+
AllowUrl::AllowUrl(
|
7
|
+
WebPageManager *manager,
|
8
|
+
QStringList &arguments,
|
9
|
+
QObject *parent
|
10
|
+
) : SocketCommand(manager, arguments, parent) {
|
11
|
+
}
|
12
|
+
|
13
|
+
void AllowUrl::start() {
|
14
|
+
manager()->allowUrl(arguments()[0]);
|
15
|
+
finish(true);
|
16
|
+
}
|