-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add validation for missing
alt
attribute on <map>
and <area>
tags.
- Loading branch information
Showing
5 changed files
with
101 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Test for anchors. | ||
use accessibility_rs::{engine::audit, AuditConfig}; | ||
use maud::html; | ||
|
||
#[test] | ||
fn _audit_missing_alt_area() { | ||
//alt attribute missing on first <area> tag | ||
let html = r#" | ||
<img src="workplace.jpg" alt="Workplace" usemap="\#workmap" width="400" height="379"> | ||
<map name="workmap" alt="workplace image map" > | ||
<area shape="rect" coords="34,44,270,350" href="computer.htm"> | ||
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm"> | ||
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm"> | ||
</map>"#; | ||
let audit: Vec<accessibility_rs::engine::issue::Issue> = | ||
accessibility_rs::audit(AuditConfig::basic(html)); | ||
|
||
let valid = audit | ||
.iter() | ||
.any(|x| x.message == "1_1_1_H24.ImageMapAreaNoAlt"); | ||
|
||
assert_eq!(valid, true) | ||
} | ||
|
||
#[test] | ||
fn _audit_missing_alt_map() { | ||
// alt attribute missing on <map> tag | ||
let html = r#" | ||
<img src="workplace.jpg" alt="Workplace" usemap="\#workmap" width="400" height="379"> | ||
<map name="workmap"> | ||
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm"> | ||
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm"> | ||
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm"> | ||
</map>"#; | ||
let audit: Vec<accessibility_rs::engine::issue::Issue> = | ||
accessibility_rs::audit(AuditConfig::basic(html)); | ||
|
||
let valid = audit.iter().any(|x| x.message == "1_1_1_H24.ImageMapNoAlt"); | ||
|
||
assert_eq!(valid, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ pub mod img; | |
pub mod input; | ||
pub mod label; | ||
pub mod meta; | ||
pub mod area; |