bbc-a11y 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -0
  3. data/CONTRIBUTING.md +70 -8
  4. data/GETTINGSTARTED.md +65 -0
  5. data/LICENSE +1 -1
  6. data/README.md +12 -55
  7. data/Rakefile +1 -1
  8. data/a11y.rb +1 -3
  9. data/bbc-a11y.gemspec +0 -1
  10. data/features/check_standards/01_core_purpose.feature +39 -0
  11. data/features/check_standards/02_validation.feature +1 -0
  12. data/features/check_standards/03_progressive_enhancement.feature +3 -0
  13. data/features/check_standards/{language.feature → 04_indicating_language.feature} +2 -2
  14. data/features/check_standards/05_page_titles.feature +1 -0
  15. data/features/check_standards/{main_landmark.feature → 06_main_landmark.feature} +6 -6
  16. data/features/check_standards/07_headings.feature +222 -0
  17. data/features/check_standards/{minimum_text_size.feature → 08_minimum_text_size.feature} +22 -2
  18. data/features/check_standards/09_resizable_text.feature +2 -0
  19. data/features/check_standards/{tab_index.feature → 10_tab_index.feature} +7 -7
  20. data/features/check_standards/{title_attribute.feature → 11_title_attributes.feature} +13 -5
  21. data/features/check_standards/{focusable_controls.feature → 12_focusable_controls.feature} +4 -4
  22. data/features/check_standards/13_visible_on_focus.feature +1 -0
  23. data/features/check_standards/14_control_styles.feature +1 -0
  24. data/features/check_standards/15_focus_styles.feature +1 -0
  25. data/features/check_standards/16_colour_contrast.feature +1 -0
  26. data/features/check_standards/17_colour_and_meaning.feature +1 -0
  27. data/features/check_standards/{image_alt.feature → 18_image_alternatives.feature} +5 -5
  28. data/features/check_standards/{form_labels.feature → 19_form_labels.feature} +7 -7
  29. data/features/check_standards/{form_interactions.feature → 20_form_interactions.feature} +6 -6
  30. data/features/check_standards/21_tables.feature +1 -0
  31. data/features/cli/display_failing_result.feature +14 -1
  32. data/features/cli/display_result_summary.feature +15 -1
  33. data/features/cli/provide_muting_tips.feature +1 -1
  34. data/features/cli/skipping_standards.feature +1 -1
  35. data/features/mute_errors.feature +2 -2
  36. data/features/step_definitions/steps.rb +10 -9
  37. data/features/support/web_server.rb +0 -11
  38. data/features/support/web_server/blank.html +7 -0
  39. data/features/support/web_server/two_headings_failures.html +11 -0
  40. data/karma.conf.js +1 -1
  41. data/lib/bbc/a11y/cli.rb +33 -6
  42. data/lib/bbc/a11y/js/bundle.js +139 -89
  43. data/lib/bbc/a11y/js/standards.js +67 -20
  44. data/lib/bbc/a11y/js/standards/{anchorsMustHaveHrefs.js → focusableControls/anchorsMustHaveHrefs.js} +0 -0
  45. data/lib/bbc/a11y/js/standards/{formsMustHaveSubmitButtons.js → formInteractions/formsMustHaveSubmitButtons.js} +0 -0
  46. data/lib/bbc/a11y/js/standards/{fieldsMustHaveLabelsOrTitles.js → formLabels/fieldsMustHaveLabelsOrTitles.js} +0 -0
  47. data/lib/bbc/a11y/js/standards/headings/contentMustFollowHeadings.js +18 -0
  48. data/lib/bbc/a11y/js/standards/{exactlyOneMainHeading.js → headings/exactlyOneMainHeading.js} +1 -1
  49. data/lib/bbc/a11y/js/standards/{headingsMustBeInAscendingOrder.js → headings/headingsMustBeInAscendingOrder.js} +0 -0
  50. data/lib/bbc/a11y/js/standards/{imagesMustHaveAltAttributes.js → imageAlternatives/imagesMustHaveAltAttributes.js} +0 -0
  51. data/lib/bbc/a11y/js/standards/{htmlMustHaveLangAttribute.js → indicatingLanguage/htmlMustHaveLangAttribute.js} +0 -0
  52. data/lib/bbc/a11y/js/standards/{exactlyOneMainLandmark.js → mainLandmark/exactlyOneMainLandmark.js} +0 -0
  53. data/lib/bbc/a11y/js/standards/{minimumTextSize.js → minimumTextSize/textCannotBeTooSmall.js} +3 -3
  54. data/lib/bbc/a11y/js/standards/{elementsWithZeroTabIndexMustBeFields.js → tabIndex/elementsWithZeroTabIndexMustBeFields.js} +0 -0
  55. data/lib/bbc/a11y/js/standards/{titleAttributesOnlyOnInputs.js → titleAttributes/titleAttributesOnlyOnInputs.js} +1 -1
  56. data/lib/bbc/a11y/linter.rb +16 -4
  57. data/lib/bbc/a11y/runner.rb +0 -1
  58. data/lib/bbc/a11y/string_colours.rb +15 -0
  59. data/lib/bbc/a11y/version +1 -1
  60. data/package.json +3 -0
  61. data/spec/bbc/a11y/js/a11ySpec.js +15 -6
  62. data/spec/bbc/a11y/js/minimumTextSizeStandardSpec.js +25 -0
  63. data/spec/bbc/a11y/js/standardsSpec.js +6 -6
  64. data/spec/bbc/a11y/string_colours_spec.rb +13 -0
  65. metadata +68 -102
  66. data/circle.yml +0 -3
  67. data/examples/bbc-pages/Gemfile +0 -3
  68. data/examples/bbc-pages/Rakefile +0 -3
  69. data/examples/bbc-pages/a11y.rb +0 -2
  70. data/examples/local-web-app/Gemfile +0 -4
  71. data/examples/local-web-app/Rakefile +0 -3
  72. data/examples/local-web-app/a11y.rb +0 -52
  73. data/examples/local-web-app/config.ru +0 -1
  74. data/examples/local-web-app/public/missing_header.html +0 -13
  75. data/examples/local-web-app/public/perfect.html +0 -14
  76. data/examples/local-web-app/readme.md +0 -0
  77. data/features/check_standards/headings.feature +0 -153
  78. data/lib/bbc/a11y/js/standards/contentMustFollowHeadings.js +0 -15
  79. data/lib/bbc/a11y/standards.rb +0 -45
  80. data/lib/bbc/a11y/standards/anchor_hrefs.rb +0 -18
  81. data/lib/bbc/a11y/standards/content_follows_headings.rb +0 -22
  82. data/lib/bbc/a11y/standards/exactly_one_main_heading.rb +0 -25
  83. data/lib/bbc/a11y/standards/exactly_one_main_landmark.rb +0 -20
  84. data/lib/bbc/a11y/standards/form_labels.rb +0 -39
  85. data/lib/bbc/a11y/standards/form_submit_buttons.rb +0 -21
  86. data/lib/bbc/a11y/standards/heading_hierarchy.rb +0 -34
  87. data/lib/bbc/a11y/standards/image_alt.rb +0 -18
  88. data/lib/bbc/a11y/standards/language_attribute.rb +0 -19
  89. data/lib/bbc/a11y/standards/tab_index.rb +0 -22
  90. data/lib/bbc/a11y/standards/title_attribute.rb +0 -31
  91. data/standards/01_core-purpose.md +0 -24
  92. data/standards/02_validation.feature +0 -31
  93. data/standards/03_javascript.feature +0 -40
  94. data/standards/04_language.feature +0 -58
  95. data/standards/05_page_title.feature +0 -45
  96. data/standards/06_main_landmark.feature +0 -24
  97. data/standards/07_headings.feature +0 -65
  98. data/standards/08_title_attribute.feature +0 -71
  99. data/standards/09_tabindex.feature +0 -51
  100. data/standards/10_form_labels.feature +0 -88
  101. data/standards/11_visible-on-focus.md +0 -58
  102. data/standards/13_colour-contrast.md +0 -27
  103. data/standards/14_colour-meaning.md +0 -19
  104. data/standards/15_focusable-controls.md +0 -45
  105. data/standards/16_table.md +0 -109
  106. data/standards/17_control-styles.md +0 -78
  107. data/standards/18_focus-styles.md +0 -36
  108. data/standards/19_form-interactions.md +0 -33
  109. data/standards/20_image-alt.md +0 -34
  110. data/standards/21_min-font-sizes.md +0 -64
  111. data/standards/22_resize-zoom.md +0 -80
  112. data/standards/step_definitions/core_content_steps.rb +0 -3
  113. data/standards/step_definitions/form_steps.rb +0 -6
  114. data/standards/step_definitions/language_steps.rb +0 -21
  115. data/standards/step_definitions/page_steps.rb +0 -50
  116. data/standards/step_definitions/w3c_steps.rb +0 -7
  117. data/standards/support/capybara.rb +0 -53
  118. data/standards/support/skipper.rb +0 -5
  119. data/standards/support/world.rb +0 -3
  120. data/standards/support/world_extender.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 860a8a0ec77c6173b3135e22cfe79fd35425bea9
