capybara-webkit 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,11 +35,24 @@ module Capybara::Webkit
35
35
  end
36
36
 
37
37
  def gets
38
- @socket.gets
38
+ response = ""
39
+ until response.match(/\n/) do
40
+ response += read(1)
41
+ end
42
+ response
39
43
  end
40
44
 
41
45
  def read(length)
42
- @socket.read(length)
46
+ response = ""
47
+ begin
48
+ while response.length < length do
49
+ response += @socket.read_nonblock(length - response.length)
50
+ end
51
+ rescue IO::WaitReadable
52
+ Thread.new { IO.select([@socket]) }.join
53
+ retry
54
+ end
55
+ response
43
56
  end
44
57
 
45
58
  private
@@ -55,9 +68,19 @@ module Capybara::Webkit
55
68
  @pipe_stdin, @pipe_stdout, @pipe_stderr, @wait_thr = Open3.popen3(SERVER_PATH)
56
69
  end
57
70
 
71
+ def parse_port(line)
72
+ if match = line.to_s.match(/listening on port: (\d+)/)
73
+ match[1].to_i
74
+ else
75
+ raise ConnectionError, "#{SERVER_PATH} failed to start."
76
+ end
77
+ end
78
+
58
79
  def discover_port
59
80
  if IO.select([@pipe_stdout], nil, nil, WEBKIT_SERVER_START_TIMEOUT)
60
- @port = ((@pipe_stdout.first || '').match(/listening on port: (\d+)/) || [])[1].to_i
81
+ @port = parse_port(@pipe_stdout.first)
82
+ else
83
+ raise ConnectionError, "#{SERVER_PATH} failed to start after #{WEBKIT_SERVER_START_TIMEOUT} seconds."
61
84
  end
62
85
  end
63
86
 
@@ -69,14 +69,22 @@ module Capybara::Webkit
69
69
  end
70
70
 
71
71
  def alert_messages
72
+ warn '[DEPRECATION] Capybara::Webkit::Driver#alert_messages ' \
73
+ 'is deprecated. Please use Capybara::Session#accept_alert instead.'
72
74
  browser.alert_messages
73
75
  end
74
76
 
75
77
  def confirm_messages
78
+ warn '[DEPRECATION] Capybara::Webkit::Driver#confirm_messages ' \
79
+ 'is deprecated. Please use Capybara::Session#accept_confirm ' \
80
+ 'or Capybara::Session#dismiss_confirm instead.'
76
81
  browser.confirm_messages
77
82
  end
78
83
 
79
84
  def prompt_messages
85
+ warn '[DEPRECATION] Capybara::Webkit::Driver#prompt_messages ' \
86
+ 'is deprecated. Please use Capybara::Session#accept_prompt ' \
87
+ 'or Capybara::Session#dismiss_prompt instead.'
80
88
  browser.prompt_messages
81
89
  end
82
90
 
@@ -89,6 +97,8 @@ module Capybara::Webkit
89
97
  end
90
98
 
91
99
  def resize_window(width, height)
100
+ warn '[DEPRECATION] Capybara::Webkit::Driver#resize_window ' \
101
+ 'is deprecated. Please use Capybara::Window#resize_to instead.'
92
102
  resize_window_to(current_window_handle, width, height)
93
103
  end
94
104
 
@@ -144,22 +154,32 @@ module Capybara::Webkit
144
154
  end
145
155
 
146
156
  def accept_js_confirms!
157
+ warn '[DEPRECATION] Capybara::Webkit::Driver#accept_js_confirms! ' \
158
+ 'is deprecated. Please use Capybara::Session#accept_confirm instead.'
147
159
  browser.accept_js_confirms
148
160
  end
149
161
 
150
162
  def dismiss_js_confirms!
163
+ warn '[DEPRECATION] Capybara::Webkit::Driver#dismiss_js_confirms! ' \
164
+ 'is deprecated. Please use Capybara::Session#dismiss_confirm instead.'
151
165
  browser.reject_js_confirms
152
166
  end
153
167
 
154
168
  def accept_js_prompts!
169
+ warn '[DEPRECATION] Capybara::Webkit::Driver#accept_js_prompts! ' \
170
+ 'is deprecated. Please use Capybara::Session#accept_prompt instead.'
155
171
  browser.accept_js_prompts
156
172
  end
157
173
 
