-
Notifications
You must be signed in to change notification settings - Fork 363
#149 Be able to evaluate page with iframes #150
Changes from 5 commits
88731e1
2fbd434
08b3be1
dc66bb7
715c1e6
83e5af1
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 |
---|---|---|
|
@@ -42,7 +42,8 @@ axs.AuditRules.addRule({ | |
} | ||
// Ignore elements which have a negative tabindex and no text content, | ||
// as they will be skipped by assistive technology | ||
if (axs.properties.findTextAlternatives(element, {}).trim() === '') | ||
var alternative = axs.properties.findTextAlternatives(element, {}); | ||
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. Is this a behavior change or just cleanup? It doesn't seem related to this PR. 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. Just a cleanup, I was getting a exception sometimes when findTextAlternatives return null (null.trim()). 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. Good catch! I just submitted a separate PR for this same issue, not having seen this, sorry. |
||
if (alternative == null || alternative.trim() === '') | ||
return false; | ||
|
||
return true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,14 @@ axs.AuditRule.collectMatchingElements = function(node, matcher, collection, | |
} | ||
} | ||
} | ||
|
||
//If it is a iframe, get the contentDocument | ||
if (element && element.localName == 'iframe' && element.contentDocument) { | ||
axs.AuditRule.collectMatchingElements(element.contentDocument, | ||
matcher, | ||
collection, | ||
opt_shadowRoot); | ||
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. Is 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. I think so, it's a recursive method and I think it's necessary to always pass this atribute forward. For example, if we got a shadow down inside a iframe contentDocument, it will be needed. 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. Makes sense. |
||
} | ||
// If it is neither the parent of a ShadowRoot, a <content> element, nor | ||
// a <shadow> element recurse normally. | ||
var child = node.firstChild; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,16 @@ | |
equal(matched.length, DIV_COUNT); | ||
}); | ||
|
||
test("Iframe with simple DOM", function () { | ||
var ifrm = document.createElement("IFRAME"); | ||
var container = document.getElementById('qunit-fixture'); | ||
container.appendChild(ifrm); | ||
ifrm.contentDocument.body.appendChild(buildTestDom()); | ||
var matched = []; | ||
axs.AuditRule.collectMatchingElements(container, matcher, matched); | ||
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. Is this method mutating 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. I was justing copying the same behavior in others tests (in this same file). I don't like methods changing parameter's content too (bad smell). 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. Yep, that's fine, thought I'd point it out as something we can improve in the future. 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. This is intended behaviour. Since this is a recursive method, we need an accumulator to keep track of matched elements - otherwise we'd be constantly having to combine partial results. |
||
equal(matched.length, DIV_COUNT); | ||
}); | ||
|
||
test("With shadow DOM with no content insertion point", function () { | ||
var container = document.getElementById('qunit-fixture'); | ||
container.appendChild(buildTestDom()); | ||
|
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.
@davidhsv this file needs to be checked out entirely.