axe-core-api 2.6.1.pre.0f0b25b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +362 -0
- data/README.md +5 -0
- data/lib/axe/api/a11y_check.rb +69 -0
- data/lib/axe/api/audit.rb +24 -0
- data/lib/axe/api/context.rb +35 -0
- data/lib/axe/api/options.rb +32 -0
- data/lib/axe/api/results/check.rb +32 -0
- data/lib/axe/api/results/checked_node.rb +51 -0
- data/lib/axe/api/results/node.rb +35 -0
- data/lib/axe/api/results/rule.rb +58 -0
- data/lib/axe/api/results.rb +48 -0
- data/lib/axe/api/rules.rb +37 -0
- data/lib/axe/api/run.rb +53 -0
- data/lib/axe/api/selector.rb +18 -0
- data/lib/axe/api/value_object.rb +9 -0
- data/lib/axe/configuration.rb +44 -0
- data/lib/axe/core.rb +45 -0
- data/lib/axe/dsl.rb +15 -0
- data/lib/axe/expectation.rb +33 -0
- data/lib/axe/finds_page.rb +55 -0
- data/lib/axe/matchers/be_accessible.rb +36 -0
- data/lib/chain_mail/chainable.rb +19 -0
- data/lib/hooks.rb +31 -0
- data/lib/loader.rb +25 -0
- data/lib/webdriver_script_adapter/exec_eval_script_adapter.rb +27 -0
- data/lib/webdriver_script_adapter/execute_async_script_adapter.rb +94 -0
- data/lib/webdriver_script_adapter/frame_adapter.rb +84 -0
- data/lib/webdriver_script_adapter/query_selector_adapter.rb +17 -0
- data/node_modules/axe-core/axe.min.js +12 -0
- metadata +200 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
require "dumb_delegator"
|
2
|
+
|
3
|
+
module WebDriverScriptAdapter
|
4
|
+
class FrameAdapter < ::DumbDelegator
|
5
|
+
def self.wrap(driver)
|
6
|
+
if driver.respond_to?(:within_frame)
|
7
|
+
CapybaraAdapter.new driver
|
8
|
+
elsif !driver.respond_to?(:switch_to)
|
9
|
+
WatirAdapter.new driver
|
10
|
+
elsif driver.switch_to.respond_to?(:parent_frame)
|
11
|
+
SeleniumAdapter.new driver # add within_frame to selenium
|
12
|
+
else
|
13
|
+
ParentlessFrameAdapter.new driver # old selenium doesn't support parent_frame
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
class CapybaraAdapter < ::DumbDelegator
|
20
|
+
def find_frames
|
21
|
+
all(:css, "iframe")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class WatirAdapter < ::DumbDelegator
|
26
|
+
# delegate to Watir's Selenium #driver
|
27
|
+
def within_frame(frame, &block)
|
28
|
+
SeleniumAdapter.instance_method(:within_frame).bind(FrameAdapter.wrap driver).call(frame, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_frames
|
32
|
+
driver.find_elements(:css, "iframe")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class SeleniumAdapter < ::DumbDelegator
|
37
|
+
def within_frame(frame)
|
38
|
+
switch_to.frame(frame)
|
39
|
+
yield
|
40
|
+
ensure
|
41
|
+
begin
|
42
|
+
switch_to.parent_frame
|
43
|
+
rescue => e
|
44
|
+
if /switchToParentFrame|frame\/parent/.match(e.message)
|
45
|
+
::Kernel.warn "WARNING:
|
46
|
+
This browser only supports first-level iframes.
|
47
|
+
Second-level iframes and beyond will not be audited.
|
48
|
+
To skip auditing all iframes,
|
49
|
+
set Axe::Configuration#skip_iframes=true"
|
50
|
+
end
|
51
|
+
switch_to.default_content
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_frames
|
56
|
+
find_elements(:css, "iframe")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Selenium Webdriver < 2.43 doesnt support moving back to the parent
|
61
|
+
class ParentlessFrameAdapter < ::DumbDelegator
|
62
|
+
# storage of frame stack (for reverting to parent) taken from Capybara
|
63
|
+
# : https://github.com/jnicklas/capybara/blob/2.6.2/lib/capybara/selenium/driver.rb#L117-L147
|
64
|
+
#
|
65
|
+
# There doesnt appear to be any way in Selenium Webdriver < 2.43 to move back to a parent frame
|
66
|
+
# other than going back to the root and then reiterating down
|
67
|
+
def within_frame(frame)
|
68
|
+
@frame_stack[window_handle] ||= []
|
69
|
+
@frame_stack[window_handle] << frame
|
70
|
+
|
71
|
+
switch_to.frame(frame)
|
72
|
+
yield
|
73
|
+
ensure
|
74
|
+
@frame_stack[window_handle].pop
|
75
|
+
switch_to.default_content
|
76
|
+
@frame_stack[window_handle].each { |f| switch_to.frame(f) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_frames
|
81
|
+
find_elements(:css, "iframe")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'dumb_delegator'
|
2
|
+
|
3
|
+
module WebDriverScriptAdapter
|
4
|
+
class QuerySelectorAdapter < ::DumbDelegator
|
5
|
+
def self.wrap(driver)
|
6
|
+
# capybara: all(<tag>) but also seems to support all(:css, <tag>)
|
7
|
+
# watir: elements(:css); also supports #iframes
|
8
|
+
# selenium: find_elements(:css, <tag>); aliased as all
|
9
|
+
|
10
|
+
driver.respond_to?(:find_elements) ? driver : new(driver)
|
11
|
+
end
|
12
|
+
|
13
|
+
def find_elements(*args)
|
14
|
+
respond_to?(:elements) ? elements(*args) : all(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|