capybara 3.29.0 → 3.37.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +229 -15
- data/README.md +13 -4
- data/lib/capybara/config.rb +24 -10
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +8 -0
- data/lib/capybara/driver/node.rb +5 -1
- data/lib/capybara/dsl.rb +5 -3
- data/lib/capybara/helpers.rb +19 -2
- data/lib/capybara/minitest/spec.rb +156 -97
- data/lib/capybara/minitest.rb +232 -144
- data/lib/capybara/node/actions.rb +41 -37
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +35 -21
- data/lib/capybara/node/finders.rb +33 -19
- data/lib/capybara/node/matchers.rb +72 -57
- data/lib/capybara/node/simple.rb +13 -3
- data/lib/capybara/queries/active_element_query.rb +18 -0
- data/lib/capybara/queries/ancestor_query.rb +4 -3
- data/lib/capybara/queries/base_query.rb +2 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +91 -30
- data/lib/capybara/queries/sibling_query.rb +4 -3
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +7 -1
- data/lib/capybara/rack_test/browser.rb +68 -10
- data/lib/capybara/rack_test/driver.rb +6 -5
- data/lib/capybara/rack_test/form.rb +2 -2
- data/lib/capybara/rack_test/node.rb +44 -16
- data/lib/capybara/registration_container.rb +41 -0
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
- data/lib/capybara/registrations/servers.rb +3 -2
- data/lib/capybara/result.rb +35 -15
- data/lib/capybara/rspec/matcher_proxies.rb +8 -8
- data/lib/capybara/rspec/matchers/base.rb +12 -6
- data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_selector.rb +16 -8
- data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
- data/lib/capybara/rspec/matchers/have_text.rb +3 -3
- data/lib/capybara/rspec/matchers/have_title.rb +2 -2
- data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
- data/lib/capybara/rspec/matchers/match_style.rb +7 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers.rb +33 -32
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/selector/builders/css_builder.rb +2 -2
- data/lib/capybara/selector/builders/xpath_builder.rb +4 -2
- data/lib/capybara/selector/css.rb +2 -2
- data/lib/capybara/selector/definition/button.rb +35 -13
- data/lib/capybara/selector/definition/checkbox.rb +3 -3
- data/lib/capybara/selector/definition/css.rb +3 -1
- data/lib/capybara/selector/definition/datalist_input.rb +2 -2
- data/lib/capybara/selector/definition/datalist_option.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +3 -2
- data/lib/capybara/selector/definition/field.rb +1 -1
- data/lib/capybara/selector/definition/file_field.rb +2 -2
- data/lib/capybara/selector/definition/fillable_field.rb +3 -3
- data/lib/capybara/selector/definition/label.rb +5 -3
- data/lib/capybara/selector/definition/link.rb +8 -0
- data/lib/capybara/selector/definition/radio_button.rb +3 -3
- data/lib/capybara/selector/definition/select.rb +33 -14
- data/lib/capybara/selector/definition/table.rb +6 -3
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/definition.rb +15 -11
- data/lib/capybara/selector/filter_set.rb +17 -17
- data/lib/capybara/selector/filters/base.rb +6 -1
- data/lib/capybara/selector/filters/locator_filter.rb +1 -1
- data/lib/capybara/selector/selector.rb +17 -3
- data/lib/capybara/selector.rb +37 -19
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
- data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
- data/lib/capybara/selenium/driver.rb +84 -17
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +11 -13
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +10 -12
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +4 -4
- data/lib/capybara/selenium/extensions/find.rb +4 -4
- data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +8 -2
- data/lib/capybara/selenium/node.rb +122 -26
- data/lib/capybara/selenium/nodes/chrome_node.rb +34 -19
- data/lib/capybara/selenium/nodes/edge_node.rb +5 -3
- data/lib/capybara/selenium/nodes/firefox_node.rb +11 -6
- data/lib/capybara/selenium/nodes/safari_node.rb +3 -3
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/logs.rb +7 -9
- data/lib/capybara/server/animation_disabler.rb +38 -15
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +22 -10
- data/lib/capybara/server.rb +15 -3
- data/lib/capybara/session/config.rb +10 -4
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/session.rb +62 -39
- data/lib/capybara/spec/public/test.js +75 -7
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/active_element_spec.rb +31 -0
- data/lib/capybara/spec/session/all_spec.rb +63 -12
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +26 -22
- data/lib/capybara/spec/session/check_spec.rb +15 -0
- data/lib/capybara/spec/session/choose_spec.rb +6 -0
- data/lib/capybara/spec/session/click_button_spec.rb +16 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
- data/lib/capybara/spec/session/current_url_spec.rb +11 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
- data/lib/capybara/spec/session/find_spec.rb +37 -8
- data/lib/capybara/spec/session/has_any_selectors_spec.rb +4 -0
- data/lib/capybara/spec/session/has_button_spec.rb +75 -0
- data/lib/capybara/spec/session/has_css_spec.rb +14 -10
- data/lib/capybara/spec/session/has_current_path_spec.rb +17 -4
- data/lib/capybara/spec/session/has_field_spec.rb +41 -1
- data/lib/capybara/spec/session/has_link_spec.rb +30 -0
- data/lib/capybara/spec/session/has_select_spec.rb +36 -8
- data/lib/capybara/spec/session/has_selector_spec.rb +19 -4
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +21 -1
- data/lib/capybara/spec/session/html_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +226 -33
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/scroll_spec.rb +4 -4
- data/lib/capybara/spec/session/selectors_spec.rb +15 -2
- data/lib/capybara/spec/session/visit_spec.rb +20 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +9 -9
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +17 -17
- data/lib/capybara/spec/test_app.rb +89 -29
- data/lib/capybara/spec/views/animated.erb +1 -1
- data/lib/capybara/spec/views/form.erb +52 -6
- data/lib/capybara/spec/views/frame_child.erb +1 -1
- data/lib/capybara/spec/views/frame_one.erb +1 -1
- data/lib/capybara/spec/views/frame_parent.erb +1 -1
- data/lib/capybara/spec/views/frame_two.erb +1 -1
- data/lib/capybara/spec/views/initial_alert.erb +2 -1
- data/lib/capybara/spec/views/layout.erb +10 -0
- data/lib/capybara/spec/views/obscured.erb +1 -1
- data/lib/capybara/spec/views/offset.erb +2 -1
- data/lib/capybara/spec/views/path.erb +2 -2
- data/lib/capybara/spec/views/popup_one.erb +1 -1
- data/lib/capybara/spec/views/popup_two.erb +1 -1
- data/lib/capybara/spec/views/react.erb +2 -2
- data/lib/capybara/spec/views/scroll.erb +2 -1
- data/lib/capybara/spec/views/spatial.erb +1 -1
- data/lib/capybara/spec/views/with_animation.erb +10 -3
- data/lib/capybara/spec/views/with_base_tag.erb +2 -2
- data/lib/capybara/spec/views/with_dragula.erb +5 -3
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
- data/lib/capybara/spec/views/with_hover.erb +2 -2
- data/lib/capybara/spec/views/with_html.erb +3 -3
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +5 -3
- data/lib/capybara/spec/views/with_jstree.erb +1 -1
- data/lib/capybara/spec/views/with_namespace.erb +1 -0
- data/lib/capybara/spec/views/with_shadow.erb +31 -0
- data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
- data/lib/capybara/spec/views/with_sortable_js.erb +3 -3
- data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
- data/lib/capybara/spec/views/with_windows.erb +1 -1
- data/lib/capybara/spec/views/within_frames.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +4 -8
- data/lib/capybara.rb +36 -29
- data/spec/basic_node_spec.rb +25 -11
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +18 -5
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
- data/spec/fixtures/selenium_driver_rspec_success.rb +3 -3
- data/spec/minitest_spec.rb +3 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/rack_test_spec.rb +43 -11
- data/spec/regexp_dissassembler_spec.rb +40 -36
- data/spec/result_spec.rb +53 -45
- data/spec/rspec/features_spec.rb +7 -4
- data/spec/rspec/scenarios_spec.rb +5 -1
- data/spec/rspec/shared_spec_matchers.rb +68 -56
- data/spec/rspec_spec.rb +8 -4
- data/spec/sauce_spec_chrome.rb +3 -3
- data/spec/selector_spec.rb +19 -4
- data/spec/selenium_spec_chrome.rb +49 -26
- data/spec/selenium_spec_chrome_remote.rb +13 -6
- data/spec/selenium_spec_firefox.rb +29 -17
- data/spec/selenium_spec_firefox_remote.rb +2 -2
- data/spec/selenium_spec_ie.rb +3 -6
- data/spec/selenium_spec_safari.rb +31 -19
- data/spec/server_spec.rb +88 -35
- data/spec/session_spec.rb +1 -1
- data/spec/shared_selenium_node.rb +21 -7
- data/spec/shared_selenium_session.rb +123 -21
- data/spec/spec_helper.rb +2 -2
- metadata +80 -21
- data/lib/capybara/spec/session/source_spec.rb +0 -0
- data/lib/capybara/spec/views/with_title.erb +0 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -59,7 +59,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
59
59
|
it 'should return false if window is closed' do
|
60
60
|
@session.switch_to_window(other_window)
|
61
61
|
other_window.close
|
62
|
-
expect(other_window.current?).to
|
62
|
+
expect(other_window.current?).to be(false)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -141,12 +141,12 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
describe '#maximize' do
|
144
|
-
|
145
|
-
@
|
144
|
+
let! :initial_size do
|
145
|
+
@session.current_window.size
|
146
146
|
end
|
147
147
|
|
148
148
|
after do
|
149
|
-
@session.current_window.resize_to(
|
149
|
+
@session.current_window.resize_to(*initial_size)
|
150
150
|
sleep 0.5
|
151
151
|
end
|
152
152
|
|
@@ -176,7 +176,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
176
176
|
|
177
177
|
expect(@session.current_window).to eq(orig_window)
|
178
178
|
# Maximizing the browser affects all tabs so this may not be valid in real browsers
|
179
|
-
# expect(@session.current_window.size).to eq(
|
179
|
+
# expect(@session.current_window.size).to eq(initial_size)
|
180
180
|
|
181
181
|
ow_width, ow_height = other_window.size
|
182
182
|
expect(ow_width).to be > 400
|
@@ -185,12 +185,12 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
185
185
|
end
|
186
186
|
|
187
187
|
describe '#fullscreen' do
|
188
|
-
|
189
|
-
@
|
188
|
+
let! :initial_size do
|
189
|
+
@session.current_window.size
|
190
190
|
end
|
191
191
|
|
192
192
|
after do
|
193
|
-
@session.current_window.resize_to(
|
193
|
+
@session.current_window.resize_to(*initial_size)
|
194
194
|
sleep 1
|
195
195
|
end
|
196
196
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -30,12 +30,13 @@ module Capybara
|
|
30
30
|
Capybara.visible_text_only = false
|
31
31
|
Capybara.match = :smart
|
32
32
|
Capybara.enable_aria_label = false
|
33
|
+
Capybara.enable_aria_role = false
|
33
34
|
Capybara.default_set_options = {}
|
34
35
|
Capybara.disable_animation = false
|
35
36
|
Capybara.test_id = nil
|
36
37
|
Capybara.predicates_wait = true
|
37
38
|
Capybara.default_normalize_ws = false
|
38
|
-
Capybara.
|
39
|
+
Capybara.use_html5_parsing = !ENV['HTML5_PARSING'].nil?
|
39
40
|
Capybara.w3c_click_offset = false
|
40
41
|
reset_threadsafe
|
41
42
|
end
|
@@ -57,10 +58,10 @@ module Capybara
|
|
57
58
|
|
58
59
|
def run_specs(session, name, **options, &filter_block)
|
59
60
|
specs = @specs
|
60
|
-
RSpec.describe Capybara::Session, name, options do
|
61
|
+
RSpec.describe Capybara::Session, name, options do
|
61
62
|
include Capybara::SpecHelper
|
62
63
|
include Capybara::RSpecMatchers
|
63
|
-
|
64
|
+
|
64
65
|
before do |example|
|
65
66
|
@session = session
|
66
67
|
instance_exec(example, &filter_block) if filter_block
|
@@ -71,28 +72,28 @@ module Capybara
|
|
71
72
|
end
|
72
73
|
|
73
74
|
before :each, psc: true do
|
74
|
-
SpecHelper.reset_threadsafe(true, session)
|
75
|
+
SpecHelper.reset_threadsafe(bool: true, session: session)
|
75
76
|
end
|
76
77
|
|
77
78
|
after psc: true do
|
78
|
-
SpecHelper.reset_threadsafe(
|
79
|
+
SpecHelper.reset_threadsafe(session: session)
|
79
80
|
end
|
80
81
|
|
81
82
|
before :each, :exact_false do
|
82
83
|
Capybara.exact = false
|
83
84
|
end
|
84
|
-
# rubocop:enable RSpec/ScatteredSetup
|
85
85
|
|
86
86
|
specs.each do |spec_name, spec_options, block|
|
87
|
-
describe spec_name, *spec_options do
|
87
|
+
describe spec_name, *spec_options do
|
88
88
|
class_eval(&block)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
def reset_threadsafe(bool
|
95
|
-
|
94
|
+
def reset_threadsafe(bool: false, session: nil)
|
95
|
+
# Work around limit on when threadsafe can be changed
|
96
|
+
Capybara::Session.class_variable_set(:@@instance_created, false) # rubocop:disable Style/ClassVars
|
96
97
|
Capybara.threadsafe = bool
|
97
98
|
session = session.current_session if session.respond_to?(:current_session)
|
98
99
|
session&.instance_variable_set(:@config, nil)
|
@@ -108,18 +109,17 @@ module Capybara
|
|
108
109
|
stream.reopen(old_stream)
|
109
110
|
end
|
110
111
|
|
111
|
-
def quietly
|
112
|
-
silence_stream(
|
113
|
-
silence_stream(
|
114
|
-
yield
|
115
|
-
end
|
112
|
+
def quietly(&block)
|
113
|
+
silence_stream($stdout) do
|
114
|
+
silence_stream($stderr, &block)
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
119
118
|
def extract_results(session)
|
120
119
|
expect(session).to have_xpath("//pre[@id='results']")
|
121
|
-
|
122
|
-
|
120
|
+
perms = [(::Sinatra::IndifferentHash if defined? ::Sinatra::IndifferentHash)].compact
|
121
|
+
results = Capybara::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
|
122
|
+
YAML.safe_load results, permitted_classes: perms
|
123
123
|
end
|
124
124
|
|
125
125
|
def be_an_invalid_element_error(session)
|
@@ -132,4 +132,4 @@ module Capybara
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
-
Dir[File.dirname(__FILE__)
|
135
|
+
Dir["#{File.dirname(__FILE__)}/session/**/*.rb"].each { |file| require_relative file }
|
@@ -7,8 +7,10 @@ require 'yaml'
|
|
7
7
|
|
8
8
|
class TestApp < Sinatra::Base
|
9
9
|
class TestAppError < Exception; end # rubocop:disable Lint/InheritException
|
10
|
+
|
10
11
|
class TestAppOtherError < Exception # rubocop:disable Lint/InheritException
|
11
12
|
def initialize(string1, msg)
|
13
|
+
super()
|
12
14
|
@something = string1
|
13
15
|
@message = msg
|
14
16
|
end
|
@@ -33,6 +35,10 @@ class TestApp < Sinatra::Base
|
|
33
35
|
redirect '/redirect_again'
|
34
36
|
end
|
35
37
|
|
38
|
+
get '/redirect_with_fragment' do
|
39
|
+
redirect '/landed#with_fragment'
|
40
|
+
end
|
41
|
+
|
36
42
|
get '/redirect_again' do
|
37
43
|
redirect '/landed'
|
38
44
|
end
|
@@ -47,8 +53,8 @@ class TestApp < Sinatra::Base
|
|
47
53
|
|
48
54
|
get '/referer_base' do
|
49
55
|
'<a href="/get_referer">direct link</a>' \
|
50
|
-
|
51
|
-
|
56
|
+
'<a href="/redirect_to_get_referer">link via redirect</a>' \
|
57
|
+
'<form action="/get_referer" method="get"><input type="submit"></form>'
|
52
58
|
end
|
53
59
|
|
54
60
|
get '/redirect_to_get_referer' do
|
@@ -85,11 +91,11 @@ class TestApp < Sinatra::Base
|
|
85
91
|
end
|
86
92
|
|
87
93
|
get '/form/get' do
|
88
|
-
|
94
|
+
%(<pre id="results">#{params[:form].to_yaml}</pre>)
|
89
95
|
end
|
90
96
|
|
91
97
|
post '/relative' do
|
92
|
-
|
98
|
+
%(<pre id="results">#{params[:form].to_yaml}</pre>)
|
93
99
|
end
|
94
100
|
|
95
101
|
get '/favicon.ico' do
|
@@ -157,26 +163,84 @@ class TestApp < Sinatra::Base
|
|
157
163
|
|
158
164
|
get '/with_title' do
|
159
165
|
<<-HTML
|
160
|
-
|
161
|
-
<
|
162
|
-
<
|
163
|
-
|
166
|
+
<!DOCTYPE html>
|
167
|
+
<html lang="en">
|
168
|
+
<head>
|
169
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
170
|
+
<title>#{params[:title] || 'Test Title'}</title>
|
171
|
+
</head>
|
172
|
+
|
173
|
+
<body>
|
174
|
+
<svg><title>abcdefg</title></svg>
|
175
|
+
</body>
|
176
|
+
</html>
|
177
|
+
HTML
|
178
|
+
end
|
179
|
+
|
180
|
+
get '/base/with_base' do
|
181
|
+
<<-HTML
|
182
|
+
<!DOCTYPE html>
|
183
|
+
<html>
|
184
|
+
<head>
|
185
|
+
<base href="/">
|
186
|
+
<title>Origin</title>
|
187
|
+
</head>
|
188
|
+
<body>
|
189
|
+
<a href="with_title">Title page</a>
|
190
|
+
<a href="?a=3">Bare query</a>
|
191
|
+
</body>
|
192
|
+
</html>
|
193
|
+
HTML
|
194
|
+
end
|
195
|
+
|
196
|
+
get '/base/with_other_base' do
|
197
|
+
<<-HTML
|
198
|
+
<!DOCTYPE html>
|
199
|
+
<html>
|
200
|
+
<head>
|
201
|
+
<base href="/base/">
|
202
|
+
<title>Origin</title>
|
203
|
+
</head>
|
204
|
+
<body>
|
205
|
+
<a href="with_title">Title page</a>
|
206
|
+
<a href="?a=3">Bare query</a>
|
207
|
+
</body>
|
208
|
+
</html>
|
209
|
+
HTML
|
210
|
+
end
|
211
|
+
|
212
|
+
get '/csp' do
|
213
|
+
response.headers['Content-Security-Policy'] = "default-src 'none'; connect-src 'self'; base-uri 'none'; font-src 'self'; img-src 'self' data:; object-src 'none'; script-src 'self' 'nonce-jAviMuMisoTisVXjgLoWdA=='; style-src 'self' 'nonce-jAviMuMisoTisVXjgLoWdA=='; form-action 'self';"
|
214
|
+
<<-HTML
|
215
|
+
<!DOCTYPE html>
|
216
|
+
<html lang="en">
|
217
|
+
<head>
|
218
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
219
|
+
<title>CSP</title>
|
220
|
+
</head>
|
221
|
+
|
222
|
+
<body>
|
223
|
+
<div>CSP</div>
|
224
|
+
</body>
|
225
|
+
</html>
|
164
226
|
HTML
|
165
227
|
end
|
166
228
|
|
167
229
|
get '/download.csv' do
|
168
230
|
content_type 'text/csv'
|
169
231
|
'This, is, comma, separated' \
|
170
|
-
|
232
|
+
'Thomas, Walpole, was , here'
|
171
233
|
end
|
172
234
|
|
173
235
|
get '/:view' do |view|
|
174
|
-
|
236
|
+
view_template = "#{__dir__}/views/#{view}.erb"
|
237
|
+
has_layout = File.exist?(view_template) && File.open(view_template) { |f| f.first.downcase.include?('doctype') }
|
238
|
+
erb view.to_sym, locals: { referrer: request.referrer }, layout: !has_layout
|
175
239
|
end
|
176
240
|
|
177
241
|
post '/form' do
|
178
242
|
self.class.form_post_count += 1
|
179
|
-
|
243
|
+
%(<pre id="results">#{params[:form].merge('post_count' => self.class.form_post_count).to_yaml}</pre>)
|
180
244
|
end
|
181
245
|
|
182
246
|
post '/upload_empty' do
|
@@ -188,28 +252,24 @@ class TestApp < Sinatra::Base
|
|
188
252
|
end
|
189
253
|
|
190
254
|
post '/upload' do
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
'No file uploaded'
|
198
|
-
end
|
255
|
+
buffer = []
|
256
|
+
buffer << "Content-type: #{params.dig(:form, :document, :type)}"
|
257
|
+
buffer << "File content: #{params.dig(:form, :document, :tempfile).read}"
|
258
|
+
buffer.join(' | ')
|
259
|
+
rescue StandardError
|
260
|
+
'No file uploaded'
|
199
261
|
end
|
200
262
|
|
201
263
|
post '/upload_multiple' do
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
buffer << "File content: #{doc[:tempfile].read}"
|
208
|
-
end
|
209
|
-
buffer.join(' | ')
|
210
|
-
rescue StandardError
|
211
|
-
'No files uploaded'
|
264
|
+
docs = params.dig(:form, :multiple_documents)
|
265
|
+
buffer = [docs.size.to_s]
|
266
|
+
docs.each do |doc|
|
267
|
+
buffer << "Content-type: #{doc[:type]}"
|
268
|
+
buffer << "File content: #{doc[:tempfile].read}"
|
212
269
|
end
|
270
|
+
buffer.join(' | ')
|
271
|
+
rescue StandardError
|
272
|
+
'No files uploaded'
|
213
273
|
end
|
214
274
|
|
215
275
|
get '/apple-touch-icon-precomposed.png' do
|
@@ -1,17 +1,23 @@
|
|
1
|
-
|
2
1
|
<h1>Form</h1>
|
3
2
|
|
3
|
+
<button type="button" tabindex="1">A Button</button>
|
4
|
+
|
5
|
+
<label>
|
6
|
+
An Input
|
7
|
+
<input type="text" tabindex="2">
|
8
|
+
</label>
|
9
|
+
|
4
10
|
<form action="/form" method="post" novalidate>
|
5
11
|
|
6
12
|
<p>
|
7
13
|
<label for="form_title">Title</label>
|
8
|
-
<select name="form[title]" id="form_title" class="title">
|
14
|
+
<select name="form[title]" id="form_title" class="title" tabindex="3">
|
9
15
|
<option class="title">Mrs</option>
|
10
16
|
<option class="title">Mr</option>
|
11
17
|
<option>Miss</option>
|
12
18
|
<option disabled="disabled">Other</option>
|
13
19
|
</select>
|
14
|
-
|
20
|
+
</p>
|
15
21
|
|
16
22
|
<p>
|
17
23
|
<label for="customer_name">Customer Name
|
@@ -62,6 +68,11 @@
|
|
62
68
|
<input type="text" name="form[name]" value="John Smith" id="form_name"/>
|
63
69
|
</p>
|
64
70
|
|
71
|
+
<p>
|
72
|
+
<label for="form_age">Age</label>
|
73
|
+
<input type="range" name="form[age]" value="18" min="13" max="100" step="0.5" id="form_age"/>
|
74
|
+
</p>
|
75
|
+
|
65
76
|
<p>
|
66
77
|
<label for="form_schmooo">Schmooo</label>
|
67
78
|
<input type="schmooo" name="form[schmooo]" value="This is Schmooo!" id="form_schmooo"/>
|
@@ -135,7 +146,11 @@
|
|
135
146
|
|
136
147
|
<p>
|
137
148
|
<label for="form_zipcode">Zipcode</label>
|
138
|
-
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" />
|
149
|
+
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" pattern="[0-9]{5,9}" />
|
150
|
+
</p>
|
151
|
+
|
152
|
+
<p>
|
153
|
+
<input maxlength="35" id="long_length" />
|
139
154
|
</p>
|
140
155
|
|
141
156
|
<p>
|
@@ -161,7 +176,7 @@ New line after and before textarea tag
|
|
161
176
|
<label for="gender_male">Male</label>
|
162
177
|
<input type="radio" name="form[gender]" value="female" id="gender_female" checked="checked"/>
|
163
178
|
<label for="gender_female">Female</label>
|
164
|
-
<input type="radio" name="form[gender]" value="both" id="gender_both"/>
|
179
|
+
<input type="radio" name="form[gender]" value="both" id="gender_both" readonly="readonly"/>
|
165
180
|
<label for="gender_both">Both</label>
|
166
181
|
</p>
|
167
182
|
|
@@ -214,6 +229,8 @@ New line after and before textarea tag
|
|
214
229
|
</label>
|
215
230
|
<input type="checkbox" value="maserati" name="form[cars][]" id="form_cars_maserati" disabled="disabled"/>
|
216
231
|
<label for="form_cars_maserati">Maserati</label>
|
232
|
+
<input type="checkbox" value="lotus" name="form[cars][]" id="form_cars_lotus" style="display: none"/>
|
233
|
+
<label for="form_cars_lotus"><a href="#" onclick="return false;">Link here</a>Lotus</label>
|
217
234
|
</p>
|
218
235
|
|
219
236
|
<p>
|
@@ -440,14 +457,25 @@ New line after and before textarea tag
|
|
440
457
|
|
441
458
|
<p>
|
442
459
|
<input type="button" aria-label="Aria button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
|
443
|
-
<input type="submit" name="form[awesome]" id="awe123" title="What an Awesome Button" value="awesome"/>
|
460
|
+
<input type="submit" name="form[awesome]" id="awe123" data-test-id="test_id_button" title="What an Awesome Button" value="awesome"/>
|
444
461
|
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
|
445
462
|
<input type="image" name="form[okay]" id="okay556" title="Okay 556 Image" value="okay" alt="oh hai thar"/>
|
446
463
|
<button type="submit" id="click_me_123" title="Click Title button" value="click_me">Click me!</button>
|
447
464
|
<button type="submit" name="form[no_value]">No Value!</button>
|
448
465
|
<button id="no_type">No Type!</button>
|
449
466
|
<button><img alt="A horse eating hay"/></button>
|
467
|
+
<button id="button_with_label"></button>
|
468
|
+
<label for="button_with_label">button with label element</label>
|
469
|
+
<label>
|
470
|
+
button within label element
|
471
|
+
<button></button>
|
472
|
+
</label>
|
473
|
+
<label>
|
474
|
+
role=button within label element
|
475
|
+
<span role="button">with other text</span>
|
476
|
+
</label>
|
450
477
|
<input type="button" disabled="disabled" value="Disabled button"/>
|
478
|
+
<span role="button">ARIA button</span>
|
451
479
|
</p>
|
452
480
|
|
453
481
|
<p>
|
@@ -474,6 +502,11 @@ New line after and before textarea tag
|
|
474
502
|
<input type="text" name="nested_label" id="nested_label"/>
|
475
503
|
</label>
|
476
504
|
|
505
|
+
<label id="wrapper_label">
|
506
|
+
Wrapper Label
|
507
|
+
<input type="checkbox"/>
|
508
|
+
</label>
|
509
|
+
|
477
510
|
<form id="form1" action="/form" method="post">
|
478
511
|
<input type="text" name="form[which_form]" value="form1" id="form_which_form"/>
|
479
512
|
<input type="text" name="form[for_form2]" value="for_form2" form="form2"/>
|
@@ -507,6 +540,7 @@ New line after and before textarea tag
|
|
507
540
|
|
508
541
|
<p>
|
509
542
|
<input type="submit" name="form[mediocre]" id="mediocre" value="med" aria-label="Mediocre Button"/>
|
543
|
+
<input type="submit" formaction="/form/get?bar=foo" id="mediocre2" value="med2"/>
|
510
544
|
<p>
|
511
545
|
</form>
|
512
546
|
|
@@ -668,3 +702,15 @@ New line after and before textarea tag
|
|
668
702
|
<p>
|
669
703
|
<input id="special" {custom}="abcdef" value="custom attribute"/>
|
670
704
|
</p>
|
705
|
+
|
706
|
+
|
707
|
+
<label for="multi_label_checkbox">
|
708
|
+
Label to click
|
709
|
+
</label>
|
710
|
+
<div>Something random that justifies the usage of a separate label</div>
|
711
|
+
<label>
|
712
|
+
<div>
|
713
|
+
<input type="checkbox" id="multi_label_checkbox" style="display: none"/>
|
714
|
+
<div>Visual representation of the checkbox</div>
|
715
|
+
</div>
|
716
|
+
</label>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
<html
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
5
5
|
<title>with_animation</title>
|
@@ -18,6 +18,14 @@
|
|
18
18
|
});
|
19
19
|
</script>
|
20
20
|
<style>
|
21
|
+
html {
|
22
|
+
scroll-behavior: smooth;
|
23
|
+
}
|
24
|
+
|
25
|
+
body {
|
26
|
+
min-height: 2000px;
|
27
|
+
}
|
28
|
+
|
21
29
|
.transition.away {
|
22
30
|
width: 0%;
|
23
31
|
}
|
@@ -71,4 +79,3 @@
|
|
71
79
|
</a>
|
72
80
|
</body>
|
73
81
|
</html>
|
74
|
-
|