bbc-a11y 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/features/check_standards/headings.feature +2 -2
- data/features/check_standards/title_attribute.feature +40 -0
- data/features/cli/display_failing_result.feature +2 -2
- data/features/cli/display_result_summary.feature +17 -0
- data/features/cli/specify_url.feature +1 -1
- data/features/mute_errors.feature +1 -1
- data/lib/bbc/a11y/cli.rb +17 -19
- data/lib/bbc/a11y/runner.rb +48 -0
- data/lib/bbc/a11y/standards.rb +3 -1
- data/lib/bbc/a11y/standards/exactly_one_main_heading.rb +1 -1
- data/lib/bbc/a11y/standards/title_attribute.rb +31 -0
- data/lib/bbc/a11y/version +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd9e7e73e7a90b1f1a0151176196f940e149c8e
|
4
|
+
data.tar.gz: f793efc23dc248e5c1261368ea5f5ec0c2ec3e16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db950a702d499d56739b17087ee83b69ffd62c0548ee91e9b91d3dfa1e4d8dcfd740505dfcd708803be56690f2913e4994b008c516fefbd79dde54b80720a012
|
7
|
+
data.tar.gz: 9c2706280a6e6767469c2af7c1fea8c6abb1d88288034b02dd4c34742e518eaa22aa3cef34255c2a9505a0349f0d39179d838de090a28e8ff458c8d4f5757535
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
This project is still at an experimental / proof-of-concept stage. Please set your expectations appropriately, but *do* [give us as much feedback](https://github.com/cucumber-ltd/bbc-a11y/issues) as you can.
|
6
6
|
|
7
|
-
#BBC
|
7
|
+
#BBC Accessibility Standards
|
8
8
|
|
9
9
|
This tool runs a set of tests against a set of URLs to verify whether each one meets the [BBC accessibility standards](http://www.bbc.co.uk/guidelines/futuremedia/accessibility/).
|
10
10
|
|
@@ -26,7 +26,7 @@ Feature: Headings
|
|
26
26
|
When I validate the heading standards
|
27
27
|
Then it fails with the message:
|
28
28
|
"""
|
29
|
-
A document must have exactly one heading. Found 0 h1 elements.
|
29
|
+
A document must have exactly one main heading. Found 0 h1 elements.
|
30
30
|
"""
|
31
31
|
|
32
32
|
Scenario: More than one main heading
|
@@ -39,7 +39,7 @@ Feature: Headings
|
|
39
39
|
When I validate the heading standards
|
40
40
|
Then it fails with the message:
|
41
41
|
"""
|
42
|
-
A document must have exactly one heading. Found 2 h1 elements.
|
42
|
+
A document must have exactly one main heading. Found 2 h1 elements.
|
43
43
|
"""
|
44
44
|
|
45
45
|
Scenario: Headings in ascending order
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: Correctly use `title` attributes
|
2
|
+
|
3
|
+
`title` attributes **must not** be used for critical information and **must not** repeat content that is already visible and associated with the same control or content.
|
4
|
+
|
5
|
+
Rationale
|
6
|
+
=========
|
7
|
+
|
8
|
+
`title` attributes are inaccessible to keyboard users without additional Assistive Technology. They are dependent on user settings in Screen Readers and similar Assistive Technology.
|
9
|
+
|
10
|
+
Additionally they suffer from discoverability problems: pointing device users are required to hover over page elements and pause before the title tooltip displays, usually with no indication that there is additional content to be displayed.
|
11
|
+
|
12
|
+
Repeating content in visible text and `title` attributes can lead to content clutter and repeated phrases.
|
13
|
+
|
14
|
+
Key recommendations are:
|
15
|
+
|
16
|
+
- Do not use the `title` attribute unless on a form input as title text is not well supported on links on mobile
|
17
|
+
- Do not use `title` attributes and explicit labels together on form fields
|
18
|
+
|
19
|
+
Scenario: Form field with title attribute
|
20
|
+
Given a page with the HTML:
|
21
|
+
"""
|
22
|
+
<button type="button" title="Close Button">
|
23
|
+
<img src="close.png" />
|
24
|
+
</button>
|
25
|
+
"""
|
26
|
+
When I validate the title attribute standards
|
27
|
+
Then it passes
|
28
|
+
|
29
|
+
Scenario: Anchor tag with title attribute
|
30
|
+
Given a page with the HTML:
|
31
|
+
"""
|
32
|
+
<a href="close" title="Close Button">
|
33
|
+
<img src="close.png" />
|
34
|
+
</a>
|
35
|
+
"""
|
36
|
+
When I validate the title attribute standards
|
37
|
+
Then it fails with the message:
|
38
|
+
"""
|
39
|
+
Element (not a form input) has a title attribute: /html/body/a
|
40
|
+
"""
|
@@ -3,8 +3,8 @@ Feature: Display failing result
|
|
3
3
|
Scenario: One standard fails
|
4
4
|
Given a website running at http://localhost:54321
|
5
5
|
When I run `a11y http://localhost:54321/missing_header.html`
|
6
|
-
Then it should fail with
|
6
|
+
Then it should fail with:
|
7
7
|
"""
|
8
8
|
✗ http://localhost:54321/missing_header.html
|
9
|
-
- A document must have exactly one heading. Found 0 h1 elements.
|
9
|
+
- A document must have exactly one main heading. Found 0 h1 elements.
|
10
10
|
"""
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Display result summary
|
2
|
+
|
3
|
+
Scenario: Summarises pages checked and standard results
|
4
|
+
Given a website running at http://localhost:54321
|
5
|
+
And a file named "a11y.rb" with:
|
6
|
+
"""
|
7
|
+
page "http://localhost:54321/perfect.html"
|
8
|
+
page "http://localhost:54321/missing_header.html"
|
9
|
+
page "http://localhost:54321/missing_header.html?again!" do
|
10
|
+
skip_standard /ExactlyOneMainHeading/
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
When I run `a11y`
|
14
|
+
Then it should fail with:
|
15
|
+
"""
|
16
|
+
Tested 3 pages, errors: 1, skipped: 1
|
17
|
+
"""
|
@@ -3,7 +3,7 @@ Feature: Specify URL
|
|
3
3
|
Scenario: No config, just pass page URL on command-line
|
4
4
|
Given a website running at http://localhost:54321
|
5
5
|
When I run `a11y http://localhost:54321/perfect.html`
|
6
|
-
Then it should pass with
|
6
|
+
Then it should pass with:
|
7
7
|
"""
|
8
8
|
✓ http://localhost:54321/perfect.html
|
9
9
|
"""
|
@@ -19,7 +19,7 @@ Feature: Mute errors
|
|
19
19
|
When I validate the exactly one main heading standard
|
20
20
|
Then it fails with the message:
|
21
21
|
"""
|
22
|
-
A document must have exactly one heading. Found 0 h1 elements.
|
22
|
+
A document must have exactly one main heading. Found 0 h1 elements.
|
23
23
|
"""
|
24
24
|
When I add a configuration with:
|
25
25
|
"""
|
data/lib/bbc/a11y/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: UTF-8
|
2
2
|
require 'bbc/a11y/configuration'
|
3
3
|
require 'bbc/a11y/linter'
|
4
|
+
require 'bbc/a11y/runner'
|
4
5
|
require 'open-uri'
|
5
6
|
require 'capybara'
|
6
7
|
require 'colorize'
|
@@ -14,32 +15,29 @@ module BBC
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def call
|
17
|
-
|
18
|
-
|
19
|
-
errors = check_standards_for(page_settings)
|
20
|
-
if errors.empty?
|
21
|
-
stdout.puts "✓ #{page_settings.url}".colorize(:green)
|
22
|
-
else
|
23
|
-
stdout.puts "✗ #{page_settings.url}".colorize(:red)
|
24
|
-
stdout.puts errors.map { |error|
|
25
|
-
" - #{error}"
|
26
|
-
}.join("\n")
|
27
|
-
end
|
28
|
-
all_errors += errors
|
29
|
-
end
|
30
|
-
exit 1 unless all_errors.empty?
|
18
|
+
Runner.new(settings, self).run
|
19
|
+
exit 1 if @any_errors
|
31
20
|
rescue Configuration::ParseError => error
|
32
21
|
exit_with_message error.message
|
33
22
|
end
|
34
23
|
|
35
|
-
|
24
|
+
def page_tested(page_settings, errors)
|
25
|
+
if errors.empty?
|
26
|
+
stdout.puts "✓ #{page_settings.url}".colorize(:green)
|
27
|
+
else
|
28
|
+
stdout.puts "✗ #{page_settings.url}".colorize(:red)
|
29
|
+
stdout.puts errors.map { |error| " - #{error}" }.join("\n")
|
30
|
+
end
|
31
|
+
stdout.puts ""
|
32
|
+
end
|
36
33
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
Linter.new(Capybara.string(html), standards).run.errors.to_a
|
34
|
+
def all_pages_tested(summary)
|
35
|
+
stdout.puts "Tested #{summary.pages} pages, errors: #{summary.errors}, skipped: #{summary.skips}"
|
36
|
+
@any_errors = summary.fail?
|
41
37
|
end
|
42
38
|
|
39
|
+
private
|
40
|
+
|
43
41
|
def settings
|
44
42
|
return Configuration.for_urls(@args) if @args.any?
|
45
43
|
configuration_file = File.expand_path("a11y.rb")
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'bbc/a11y/standards'
|
2
|
+
|
3
|
+
module BBC
|
4
|
+
module A11y
|
5
|
+
class Runner
|
6
|
+
def initialize(settings, listener)
|
7
|
+
@settings = settings
|
8
|
+
@listener = listener
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
@summary = RunSummary.new
|
13
|
+
@summary.pages = @settings.pages.size
|
14
|
+
@settings.pages.each do |page_settings|
|
15
|
+
errors = check_standards_for(page_settings)
|
16
|
+
@summary.errors += errors.size
|
17
|
+
@listener.page_tested(page_settings, errors)
|
18
|
+
end
|
19
|
+
@listener.all_pages_tested(@summary)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def check_standards_for(page_settings)
|
25
|
+
standards = Standards.for(page_settings)
|
26
|
+
@summary.skips += Standards.all.size - standards.size
|
27
|
+
html = open(page_settings.url).read
|
28
|
+
Linter.new(Capybara.string(html), standards).run.errors.to_a
|
29
|
+
end
|
30
|
+
|
31
|
+
class RunSummary
|
32
|
+
def initialize
|
33
|
+
@pages = 0
|
34
|
+
@errors = 0
|
35
|
+
@skips = 0
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_accessor :pages
|
39
|
+
attr_accessor :errors
|
40
|
+
attr_accessor :skips
|
41
|
+
|
42
|
+
def fail?
|
43
|
+
@errors > 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/bbc/a11y/standards.rb
CHANGED
@@ -8,6 +8,7 @@ require 'bbc/a11y/standards/heading_hierarchy'
|
|
8
8
|
require 'bbc/a11y/standards/image_alt'
|
9
9
|
require 'bbc/a11y/standards/language_attribute'
|
10
10
|
require 'bbc/a11y/standards/tab_index'
|
11
|
+
require 'bbc/a11y/standards/title_attribute'
|
11
12
|
|
12
13
|
module BBC
|
13
14
|
module A11y
|
@@ -35,7 +36,8 @@ module BBC
|
|
35
36
|
ExactlyOneMainHeading,
|
36
37
|
ExactlyOneMainLandmark,
|
37
38
|
LanguageAttribute,
|
38
|
-
TabIndex
|
39
|
+
TabIndex,
|
40
|
+
TitleAttribute
|
39
41
|
]
|
40
42
|
end
|
41
43
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BBC
|
2
|
+
module A11y
|
3
|
+
module Standards
|
4
|
+
class TitleAttribute
|
5
|
+
def initialize(page)
|
6
|
+
@page = page
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(errors)
|
10
|
+
@page.all("[title]").each do |element|
|
11
|
+
unless form_input? element
|
12
|
+
errors << "Element (not a form input) has a title " +
|
13
|
+
"attribute: #{element.path}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def form_input?(element)
|
21
|
+
form_input_tags.include? element.tag_name.downcase
|
22
|
+
end
|
23
|
+
|
24
|
+
def form_input_tags
|
25
|
+
['input', 'button', 'select', 'textarea']
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/bbc/a11y/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.16
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbc-a11y
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wynne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
12
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
@@ -146,7 +146,9 @@ files:
|
|
146
146
|
- features/check_standards/language.feature
|
147
147
|
- features/check_standards/main_landmark.feature
|
148
148
|
- features/check_standards/tab_index.feature
|
149
|
+
- features/check_standards/title_attribute.feature
|
149
150
|
- features/cli/display_failing_result.feature
|
151
|
+
- features/cli/display_result_summary.feature
|
150
152
|
- features/cli/exit_status.feature
|
151
153
|
- features/cli/provide_muting_tips.feature
|
152
154
|
- features/cli/report_configuration_errors.feature
|
@@ -162,6 +164,7 @@ files:
|
|
162
164
|
- lib/bbc/a11y/cli.rb
|
163
165
|
- lib/bbc/a11y/configuration.rb
|
164
166
|
- lib/bbc/a11y/linter.rb
|
167
|
+
- lib/bbc/a11y/runner.rb
|
165
168
|
- lib/bbc/a11y/standards.rb
|
166
169
|
- lib/bbc/a11y/standards/anchor_hrefs.rb
|
167
170
|
- lib/bbc/a11y/standards/content_follows_headings.rb
|
@@ -173,6 +176,7 @@ files:
|
|
173
176
|
- lib/bbc/a11y/standards/image_alt.rb
|
174
177
|
- lib/bbc/a11y/standards/language_attribute.rb
|
175
178
|
- lib/bbc/a11y/standards/tab_index.rb
|
179
|
+
- lib/bbc/a11y/standards/title_attribute.rb
|
176
180
|
- lib/bbc/a11y/version
|
177
181
|
- spec/bbc/a11y/cli_spec.rb
|
178
182
|
- spec/bbc/a11y/configuration_spec.rb
|
@@ -230,7 +234,7 @@ rubyforge_project:
|
|
230
234
|
rubygems_version: 2.4.5.1
|
231
235
|
signing_key:
|
232
236
|
specification_version: 4
|
233
|
-
summary: bbc-a11y-0.0.
|
237
|
+
summary: bbc-a11y-0.0.16
|
234
238
|
test_files:
|
235
239
|
- features/README.md
|
236
240
|
- features/check_standards/focusable_controls.feature
|
@@ -241,7 +245,9 @@ test_files:
|
|
241
245
|
- features/check_standards/language.feature
|
242
246
|
- features/check_standards/main_landmark.feature
|
243
247
|
- features/check_standards/tab_index.feature
|
248
|
+
- features/check_standards/title_attribute.feature
|
244
249
|
- features/cli/display_failing_result.feature
|
250
|
+
- features/cli/display_result_summary.feature
|
245
251
|
- features/cli/exit_status.feature
|
246
252
|
- features/cli/provide_muting_tips.feature
|
247
253
|
- features/cli/report_configuration_errors.feature
|