4
- data.tar.gz: 3e0a6bc605c287bcd11f4704166938dbbea0661e
3
+ metadata.gz: d59c94f740e8990fafb8ae7201c7096cd91ccef9
4
+ data.tar.gz: 57e5a3f69ce2e509ce61d765edda3c2b1df5893f
5
5
  SHA512:
6
- metadata.gz: 43163b05f80e4d566df4f1c36307da416752c4f8630b2209c7d3a4a85f6480fc68cc5ab1010933552833af8708da9da54da8f270415ad3472ce77f6530521403
7
- data.tar.gz: 934b77fb2a31ea46624b45679f499276dc839f843d1b6d67bc91c7e9ca4e44a2dec6a0411536819950e37bb6b1db73ee04ac89f95383728e69c340ceb681fb92
6
+ metadata.gz: 135ffcf60d5e6a159d0ddb987e0c939e6dfbdd41215f75e3887aad71bcf6a91f17d6f637f6299799434a5464d21fd8e61c44f183df6ab90fe45fc7936d657d8c
7
+ data.tar.gz: cec1529c7021ee79faec561281dabcfd0cf77fd1f16ea9c92530922aaaf93cefb16b914cafb5a70f8870439bf3d3c21f653828941c9bb5ae9d398bf460487418
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ 2.2
4
+ before_script:
5
+ - npm install
6
+ - export PATH=$PWD/node_modules/.bin:$PATH
7
+ script:
8
+ - bundle exec rake
9
+ - npm test
@@ -1,15 +1,77 @@
1
- # BBC A11y Contributing guidelines
1
+ # BBC A11y Contributing Guidelines
2
2
 
