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

getting document-title violation when scanned code uses title in head. #4512

Open
1 task done
jasonhocker opened this issue Jun 22, 2024 · 2 comments
Open
1 task done
Labels
info needed More information or research is needed to continue

Comments

@jasonhocker
Copy link

jasonhocker commented Jun 22, 2024

Product

axe-core

Product Version

4.9.1

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

Describe what you expected the product to do.

Actual

Using axe-core npm package scanning some text and getting document-title violation though there is a <title>

How to Reproduce

            let parser = new DOMParser();
            const html2 = '<html lang="en-US"><head><title>Deque test</title></head><body></body></html>';
            let document = parser.parseFromString(html2, "text/html");
            await axe.run(document, {
                runOnly: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
            }).then(results => {

Additional context

@jasonhocker jasonhocker added the ungroomed Ticket needs a maintainer to prioritize and label label Jun 22, 2024
@straker
Copy link
Contributor

straker commented Jun 24, 2024

Thanks for the issue. I can't reproduce the issue though. Running the code inside it's own bock doesn't reproduce the issue and I can't run it outside of it's own block because I can't override document.

(async () => {
  let parser = new DOMParser();
  const html2 = '<html lang="en-US"><head><title>Deque test</title></head><body></body></html>';
  let document = parser.parseFromString(html2, "text/html");
  const results = await axe.run(document, {
    runOnly: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
  })
  console.log(results)  // violations is empty
})()
  let parser = new DOMParser();
  const html2 = '<html lang="en-US"><head><title>Deque test</title></head><body></body></html>';
  // throws Uncaught SyntaxError: Identifier 'document' has already been declared
  let document = parser.parseFromString(html2, "text/html"); 
@straker straker added info needed More information or research is needed to continue and removed ungroomed Ticket needs a maintainer to prioritize and label labels Jun 24, 2024
@jasonhocker
Copy link
Author

I am trying to write a Chrome extension for my own internal purpose. I am trying to run axe-core inside devtools, passing the html from the content-script in certain situations and then scan in devtools using a DOMParser to hydrate the string I get from the messaging to pass to axe-core. Looks like the extension is doing its job, but for this test it was scanning the head of the html for the devtools panel. Once I added a title to that, this violation from axe-core went away, but I'm wondering what is not getting scanned that I expected to scan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed More information or research is needed to continue
2 participants