Skip to content

Iframes with display: none; shouldn't be required to have a title. #34

@romainmenke

Description

@romainmenke

Google Tag Manager recently switched to using iframes to load a service worker.
These iframes don't have a title but do have style="display: none;"

I don't think these should be recorded as failures:

Image

Suggested fix:

HTMLCS.Util.js

    /**
     * Returns true if the element is deliberately hidden from Accessibility APIs.
     *
     * @param {Node} element The element to check.
     *
     * @return {Boolean}
     */
    self.isAccessibilityHidden = function(element) {
        do {
            // WAI-ARIA presentation role.
            if (element.hasAttribute('role') && element.getAttribute('role') === 'presentation') {
                return true;
            }

            // WAI-ARIA hidden attribute.
            if (element.hasAttribute('aria-hidden') && element.getAttribute('aria-hidden') === 'true') {
                return true;
            }

+            // CSS hidden attribute.
+            var style = self.style(element);
+            if (style !== null && style.display === 'none') {
+                return true;
+            }
+
            // Consider iframes to be "invisible" as well, if the setting is set, so that
            // checks don't run for external widgets we don't have control over.
            if (element.tagName == 'IFRAME' && HTMLCS.getBosaOption('skipIframes') == true) {
                return true;
            }
        } while (element = element.parentElement);

        return false;
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions