-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check usemap attribute of <img> elements #64
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,47 @@ func TestImagePre(t *testing.T) { | |
tExpectIssueCount(t, hT, 0) | ||
} | ||
|
||
func TestImageUsemap(t *testing.T) { | ||
// deals with valid usemap | ||
hT := tTestFile("fixtures/images/usemapValid.html") | ||
tExpectIssueCount(t, hT, 0) | ||
} | ||
|
||
func TestImageUsemapMapDoesNotExist(t *testing.T) { | ||
// detects usemap pointing to a non-existent map | ||
hT := tTestFile("fixtures/images/usemapMapDoesNotExist.html") | ||
tExpectIssueCount(t, hT, 1) | ||
tExpectIssue(t, hT, "hash does not exist", 1) | ||
} | ||
|
||
func TestImageUsemapReferenceInvalid(t *testing.T) { | ||
// detects usemap with reference formally invalid | ||
hT := tTestFile("fixtures/images/usemapReferenceInvalid.html") | ||
tExpectIssueCount(t, hT, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you put in a |
||
tExpectIssue(t, hT, "only fragment starting with # allowed", 1) | ||
} | ||
|
||
func TestImageUsemapEmpty(t *testing.T) { | ||
// detects empty usemap | ||
hT := tTestFile("fixtures/images/usemapEmpty.html") | ||
tExpectIssueCount(t, hT, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you put in a |
||
tExpectIssue(t, hT, "usemap empty", 1) | ||
} | ||
|
||
func TestImageUsemapInLink(t *testing.T) { | ||
// detects forbidden usemap in an <a> alement | ||
hT := tTestFile("fixtures/images/usemapInLink.html") | ||
tExpectIssueCount(t, hT, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you put in a |
||
tExpectIssue(t, hT, "usemap attribute not allowed as descendant of an <a>", 1) | ||
} | ||
|
||
func TestImageUsemapInButton(t *testing.T) { | ||
// detects forbidden usemap in a <button> alement | ||
hT := tTestFile("fixtures/images/usemapInButton.html") | ||
tExpectIssueCount(t, hT, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you put in a |
||
tExpectIssue(t, hT, "usemap attribute not allowed as descendant of a <button>", 1) | ||
} | ||
|
||
func TestImageMultipleProblems(t *testing.T) { | ||
hT := tTestFile("fixtures/images/multipleProblems.html") | ||
tExpectIssueCount(t, hT, 6) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
|
||
<body> | ||
|
||
<img usemap="" src="./gpl.png" alt="alt text" /> | ||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
|
||
<body> | ||
|
||
<map name="primary"> | ||
<area shape="circle" coords="75,75,75" href="usemapMapDoesNotExist.html"> | ||
</map> | ||
<button> | ||
<img usemap="#primary" src="gpl.png" alt="GPL"> | ||
</button> | ||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
|
||
<body> | ||
|
||
<map name="primary"> | ||
<area shape="circle" coords="75,75,75" href="usemapMapDoesNotExist.html"> | ||
</map> | ||
<a href="usemapValid.html"> | ||
<img usemap="#primary" src="gpl.png" alt="GPL"> | ||
</a> | ||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
|
||
<body> | ||
|
||
<img usemap="#map" src="./gpl.png" alt="alt text" /> | ||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<html> | ||
|
||
<body> | ||
|
||
<map name="primary"> | ||
<area shape="circle" coords="75,75,75" href="usemapMapDoesNotExist.html"> | ||
</map> | ||
<img usemap="primary" src="gpl.png" alt="GPL"> | ||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<html> | ||
|
||
<body> | ||
|
||
<map name="primary"> | ||
<area shape="circle" coords="75,75,75" href="usemapMapDoesNotExist.html"> | ||
</map> | ||
<img usemap="#primary" src="gpl.png" alt="GPL"> | ||
|
||
</body> | ||
|
||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alongside
tExpectIssueCount
please also usetExpectIssue
to ensure the correct issue is caught(
tExpectIssue(t, hT, "message here", 1)
)