dequelabs / axe-core

Accessibility engine for automated Web UI testing
https://www.deque.com/axe/
Mozilla Public License 2.0
5.87k stars 763 forks source link

Option to truncate excessively large `.html` in results #4544

Open stephenmathieson opened 1 month ago

stephenmathieson commented 1 month ago

Product

axe-core

Feature Description

When analyzing a axe Watcher results in prod, we noticed we have a few excessively large datums (>1MB). This is preventing us from migrating result data to a different (much faster data store).

After digging further, it was noticed that this is due to axe-core including the element in violation's outerHTML (eg .violations[x].nodes[y].html) and its related node's outerHTML (.violations[x].nodes[y].relatedNodes[z].html). Consider the following snippet:

<img class="foo" src="data:png,base64, EXTREMELY LARGE IMAGE CONVERTED TO BASE64" />

It appears axe-core is already truncating some parts (children) of the element's HTML, but not the element itself.

An option similar to axe.configure({ noHtml: true }) which causes axe-core to truncate ALL HTML snippets would be extremely helpful.

WilcoFiers commented 1 month ago

@stephenmathieson Thanks for the suggestion. That's definitely a problem we should find a solution to. I'm not sure whether it should be a separate option. Axe-core truncates HTML snippets to prevent this problem. I think what we might want to do also put limits on attributes, both on the length of an attribute value, and of the number of attributes.

I'll bring this up with the team to come up with a solution.

WilcoFiers commented 3 days ago

Talked about this, we agree this should happen. Will be in 4.11 / 5.0, won't do this in a patch.

We think the best way to do this is to:

  1. Look at each attribute, if any are too long replace the value with "..."
  2. If this results in a string that is overall still too long, start removing attributes and ad "..." at the end of the tag.
  3. If this is still too longer (very long custom elm) we take only the first X characters and truncate with "..." at the end.