bump
This commit is contained in:
116
daemon/daemon.go
116
daemon/daemon.go
@@ -12264,66 +12264,80 @@ func (d *Daemon) getFormAccessibilityAudit(tabID, formSelector string, timeout i
|
||||
return nil, fmt.Errorf("failed to get page: %v", err)
|
||||
}
|
||||
|
||||
// Determine the selector to use
|
||||
selector := formSelector
|
||||
if selector == "" {
|
||||
selector = "form"
|
||||
}
|
||||
|
||||
// JavaScript to analyze forms
|
||||
jsCode := `
|
||||
(function() {
|
||||
const forms = document.querySelectorAll('` + formSelector + `' || 'form');
|
||||
const result = {
|
||||
forms_found: forms.length,
|
||||
forms: []
|
||||
};
|
||||
|
||||
forms.forEach((form, index) => {
|
||||
const formData = {
|
||||
id: form.id || 'form-' + index,
|
||||
fields: form.querySelectorAll('input, select, textarea').length,
|
||||
issues: [],
|
||||
aria_compliance: 'FULL',
|
||||
keyboard_accessible: true,
|
||||
required_fields_marked: true
|
||||
try {
|
||||
const forms = document.querySelectorAll('` + selector + `');
|
||||
const result = {
|
||||
forms_found: forms.length,
|
||||
forms: []
|
||||
};
|
||||
|
||||
// Check for labels
|
||||
const inputs = form.querySelectorAll('input:not([type="hidden"]), select, textarea');
|
||||
let missingLabels = 0;
|
||||
inputs.forEach(input => {
|
||||
const id = input.id;
|
||||
if (id) {
|
||||
const label = form.querySelector('label[for="' + id + '"]');
|
||||
if (!label && !input.getAttribute('aria-label') && !input.getAttribute('aria-labelledby')) {
|
||||
missingLabels++;
|
||||
forms.forEach((form, index) => {
|
||||
const formData = {
|
||||
id: form.id || 'form-' + index,
|
||||
fields: form.querySelectorAll('input, select, textarea').length,
|
||||
issues: [],
|
||||
aria_compliance: 'FULL',
|
||||
keyboard_accessible: true,
|
||||
required_fields_marked: true
|
||||
};
|
||||
|
||||
// Check for labels
|
||||
const inputs = form.querySelectorAll('input:not([type="hidden"]), select, textarea');
|
||||
let missingLabels = 0;
|
||||
inputs.forEach(input => {
|
||||
const id = input.id;
|
||||
if (id) {
|
||||
const label = form.querySelector('label[for="' + id + '"]');
|
||||
if (!label && !input.getAttribute('aria-label') && !input.getAttribute('aria-labelledby')) {
|
||||
missingLabels++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (missingLabels > 0) {
|
||||
formData.issues.push({
|
||||
type: 'missing_labels',
|
||||
severity: 'SERIOUS',
|
||||
count: missingLabels,
|
||||
description: missingLabels + ' fields lack proper labels',
|
||||
fix: 'Add <label> elements or aria-label attributes'
|
||||
});
|
||||
formData.aria_compliance = 'PARTIAL';
|
||||
}
|
||||
|
||||
// Check submit button contrast (simplified)
|
||||
const submitBtn = form.querySelector('button[type="submit"], input[type="submit"]');
|
||||
if (submitBtn) {
|
||||
const styles = window.getComputedStyle(submitBtn);
|
||||
// Note: Actual contrast calculation would be more complex
|
||||
formData.issues.push({
|
||||
type: 'submit_button_check',
|
||||
severity: 'INFO',
|
||||
description: 'Submit button found - verify contrast manually',
|
||||
fix: 'Ensure submit button has 4.5:1 contrast ratio'
|
||||
});
|
||||
}
|
||||
|
||||
result.forms.push(formData);
|
||||
});
|
||||
|
||||
if (missingLabels > 0) {
|
||||
formData.issues.push({
|
||||
type: 'missing_labels',
|
||||
severity: 'SERIOUS',
|
||||
count: missingLabels,
|
||||
description: missingLabels + ' fields lack proper labels',
|
||||
fix: 'Add <label> elements or aria-label attributes'
|
||||
});
|
||||
formData.aria_compliance = 'PARTIAL';
|
||||
}
|
||||
|
||||
// Check submit button contrast (simplified)
|
||||
const submitBtn = form.querySelector('button[type="submit"], input[type="submit"]');
|
||||
if (submitBtn) {
|
||||
const styles = window.getComputedStyle(submitBtn);
|
||||
// Note: Actual contrast calculation would be more complex
|
||||
formData.issues.push({
|
||||
type: 'submit_button_check',
|
||||
severity: 'INFO',
|
||||
description: 'Submit button found - verify contrast manually',
|
||||
fix: 'Ensure submit button has 4.5:1 contrast ratio'
|
||||
});
|
||||
}
|
||||
|
||||
result.forms.push(formData);
|
||||
});
|
||||
|
||||
return result;
|
||||
return result;
|
||||
} catch (error) {
|
||||
return {
|
||||
error: error.message,
|
||||
forms_found: 0,
|
||||
forms: []
|
||||
};
|
||||
}
|
||||
})();
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user