158
174
  def dismiss_js_prompts!
175
+ warn '[DEPRECATION] Capybara::Webkit::Driver#dismiss_js_prompts! ' \
176
+ 'is deprecated. Please use Capybara::Session#dismiss_prompt instead.'
159
177
  browser.reject_js_prompts
160
178
  end
161
179
 
162
180
  def js_prompt_input=(value)
181
+ warn '[DEPRECATION] Capybara::Webkit::Driver#js_prompt_input= ' \
182
+ 'is deprecated. Please use Capybara::Session#accept_prompt instead.'
163
183
  if value.nil?
164
184
  browser.clear_prompt_text
165
185
  else
@@ -175,6 +195,38 @@ module Capybara::Webkit
175
195
  browser.go_forward
176
196
  end
177
197
 
198
+ def accept_modal(type, options={})
199
+ options = modal_action_options_for_browser(options)
200
+
201
+ case type
202
+ when :confirm
203
+ id = browser.accept_confirm(options)
204
+ when :prompt
205
+ id = browser.accept_prompt(options)
206
+ else
207
+ id = browser.accept_alert(options)
208
+ end
209
+
210
+ yield
211
+
212
+ find_modal(type, id, options)
213
+ end
214
+
215
+ def dismiss_modal(type, options={})
216
+ options = modal_action_options_for_browser(options)
217
+
218
+ case type
219
+ when :confirm
220
+ id = browser.reject_confirm(options)
221
+ else
222
+ id = browser.reject_prompt(options)
223
+ end
224
+
225
+ yield
226
+
227
+ find_modal(type, id, options)
228
+ end
229
+
178
230
  def wait?
179
231
  true
180
232
  end
@@ -217,5 +269,27 @@ module Capybara::Webkit
217
269
  browser.version
218
270
  ].join("\n")
219
271
  end
272
+
273
+ private
274
+
275
+ def modal_action_options_for_browser(options)
276
+ if options[:text].is_a?(Regexp)
277
+ options.merge(text: options[:text].source)
278
+ else
279
+ options.merge(text: Regexp.escape(options[:text].to_s))
280
+ end.merge(original_text: options[:text])
281
+ end
282
+
283
+ def find_modal(type, id, options)
284
+ Timeout::timeout(options[:wait] || Capybara.default_wait_time) do
285
+ browser.find_modal(id)
286
+ end
287
+ rescue ModalNotFound
288
+ raise Capybara::ModalNotFound,
289
+ "Unable to find modal dialog#{" with #{options[:original_text]}" if options[:original_text]}"
290
+ rescue Timeout::Error
291
+ raise Capybara::ModalNotFound,
292
+ "Timed out waiting for modal dialog#{" with #{options[:original_text]}" if options[:original_text]}"
293
+ end
220
294
  end
221
295
  end
@@ -17,6 +17,12 @@ module Capybara::Webkit
17
17
  class NoSuchWindowError < StandardError
18
18
  end
19
19
 
20
+ class ConnectionError < StandardError
21
+ end
22
+
23
+ class ModalNotFound < StandardError
24
+ end
25
+
20
26
  class JsonError
21
27
  def initialize(response)
22
28
  error = JSON.parse response
@@ -1,7 +1,7 @@
1
1
  module Capybara
2
2
  module Driver
3
3
  class Webkit
4
- VERSION = '1.2.0'.freeze
4
+ VERSION = '1.3.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -23,6 +23,33 @@ describe Capybara::Webkit::Connection do
23
23
  expect { Process.getpgid(webkit_pid) }.to raise_error Errno::ESRCH
24
24
  end
25
25
 
26
+ it "raises an error if the server has stopped", skip_on_windows: true do
27
+ path = 'false'
28
+ stub_const("Capybara::Webkit::Connection::SERVER_PATH", path)
29
+
30
+ expect { Capybara::Webkit::Connection.new }.
31
+ to raise_error(
32
+ Capybara::Webkit::ConnectionError,
33
+ "#{path} failed to start.")
34
+ end
35
+
36
+ it "raises an error if the server is not ready", skip_on_windows: true do
37
+ server_path = 'sleep 1'
38
+ stub_const("Capybara::Webkit::Connection::SERVER_PATH", server_path)
39
+ start_timeout = 0.5
40
+ stub_const("Capybara::Webkit::Connection::WEBKIT_SERVER_START_TIMEOUT", start_timeout)
41
+
42
+ error_string =
43
+ if defined?(::JRUBY_VERSION)
44
+ "#{server_path} failed to start."
45
+ else
46
+ "#{server_path} failed to start after #{start_timeout} seconds."
47
+ end
48
+
49
+ expect { Capybara::Webkit::Connection.new }.
50
+ to raise_error(Capybara::Webkit::ConnectionError, error_string)
51
+ end
52
+
26
53
  it "boots a server to talk to" do
