Skip to content
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

Merged
merged 5 commits into from
Oct 12, 2017
Merged

Conversation

igneus
Copy link
Contributor

@igneus igneus commented Oct 8, 2017

an attempt to implement #19

@codecov-io
Copy link

codecov-io commented Oct 8, 2017

Codecov Report

Merging #64 into master will increase coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   95.67%   95.82%   +0.14%     
==========================================
  Files          17       17              
  Lines         902      934      +32     
==========================================
+ Hits          863      895      +32     
  Misses         34       34              
  Partials        5        5
Impacted Files Coverage Δ
htmltest/check-img.go 100% <100%> (ø) ⬆️
htmltest/check-link.go 95.16% <0%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d42cbee...f7a3d5d. Read the comment docs.

@wjdp
Copy link
Owner

wjdp commented Oct 9, 2017

@igneus This looks really good. I'll review this week.

Copy link
Owner

@wjdp wjdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very straightforward PR, thanks!

if parent.Data == "a" {
hT.issueStore.AddIssue(issues.Issue{
Level: issues.LevelError,
Message: "img with usemap in a link",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps tweak the wording to explain this isn't allowed

<img> with usemap attribute not allowed as a descendant of am <a> tag

} else if parent.Data == "button" {
hT.issueStore.AddIssue(issues.Issue{
Level: issues.LevelError,
Message: "img with usemap in a button",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

func TestImageUsemapMapDoesNotExist(t *testing.T) {
// detects usemap pointing to a non-existent map
hT := tTestFile("fixtures/images/usemapMapDoesNotExist.html")
tExpectIssueCount(t, hT, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alongside tExpectIssueCount please also use tExpectIssue to ensure the correct issue is caught

(tExpectIssue(t, hT, "message here", 1))

@igneus
Copy link
Contributor Author

igneus commented Oct 12, 2017

@wjdp All three issues mentioned in the review reflected.

Copy link
Owner

@wjdp wjdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops sorry, could you do tExpectIssue for the other tests that cause them?

func TestImageUsemapReferenceInvalid(t *testing.T) {
// detects usemap with reference formally invalid
hT := tTestFile("fixtures/images/usemapReferenceInvalid.html")
tExpectIssueCount(t, hT, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put in a tExpectIssue here?

func TestImageUsemapEmpty(t *testing.T) {
// detects empty usemap
hT := tTestFile("fixtures/images/usemapEmpty.html")
tExpectIssueCount(t, hT, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put in a tExpectIssue here?

func TestImageUsemapInLink(t *testing.T) {
// detects forbidden usemap in an <a> alement
hT := tTestFile("fixtures/images/usemapInLink.html")
tExpectIssueCount(t, hT, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put in a tExpectIssue here?

func TestImageUsemapInButton(t *testing.T) {
// detects forbidden usemap in a <button> alement
hT := tTestFile("fixtures/images/usemapInButton.html")
tExpectIssueCount(t, hT, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put in a tExpectIssue here?

@igneus
Copy link
Contributor Author

igneus commented Oct 12, 2017

@wjdp Sure. I was surprised myself as I saw that most tests check just issue count and don't match detected issues specifically. But then I followed what seemed to be more or less standard way of writing tests in this project.

Copy link
Owner

@wjdp wjdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fab, thanks for following up on all of this!

@wjdp wjdp merged commit a0bc043 into wjdp:master Oct 12, 2017
@wjdp wjdp mentioned this pull request Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants