mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Minor code cleanup
This commit is contained in:
parent
71770a1b81
commit
70ab439726
3 changed files with 20 additions and 16 deletions
|
@ -44,27 +44,31 @@ module Capybara
|
|||
end
|
||||
|
||||
def insert_disable(html, nonces)
|
||||
puts nonces
|
||||
h=html.sub(%r{(</head>)}, "<style #{nonces['style-src']}>#{disable_css_markup}</style>\\1")
|
||||
html.sub(%r{(</head>)}, "<style #{nonces['style-src']}>#{disable_css_markup}</style>\\1")
|
||||
.sub(%r{(</body>)}, "<script #{nonces['script-src']}>#{disable_js_markup}</script>\\1")
|
||||
puts h
|
||||
h
|
||||
end
|
||||
|
||||
|
||||
def directive_nonces
|
||||
@headers.fetch('Content-Security-Policy', '')
|
||||
.split(';')
|
||||
.map { |s| s.split(' ') }
|
||||
.to_h { |s| [s[0], s[1..].filter_map { |value| /^\'nonce-(?<nonce>.+)\'/ =~ value; nonce}[0]]}
|
||||
.split(';')
|
||||
.map(&:split)
|
||||
.to_h do |s|
|
||||
[
|
||||
s[0], s[1..].filter_map do |value|
|
||||
/^'nonce-(?<nonce>.+)'/ =~ value
|
||||
nonce
|
||||
end[0]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
DISABLE_CSS_MARKUP_TEMPLATE = <<~CSS
|
||||
%<selector>s, %<selector>s::before, %<selector>s::after {
|
||||
transition: none !important;
|
||||
animation-duration: 0s !important;
|
||||
animation-delay: 0s !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
%<selector>s, %<selector>s::before, %<selector>s::after {
|
||||
transition: none !important;
|
||||
animation-duration: 0s !important;
|
||||
animation-delay: 0s !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
CSS
|
||||
|
||||
DISABLE_JS_MARKUP_TEMPLATE = <<~SCRIPT
|
||||
|
|
|
@ -259,7 +259,7 @@ class TestApp < Sinatra::Base
|
|||
get '/apple-touch-icon-precomposed.png' do
|
||||
halt(404)
|
||||
end
|
||||
|
||||
|
||||
class << self
|
||||
attr_accessor :form_post_count
|
||||
end
|
||||
|
|
|
@ -505,7 +505,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
end
|
||||
end
|
||||
# rubocop:enable RSpec/InstanceVariable
|
||||
|
||||
|
||||
describe ':element selector' do
|
||||
it 'can find html5 svg elements' do
|
||||
session.visit('with_html5_svg')
|
||||
|
|
Loading…
Reference in a new issue