27
54
  url = "http://#{@rack_server.host}:#{@rack_server.port}/"
28
55
  connection.puts "Visit"
@@ -618,28 +618,101 @@ describe Capybara::Webkit::Driver do
618
618
  end
619
619
 
620
620
  context "javascript dialog interaction" do
621
+ before do
622
+ stub_const('Capybara::ModalNotFound', Class.new(StandardError))
623
+ end
624
+
621
625
  context "on an alert app" do
622
626
  let(:driver) do
623
- driver_for_html(<<-HTML)
624
- <html>
625
- <head>
626
- </head>
627
- <body>
628
- <script type="text/javascript">
629
- alert("Alert Text\\nGoes Here");
630
- </script>
631
- </body>
632
- </html>
633
- HTML
627
+ driver_for_app do
628
+ get '/' do
629
+ <<-HTML
630
+ <html>
631
+ <head>
632
+ </head>
633
+ <body>
634
+ <script type="text/javascript">
635
+ alert("Alert Text\\nGoes Here");
636
+ </script>
637
+ </body>
638
+ </html>
639
+ HTML
640
+ end
641
+
642
+ get '/async' do
643
+ <<-HTML
644
+ <html>
645
+ <head>
646
+ </head>
647
+ <body>
648
+ <script type="text/javascript">
649
+ function testAlert() {
650
+ setTimeout(function() { alert("Alert Text\\nGoes Here"); },
651
+ #{params[:sleep] || 100});
652
+ }
653
+ </script>
654
+ <input type="button" onclick="testAlert()" name="test"/>
655
+ </body>
656
+ </html>
657
+ HTML
658
+ end
659
+ end
634
660
  end
635
661
 
636
- before { visit("/") }
662
+ it 'accepts any alert modal if no match is provided' do
663
+ alert_message = driver.accept_modal(:alert) do
664
+ visit("/")
665
+ end
666
+ alert_message.should eq "Alert Text\nGoes Here"
667
+ end
668
+
669
+ it 'accepts an alert modal if it matches' do
670
+ alert_message = driver.accept_modal(:alert, text: "Alert Text\nGoes Here") do
671
+ visit("/")
672
+ end
673
+ alert_message.should eq "Alert Text\nGoes Here"
674
+ end
675
+
676
+ it 'raises an error when accepting an alert modal that does not match' do
677
+ expect {
678
+ driver.accept_modal(:alert, text: 'No?') do
679
+ visit('/')
680
+ end
681
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog with No?"
682
+ end
683
+
684
+ it 'waits to accept an async alert modal' do
685
+ visit("/async")
686
+ alert_message = driver.accept_modal(:alert) do
687
+ driver.find_xpath("//input").first.click
688
+ end
689
+ alert_message.should eq "Alert Text\nGoes Here"
690
+ end
691
+
692
+ it 'times out waiting for an async alert modal' do
693
+ visit("/async?sleep=1000")
694
+ expect {
695
+ driver.accept_modal(:alert, wait: 0.1) do
696
+ driver.find_xpath("//input").first.click
697
+ end
698
+ }.to raise_error Capybara::ModalNotFound, "Timed out waiting for modal dialog"
699
+ end
700
+
701
+ it 'raises an error when an unexpected modal is displayed' do
702
+ expect {
703
+ driver.accept_modal(:confirm) do
704
+ visit("/")
705
+ end
706
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog"
707
+ end
637
708
 
638
709
  it "should let me read my alert messages" do
710
+ visit("/")
639
711
  driver.alert_messages.first.should eq "Alert Text\nGoes Here"
640
712
  end
641
713
 
642
714
  it "empties the array when reset" do
715
+ visit("/")
643
716
  driver.reset!
644
717
  driver.alert_messages.should be_empty
645
718
  end
@@ -659,8 +732,25 @@ describe Capybara::Webkit::Driver do
659
732
  else
660
733
  console.log("goodbye");
661
734
  }
735
+ function test_complex_dialog() {
736
+ if(confirm("Yes?"))
737
+ if(confirm("Really?"))
738
+ console.log("hello");
739
+ else
740
+ console.log("goodbye");
741
+ }
742
+ function test_async_dialog() {
743
+ setTimeout(function() {
744
+ if(confirm("Yes?"))
745
+ console.log("hello");
746
+ else
747
+ console.log("goodbye");
748
+ }, 100);
749
+ }
662
750
  </script>
663
751
  <input type="button" onclick="test_dialog()" name="test"/>
752
+ <input type="button" onclick="test_complex_dialog()" name="test_complex"/>
753
+ <input type="button" onclick="test_async_dialog()" name="test_async"/>
664
754
  </body>
665
755
  </html>
666
756
  HTML
@@ -668,6 +758,81 @@ describe Capybara::Webkit::Driver do
668
758
 
669
759
  before { visit("/") }
670
760
 
761
+ it 'accepts any confirm modal if no match is provided' do
762
+ driver.accept_modal(:confirm) do
763
+ driver.find_xpath("//input").first.click
764
+ end
765
+ driver.console_messages.first[:message].should eq "hello"
766
+ end
767
+
768
+ it 'dismisses a confirm modal that does not match' do
769
+ begin
770
+ driver.accept_modal(:confirm, text: 'No?') do
771
+ driver.find_xpath("//input").first.click
772
+ driver.console_messages.first[:message].should eq "goodbye"
773
+ end
774
+ rescue Capybara::ModalNotFound
775
+ end
776
+ end
777
+
778
+ it 'raises an error when accepting a confirm modal that does not match' do
779
+ expect {
780
+ driver.accept_modal(:confirm, text: 'No?') do
781
+ driver.find_xpath("//input").first.click
782
+ end
783
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog with No?"
784
+ end
785
+
786
+ it 'dismisses any confirm modal if no match is provided' do
787
+ driver.dismiss_modal(:confirm) do
788
+ driver.find_xpath("//input").first.click
789
+ end
790
+ driver.console_messages.first[:message].should eq "goodbye"
791
+ end
792
+
793
+ it 'raises an error when dismissing a confirm modal that does not match' do
794
+ expect {
795
+ driver.dismiss_modal(:confirm, text: 'No?') do
796
+ driver.find_xpath("//input").first.click
797
+ end
798
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog with No?"
799
+ end
800
+
801
+ it 'waits to accept an async confirm modal' do
802
+ visit("/async")
803
+ confirm_message = driver.accept_modal(:confirm) do
804
+ driver.find_css("input[name=test_async]").first.click
805
+ end
806
+ confirm_message.should eq "Yes?"
807
+ end
808
+
809
+ it 'allows the nesting of dismiss and accept' do
810
+ driver.dismiss_modal(:confirm) do
811
+ driver.accept_modal(:confirm) do
812
+ driver.find_css("input[name=test_complex]").first.click
813
+ end
814
+ end
815
+ driver.console_messages.first[:message].should eq "goodbye"
816
+ end
817
+
818
+ it 'raises an error when an unexpected modal is displayed' do
819
+ expect {
820
+ driver.accept_modal(:prompt) do
821
+ driver.find_xpath("//input").first.click
822
+ end
823
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog"
824
+ end
825
+
826
+ it 'dismisses a confirm modal when prompt is expected' do
827
+ begin
828
+ driver.accept_modal(:prompt) do
829
+ driver.find_xpath("//input").first.click
830
+ driver.console_messages.first[:message].should eq "goodbye"
831
+ end
832
+ rescue Capybara::ModalNotFound
833
+ end
834
+ end
835
+
671
836
  it "should default to accept the confirm" do
672
837
  driver.find_xpath("//input").first.click
673
838
  driver.console_messages.first[:message].should eq "hello"
@@ -727,8 +892,23 @@ describe Capybara::Webkit::Driver do
727
892
  else
728
893
  console.log("goodbye");
729
894
  }
895
+ function test_complex_dialog() {
896
+ var response = prompt("Your name?", "John Smith");
897
+ if(response != null)
898
+ if(prompt("Your age?"))
899
+ console.log("hello " + response);
900
+ else
901
+ console.log("goodbye");
902
+ }
903
+ function test_async_dialog() {
904
+ setTimeout(function() {
905
+ var response = prompt("Your name?", "John Smith");
906
+ }, 100);
907
+ }
730
908
  </script>
731
909
  <input type="button" onclick="test_dialog()" name="test"/>
910
+ <input type="button" onclick="test_complex_dialog()" name="test_complex"/>
911
+ <input type="button" onclick="test_async_dialog()" name="test_async"/>
732
912
  </body>
733
913
  </html>
734
914
  HTML
@@ -736,6 +916,88 @@ describe Capybara::Webkit::Driver do
736
916
 
737
917
  before { visit("/") }
738
918
 
919
+ it 'accepts any prompt modal if no match is provided' do
920
+ driver.accept_modal(:prompt) do
921
+ driver.find_xpath("//input").first.click
922
+ end
923
+ driver.console_messages.first[:message].should eq "hello John Smith"
924
+ end
925
+
926
+ it 'accepts any prompt modal with the provided response' do
927
+ driver.accept_modal(:prompt, with: 'Capy') do
928
+ driver.find_xpath("//input").first.click
929
+ end
930
+ driver.console_messages.first[:message].should eq "hello Capy"
931
+ end
932
+
933
+ it 'raises an error when accepting a prompt modal that does not match' do
934
+ expect {
935
+ driver.accept_modal(:prompt, text: 'Your age?') do
936
+ driver.find_xpath("//input").first.click
937
+ end
938
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog with Your age?"
939
+ end
940
+
941
+ it 'dismisses any prompt modal if no match is provided' do
942
+ driver.dismiss_modal(:prompt) do
943
+ driver.find_xpath("//input").first.click
944
+ end
945
+ driver.console_messages.first[:message].should eq "goodbye"
946
+ end
947
+
948
+ it 'dismisses a prompt modal that does not match' do
949
+ begin
950
+ driver.accept_modal(:prompt, text: 'Your age?') do
951
+ driver.find_xpath("//input").first.click
952
+ driver.console_messages.first[:message].should eq "goodbye"
953
+ end
954
+ rescue Capybara::ModalNotFound
955
+ end
956
+ end
957
+
958
+ it 'raises an error when dismissing a prompt modal that does not match' do
959
+ expect {
960
+ driver.dismiss_modal(:prompt, text: 'Your age?') do
961
+ driver.find_xpath("//input").first.click
962
+ end
963
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog with Your age?"
964
+ end
965
+
966
+ it 'waits to accept an async prompt modal' do
967
+ visit("/async")
968
+ prompt_message = driver.accept_modal(:prompt) do
969
+ driver.find_css("input[name=test_async]").first.click
970
+ end
971
+ prompt_message.should eq "Your name?"
972
+ end
973
+
974
+ it 'allows the nesting of dismiss and accept' do
975
+ driver.dismiss_modal(:prompt) do
976
+ driver.accept_modal(:prompt) do
977
+ driver.find_css("input[name=test_complex]").first.click
978
+ end
979
+ end
980
+ driver.console_messages.first[:message].should eq "goodbye"
981
+ end
982
+
983
+ it 'raises an error when an unexpected modal is displayed' do
984
+ expect {
985
+ driver.accept_modal(:confirm) do
986
+ driver.find_xpath("//input").first.click
987
+ end
988
+ }.to raise_error Capybara::ModalNotFound, "Unable to find modal dialog"
989
+ end
990
+
991
+ it 'dismisses a prompt modal when confirm is expected' do
992
+ begin
993
+ driver.accept_modal(:confirm) do
994
+ driver.find_xpath("//input").first.click
995
+ driver.console_messages.first[:message].should eq "goodbye"
996
+ end
997
+ rescue Capybara::ModalNotFound
998
+ end
999
+ end
1000
+
739
1001
  it "should default to dismiss the prompt" do
740
1002
  driver.find_xpath("//input").first.click
741
1003
  driver.console_messages.first[:message].should eq "goodbye"
@@ -1763,6 +2025,75 @@ describe Capybara::Webkit::Driver do
1763
2025
  end
1764
2026
  end
1765
2027
 
2028
+ context "offline application cache" do
2029
+ let(:driver) do
2030
+ @visited = []
2031
+ visited = @visited
2032
+
2033
+ driver_for_app do
2034
+ get '/8d853f09-4275-409d-954d-ebbf6e2ce732' do
2035
+ content_type 'text/cache-manifest'
2036
+ visited << 'manifest'
2037
+ <<-TEXT
2038
+ CACHE MANIFEST
2039
+ /4aaffa31-f42d-403e-a19e-6b248d608087
2040
+ TEXT
2041
+ end
2042
+
2043
+ # UUID urls so that this gets isolated from other tests
2044
+ get '/f8742c39-8bef-4196-b1c3-80f8a3d65f3e' do
2045
+ visited << 'complex'
2046
+ <<-HTML
2047
+ <html manifest="/8d853f09-4275-409d-954d-ebbf6e2ce732">
2048
+ <body>
2049
+ <span id='state'></span>
2050
+ <span id='finished'></span>
2051
+ <script type="text/javascript">
2052
+ document.getElementById("state").innerHTML = applicationCache.status;
2053
+ applicationCache.addEventListener('cached', function() {
2054
+ document.getElementById("finished").innerHTML = 'cached';
2055
+ });
2056
+ applicationCache.addEventListener('error', function() {
2057
+ document.getElementById("finished").innerHTML = 'error';
2058
+ });
2059
+ </script>
2060
+ </body>
2061
+ </html>
2062
+ HTML
2063
+ end
2064
+
2065
+ get '/4aaffa31-f42d-403e-a19e-6b248d608087' do
2066
+ visited << 'simple'
2067
+ <<-HTML
2068
+ <html manifest="/8d853f09-4275-409d-954d-ebbf6e2ce732">
2069
+ <body>
2070
+ </body>
2071
+ </html>
2072
+ HTML
2073
+ end
2074
+ end
2075
+ end
2076
+
2077
+ before { visit("/f8742c39-8bef-4196-b1c3-80f8a3d65f3e") }
2078
+
2079
+ it "has proper state available" do
2080
+ driver.find_xpath("//*[@id='state']").first.visible_text.should == '0'
2081
+ sleep 1
2082
+ @visited.should eq(['complex', 'manifest', 'simple']), 'files were not downloaded in expected order'
2083
+ driver.find_xpath("//*[@id='finished']").first.visible_text.should == 'cached'
2084
+ end
2085
+
2086
+ it "is cleared on driver reset!" do
2087
+ sleep 1
2088
+ @visited.should eq(['complex', 'manifest', 'simple']), 'files were not downloaded in expected order'
2089
+ driver.reset!
2090
+ @visited.clear
2091
+ visit '/4aaffa31-f42d-403e-a19e-6b248d608087'
2092
+ sleep 1
2093
+ @visited.should eq(['simple', 'manifest', 'simple']), 'simple action was used from cache instead of server'
2094
+ end
2095
+ end
2096
+
1766
2097
  context "form app with server-side handler" do
1767
2098
  let(:driver) do
1768
2099
  driver_for_app do
@@ -2185,6 +2516,7 @@ describe Capybara::Webkit::Driver do
2185
2516
  <iframe src="http://example.com/path" id="frame1"></iframe>
2186
2517
  <iframe src="http://example.org/path/to/file" id="frame2"></iframe>
2187
2518
  <iframe src="/frame" id="frame3"></iframe>
2519
+ <iframe src="http://example.org/foo/bar" id="frame4"></iframe>
2188
2520
  </body>
2189
2521
  </html>
2190
2522
  HTML
@@ -2210,6 +2542,7 @@ describe Capybara::Webkit::Driver do
2210
2542
 
2211
2543
  before do
2212
2544
  driver.browser.url_blacklist = ["http://example.org/path/to/file",
2545
+ "http://example.*/foo/*",
2213
2546
  "http://example.com",
2214
2547
  "#{AppRunner.app_host}/script"]
2215
2548
  end
@@ -2240,6 +2573,13 @@ describe Capybara::Webkit::Driver do
2240
2573
  end
2241
2574
  end
2242
2575
 
2576
+ it "should not fetch urls blocked by wildcard match" do
2577
+ visit('/')
2578
+ driver.within_frame('frame4') do
2579
+ driver.find("//body").first.text.should be_empty
2580
+ end
2581
+ end
2582
+
2243
2583
  it "returns a status code for blocked urls" do
2244
2584
  visit("/")
2245
2585
  driver.within_frame('frame1') do