3
- The standards are all stored in the `standards` directory.
3
+ ## How can I contribute?
4
4
 
5
- You can run a manual test of your development copy of a11y at any time just by running:
5
+ We welcome contributions of all shapes and sizes, but we prefer them in the form
6
+ of Github [issues](https://github.com/cucumber-ltd/bbc-a11y/issues/new) or [pull requests](https://help.github.com/articles/using-pull-requests). Please have a quick look at our [existing
7
+ issues](https://github.com/cucumber-ltd/bbc-a11y/issues) before posting, as you may find we are already thinking about or working
8
+ on a fix.
6
9
 
7
- bundle exec ./bin/a11y <url>
10
+ ## Improving standards checks
8
11
 
9
- You can also use cucumber to run one specific test:
12
+ If you believe there is a bug or misinterpretation of the BBC Accessibility
13
+ Guidelines, please submit an issue with as much relevant detail as possible.
14
+ Ideally this should include an HTML snippet that demonstrates the problem. Even
15
+ more ideally, you can create or amend a scenario in one of our [cucumber features](features/check_standards).
10
16
 
11
- A11Y_URL=<url> bundle exec cucumber features/04_language.feature
17
+ ## Contributing code
12
18
 
13
- The step definitions behind these features are shallow wrappers that delegate to objects in `lib/bbc/a11y/`. Those objects are unit-tested to ensure they'll behave as expected when tests pass or fail.
19
+ Contributions of code are very welcome. You'll need to do a little bit more
20
+ setup before you can start hacking on the code:
14
21
 
15
- To add new behaviour, test-drive changes to the objects in `lib`.
22
+ ### Prerequisites
23
+
24
+ You'll need to install a few things on your system before you can work on the
25
+ code:
26
+
27
+ * Ruby (1.9.3 is required, 2.0+ is recommended)
28
+ * node.js (5.0+ is recommended)
29
+ * phantomjs
30
+
31
+ Once those are installed, you can install the Ruby dependencies:
32
+
33
+ ```
34
+ bundle install
35
+ ```
36
+
37
+ ...and the node.js dependencies:
38
+
39
+ ```
40
+ npm install
41
+ ```
42
+
43
+ ...then finally run all the tests to verify:
44
+
45
+ ```
46
+ bundle exec rake
47
+ ```
48
+
49
+ You should see red if anything fails. If all tests pass, you are ready to start
50
+ hacking! If not, please get in touch and we'll help you figure it out.
51
+
52
+ ### Amending features
53
+
54
+ It usually makes sense to start by briefly reviewing the [cucumber
55
+ features](features) as there may be similar scenarios already implemented. Then
56
+ change the features, or add scenarios to cover new edge cases, or create new
57
+ feature files.
58
+
59
+ When you are done changing feature files, we recommend that you submit a pull
60
+ request, to get feedback from the a11y team before implementing your change.
61
+
62
+ ### Implementing code changes
63
+
64
+ When it's time to implement your changes, you might need to write Ruby, or
65
+ JavaScript, or both. The standards checks are implemented in JavaScript,
66
+ whereas the command-line runner is implemented in Ruby.
67
+
68
+ There are high-level cucumber features, and low-level specs for both Ruby and
69
+ JavaScript. The cucumber features are generally broad in scope have more moving
70
+ parts, so depending on the change, it can be difficult to understand why things
71
+ fail, and to iterate on changes. In this case you should consider writing or
72
+ amending the low-level [JavaScript specs for the standards](spec/bbc/a11y/js)
73
+ or [Ruby specs for the runner](spec/bbc/a11y).
74
+
75
+ When all tests pass, please submit a pull request and the team will review it.
76
+
77
+ Happy hacking!
@@ -0,0 +1,65 @@
1
+ ## BBC A11y User Guide
2
+
3
+ ## Installing bbc-a11y to validate your project
4
+
5
+ bbc-a11y is packaged as a Ruby gem. You'll most likely want to create a
6
+ stand-alone repo to run your accessibility tests, but you can also add it as
7
+ part of an existing repo.
8
+
9
+ ### Prerequisites
10
+
11
+ [Install Ruby](https://www.ruby-lang.org/en/documentation/installation/) and
12
+ then:
13
+
14
+ gem install bundler
15
+
16
+ ### Adding a11y to your project's Gemfile
17
+
18
+ Create or amend your your project's `Gemfile` to include this line:
19
+
20
+ gem 'bbc-a11y`
21
+
22
+ Now install the gem:
23
+
24
+ bundle install
25
+
26
+ ## Configuring a11y for your project
27
+
28
+ You'll need to configure a11y with a set of URLs to run the checks against.
29
+ Create a file called `a11y.rb` in the root of your project that looks something
30
+ like this:
31
+
32
+ ```
33
+ page "http://bbc.co.uk"
34
+ page "http://bbc.co.uk/news"
35
+ ```
36
+
37
+ ### Skipping standards checks
38
+
39
+ Nobody's perfect. Use `skip_standard` in the configuration to opt-out of certain
40
+ checks.
41
+
42
+ ```
43
+ page "http://bbc.co.uk" do
44
+ skip_standard 'Focusable controls: Anchors must have hrefs'
45
+ end
46
+
47
+ page "http://bbc.co.uk/news"
48
+ ```
49
+
50
+ A11y will skip any standards from whose name matches that string.
51
+
52
+ ## Running it
53
+
54
+ Once you're configured, you can run the tests using the `a11y` command, from the
55
+ directory where your `a11y.rb` configuration file is stored:
56
+
57
+ bundle exec a11y
58
+
59
+ This will pick up your `a11y.rb` configuration file and run the a11y checks on
60
+ each page specified in your configuration. Output is printed to the console.
61
+
62
+ ## Using a11y in build scripts
63
+
64
+ The `a11y` executable will exit with a non-zero status code if there are any
65
+ standards failures, for convenient integration with CI tools like Jenkins.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Cucumber Limited
3
+ Copyright (c) 2016 British Broadcasting Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,62 +1,19 @@
1
- [![Circle CI](https://circleci.com/gh/cucumber-ltd/bbc-a11y.svg?style=svg&circle-token=00d656fd091643ad692c78ca60e30ad95df9563a)](https://circleci.com/gh/cucumber-ltd/bbc-a11y)
2
1
 
3
- # WARNING - PROTOTYPE SOFTWARE
2
+ # BBC Accessibility Standards Checker
4
3
 
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.
4
+ This tool runs a set of tests against a set of URLs to verify whether each one
5
+ meets the [BBC accessibility
6
+ standards](http://www.bbc.co.uk/guidelines/futuremedia/accessibility/).
6
7
 
7
- #BBC Accessibility Standards
8
+ This project is a work in progress, but it is stable and you can use it in your
9
+ project today.
8
10
 
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/).
11
+ ## Using BBC A11y
10
12
 
11
- ## How to install
13
+ The [getting started guide](GETTINGSTARTED.md) shows how to use a11y in your
14
+ project.
12
15
 
13
- bbc-a11y is packaged as a Ruby gem. You'll most likely want to create a stand-alone repo to run your accessibilty tests,
14
- but you can also add it as part of an existing repo.
16
+ ## Contributing to BBC A11y
15
17
 
16
- ### Prerequisites
17
-
18
- [Install Ruby](https://www.ruby-lang.org/en/documentation/installation/) and then:
19
-
20
- gem install bundler
21
-
22
- ### Adding a11y to your project's Gemfile
23
-
24
- Create or amend your your project's `Gemfile` to include this line:
25
-
26
- gem 'bbc-a11y`
27
-
28
- Now install the gem:
29
-
30
- bundle install
31
-
32
- ## Configuration
33
-
34
- You'll need to configure a11y with a set of URLs to run the checks against. Create a file `a11y.rb` in the root of your project that looks something like this:
35
-
36
- ```
37
- page "http://bbc.co.uk"
38
- page "http://bbc.co.uk/news"
39
- ```
40
-
41
- ### Skipping scenarios
42
-
43
- Nobody's perfect. Use `skip_standard` in the configuration to opt-out of certain checks.
44
-
45
- ```
46
- page "http://bbc.co.uk" do
47
- skip_standard /W3C/
48
- end
49
-
50
- page "http://bbc.co.uk/news"
51
- ```
52
-
53
- A11y will skip any scenarios from the specifications whose name contains that string.
54
-
55
- ## Running it
56
-
57
- Once you're configured, you can run the tests using the `a11y` command, from the directory where your `a11y.rb` configuration file is stored:
58
-
59
- bundle exec a11y
60
-
61
- This will pick up your `a11y.rb` configuration file and run the a11y checks on each page specified in your configuration.
62
- Output is printed to the console.
18
+ We welcome contributions of ideas and code! Please refer to the
19
+ [contributing guide](CONTRIBUTING.md).
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
4
4
  task default: [:unit, :acceptance]
5
5
 
6
6
  task :unit do
7
- sh "bundle exec rspec"
7
+ sh "bundle exec rspec && karma start --single-run"
8
8
  end
9
9
 
10
10
  task :acceptance do
data/a11y.rb CHANGED
@@ -1,5 +1,3 @@
1
1
  page "https://bbc.co.uk/news" do
2
- skip_standard /W3C/
3
- skip_standard /JavaScript/
4
- skip_standard /title/
2
+ skip_standard /title/i
5
3
  end
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency 'capybara'
17
17
  s.add_dependency 'phantomjs'
18
18
  s.add_dependency 'poltergeist'
19
- s.add_dependency 'colorize'
20
19
 
21
20
  s.add_development_dependency 'rspec', '~> 3.0'
22
21
  s.add_development_dependency 'aruba', '~> 0.9'
@@ -0,0 +1,39 @@
1
+ Feature: Core Purpose
2
+
3
+ Rationale
4
+ =========
5
+
6
+ While our aim is for all users to have access to all features of BBC apps and
7
+ sites we recognise that technology both restricts and extends what is
8
+ possible.
9
+
10
+ Additionally GEL is aimed providing the best experience to the broadest range
11
+ of users, and while it should not discriminate against users with access needs
12
+ nor does it give special privilege.
13
+
14
+ The aim of this guideline is to provide the most accessible base line
15
+ experience for the core purpose across the broadest range of technology.
16
+
17
+ See the following standards for examples of when a defined core purpose is
18
+ applicable:
19
+
20
+ * Progressive enhancement
21
+
22
+ * Minimum text size
23
+
24
+ It is not a reason to ignore accessibility for non-core page elements.
25
+
26
+ Using the standards and guidelines
27
+ ==================================
28
+
29
+ You can use use and re-use the the BBC Accessibility Standards and Guidelines
30
+ under an Open Government Licence for Public Sector Information.
31
+
32
+ Details can be found on the Open Government Licence for Public Sector
33
+ Information website.
34
+
35
+ Feedback
36
+ ========
37
+
38
+ We would love to hear your feedback. If you have a question or comment about
39
+ the standards or guidelines email us at AccessibilityTeam@bbc.co.uk.
@@ -0,0 +1 @@
1
+ Feature: Validation
@@ -0,0 +1,3 @@
1
+ Feature: Progressive Enhancement
2
+
3
+ * The core purpose of every document must not require JavaScript or CSS to function.
@@ -23,7 +23,7 @@ Feature: Specify content language
23
23
  </body>
24
24
  </html>
25
25
  """
26
- When I validate the "html must have lang attribute" standard
26
+ When I validate the "Indicating language: html must have lang attribute" standard
27
27
  Then it passes
28
28
 
29
29
  Scenario: Missing lang attribute on html element
@@ -39,7 +39,7 @@ Feature: Specify content language
39
39
  </body>
40
40
  </html>
41
41
  """
42
- When I validate the "html must have lang attribute" standard
42
+ When I validate the "Indicating language: html must have lang attribute" standard
43
43
  Then it fails with the message:
44
44
  """
45
45
  html tag has no lang attribute: /html
@@ -0,0 +1 @@
1
+ Feature: Page Titles
@@ -8,31 +8,31 @@ Feature: Main landmark
8
8
  The WAI-ARIA `main` landmark role can be help keyboard users with assistive technologies such as screen readers (and in the future as native browser functionality) to skip directly to the main content of a page, bypassing navigation and other contents that might be before it.
9
9
 
10
10
  Scenario: Page has a single main element
11
- Given a page with the HTML:
11
+ Given a page with the body:
12
12
  """
13
13
  <div role="main">Main element</div>
14
14
  """
15
- When I validate the "exactly one main landmark" standard
15
+ When I validate the "Main landmark: exactly one main landmark" standard
16
16
  Then it passes
17
17
 
18
18
  Scenario: Page has two main elements
19
- Given a page with the HTML:
19
+ Given a page with the body:
20
20
  """
21
21
  <div role="main">Main one</div>
22
22
  <div role="main">Main two</div>
23
23
  """
24
- When I validate the "exactly one main landmark" standard
24
+ When I validate the "Main landmark: exactly one main landmark" standard
25
25
  Then it fails with the message:
26
26
  """
27
27
  Found 2 elements with role="main": /html/body/div[1] /html/body/div[2]
28
28
  """
29
29
 
30
30
  Scenario: Page has zero main elements
31
- Given a page with the HTML:
31
+ Given a page with the body:
32
32
  """
33
33
  <div role="not-main">Main one</div>
34
34
  """
35
- When I validate the "exactly one main landmark" standard
35
+ When I validate the "Main landmark: exactly one main landmark" standard
36
36
  Then it fails with the message:
37
37
  """
38
38
  Found 0 elements with role="main".
@@ -0,0 +1,222 @@
1
+ Feature: Headings
2
+
3
+ A document **must** have exactly one `<h1>` element.
4
+
5
+ Heading levels after the document `<h1>` element **must** be sequential and **must not** skip heading levels.
6
+
7
+ Heading elements **must** be followed by content.
8
+
9
+ Rationale
10
+ =========
11
+
12
+ A logical heading structure is invaluable for users of screen readers and similar assistive technologies to help navigate content.
13
+
14
+ Users should be able to use the document's `<h1>` identify its main content. Documents should have one main subject.
15
+
16
+ Heading levels should not be skipped as a predictable document outline is an important factor for understandability.
17
+
18
+ Headings should not be used for non-heading purposes, i.e. to identify blocks of content. A heading should always
19
+ be followed either by non-heading content or by a heading of one level deeper.
20
+
21
+ Scenario: No main heading
22
+ Given a page with the body:
23
+ """
24
+ <h2>Heading 2</h2>
25
+ """
26
+ When I validate the "Headings: exactly one main heading" standard
27
+ Then it fails with the message:
28
+ """
29
+ Found 0 h1 elements.
30
+ """
31
+
32
+ Scenario: More than one main heading
33
+ Given a page with the body:
34
+ """
35
+ <h1>Heading 1</h1>
36
+ <h2>Heading 2</h2>
37
+ <h1>Heading 1</h1>
38
+ """
39
+ When I validate the "Headings: exactly one main heading" standard
40
+ Then it fails with the message:
41
+ """
42
+ Found 2 h1 elements: /html/body/h1[1] /html/body/h1[2]
43
+ """
44
+
45
+ Scenario: More than one main heading, but only one visible
46
+ Given a page with the body:
47
+ """
48
+ <h1>A Heading</h1>
49
+ <h1 style="display:none">Another Heading</h1>
50
+ """
51
+ When I validate the "Headings: exactly one main heading" standard
52
+ Then it passes
53
+
54
+ Scenario: Headings in ascending order
55
+ Given a page with the body:
56
+ """
57
+ <h1>Heading 1</h1>
58
+ <h2>Heading 2</h2>
59
+ <h3>Heading 3</h3>
60
+ <h4>Heading 4</h4>
61
+ <h5>Heading 5</h5>
62
+ <h6>Heading 6</h6>
63
+ """
64
+ When I validate the "Headings: headings must be in ascending order" standard
65
+ Then it passes
66
+
67
+ Scenario: Headings in invalid order
68
+ Given a page with the body:
69
+ """
70
+ <h1>Heading 1</h1>
71
+ <h3>Heading 3</h3>
72
+ <h2>Heading 2</h2>
73
+ """
74
+ When I validate the "Headings: headings must be in ascending order" standard
75
+ Then it fails with the message:
76
+ """
77
+ Headings are not in order: /html/body/h1 /html/body/h3
78
+ """
79
+
80
+ Scenario: Headings jump back up more than one level
81
+ Given a page with the body:
82
+ """
83
+ <h1>Heading 1</h1>
84
+ <h2>Heading 2</h2>
85
+ <h3>Heading 3</h3>
86
+ <h4>Heading 4</h4>
87
+ <h2>Heading 2b</h2>
88
+ <h3>Heading 3b</h3>
89
+ """
90
+ When I validate the "Headings: headings must be in ascending order" standard
91
+ Then it passes
92
+
93
+ Scenario: Heading is hidden
94
+ Given a page with the body:
95
+ """
96
+ <h1>Heading 1</h1>
97
+ <h3 style="display:none">Heading 3</h3>
98
+ <h2>Heading 2</h2>
99
+ """
100
+ When I validate the "Headings: headings must be in ascending order" standard
101
+ Then it fails with the message:
102
+ """
103
+ Headings are not in order: /html/body/h1 /html/body/h3
104
+ """
105
+
106
+ Scenario: Heading in a script tag
107
+ Given a page with the body:
108
+ """
109
+ <h1>Heading 1</h1>
110
+ <script>
111
+ var stuff = "<h3>Heading 3</h3>";
112
+ </script>
113
+ <h2>Heading 2</h2>
114
+ """
115
+ When I validate the "Headings: headings must be in ascending order" standard
116
+ Then it passes
117
+
118
+ Scenario: Subheading before the first main heading
119
+ Given a page with the body:
120
+ """
121
+ <h3>Ignore me</h3>
122
+ <h1>Heading 1</h1>
123
+ <h2>Heading 2</h2>
124
+ """
125
+ When I validate the "Headings: headings must be in ascending order" standard
126
+ Then it passes
127
+
128
+ Scenario: Content between headings
129
+ Given a page with the body:
130
+ """
131
+ <div role="main">
132
+ <h1>Main heading</h1>
133
+ <p>non-heading content</p>
134
+ <h2>Another heading</h2>
135
+ <p>non-heading content</p>
136
+ <h3>Main content</h3>
137
+ non-heading content
138
+ <h2>Secondary content</h2>
139
+ <p>non-heading content</p>
140
+ <h2>Tertiary content</h2>
141
+ non-heading content
142
+ </div>
143
+ """
144
+ When I validate the "Headings: content must follow headings" standard
145
+ Then it passes
146
+
147
+ Scenario: Heading followed by subheading
148
+ Given a page with the body:
149
+ """
150
+ <h1>Main heading</h1>
151
+ <h2>Another heading</h2>
152
+ <p>...and some content</p>
153
+ """
154
+ When I validate the "Headings: content must follow headings" standard
155
+ Then it passes
156
+
157
+ Scenario: No content between headings
158
+ Given a page with the body:
159
+ """
160
+ <div role="main">
161
+ <h1>Main heading</h1>
162
+ <p>non-heading content</p>
163
+ <h2>Secondary content</h2>
164
+ <h2>Tertiary content</h2>
165
+ <p>non-heading content</p>
166
+ </div>
167
+ """
168
+ When I validate the "Headings: content must follow headings" standard
169
+ Then it fails with the message:
170
+ """
171
+ No content follows: /html/body/div/h2[1]
172
+ """
173
+
174
+ Scenario: Nested heading followed by non-nested content
175
+ Given a page with the body:
176
+ """
177
+ <div>
178
+ <h1>Main heading</h1>
179
+ </div>
180
+ Followed by some content
181
+ """
182
+ When I validate the "Headings: content must follow headings" standard
183
+ Then it passes
184
+
185
+ Scenario: Nested heading followed by heading
186
+ Given a page with the body:
187
+ """
188
+ <div>
189
+ <h1>Main heading</h1>
190
+ </div>
191
+ <h1>Another heading</h1>
192
+ """
193
+ When I validate the "Headings: content must follow headings" standard
194
+ Then it fails with the message:
195
+ """
196
+ No content follows: /html/body/div/h1
197
+ No content follows: /html/body/h1
198
+ """
199
+
200
+ Scenario: Nested heading followed by nested content
201
+ Given a page with the body:
202
+ """
203
+ <div>
204
+ <h1>Main heading</h1>
205
+ </div>
206
+ <div>
207
+ Followed by some content
208
+ </div>
209
+ """
210
+ When I validate the "Headings: content must follow headings" standard
211
+ Then it passes
212
+
213
+ Scenario: Non-nested heading followed by nested content
214
+ Given a page with the body:
215
+ """
216
+ <h1>Main heading</h1>
217
+ <div>
218
+ Followed by some content
219
+ </div>
220
+ """
221
+ When I validate the "Headings: content must follow headings" standard
222
+ Then it passes