haikuwebkit/LayoutTests/accessibility/title-ui-element-correctnes...

110 lines
4.0 KiB
HTML
Raw Permalink Normal View History

AX: labelForElement is slow when there are a lot of DOM elements https://bugs.webkit.org/show_bug.cgi?id=97825 Reviewed by Ryosuke Niwa. Source/WebCore: Adds a DocumentOrderedMap to TreeScope that allows accessibility to quickly map from an id to the label for that id. This speeds up AccessibilityNode::labelForElement, which was a bottleneck in Chromium when accessibility was on. Tests: accessibility/title-ui-element-correctness.html perf/accessibility-title-ui-element.html * accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::labelForElement): * dom/DocumentOrderedMap.cpp: (WebCore::keyMatchesLabelForAttribute): (WebCore): (WebCore::DocumentOrderedMap::get): (WebCore::DocumentOrderedMap::getElementByLabelForAttribute): * dom/DocumentOrderedMap.h: (DocumentOrderedMap): * dom/Element.cpp: (WebCore::Element::insertedInto): (WebCore::Element::removedFrom): (WebCore::Element::updateLabel): (WebCore): (WebCore::Element::willModifyAttribute): * dom/Element.h: (Element): * dom/TreeScope.cpp: (WebCore::TreeScope::TreeScope): (WebCore::TreeScope::destroyTreeScopeData): (WebCore::TreeScope::addLabel): (WebCore): (WebCore::TreeScope::removeLabel): (WebCore::TreeScope::labelElementForId): * dom/TreeScope.h: (WebCore): (TreeScope): (WebCore::TreeScope::shouldCacheLabelsByForAttribute): Tools: Implement titleUIElement in the chromium port of DRT, and fix getAccessibleElementById so that it ensures the backing store is up-to-date. * DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp: (AccessibilityController::getAccessibleElementById): * DumpRenderTree/chromium/TestRunner/AccessibilityUIElementChromium.cpp: (AccessibilityUIElement::titleUIElementCallback): LayoutTests: Adds two new tests for titleUIElement that run on both Mac and Chromium. One tests correctness, the other tests speed. Fixes one test so that it passes on Chromium. Enables other tests that now pass on Chromium. * accessibility/secure-textfield-title-ui.html: * accessibility/title-ui-element-correctness-expected.txt: Added. * accessibility/title-ui-element-correctness.html: Added. * perf/accessibility-title-ui-element-expected.txt: Added. * perf/accessibility-title-ui-element.html: Added. * platform/chromium/TestExpectations: Canonical link: https://commits.webkit.org/117807@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-10-19 08:01:06 +00:00
<!DOCTYPE HTML>
<html>
<body>
Many accessibility js-tests use waitUntilDone https://bugs.webkit.org/show_bug.cgi?id=172372 Reviewed by Tim Horton. Corrected the use of js-test harness, updated the tests to use js-test.js instead of js-test-pre.js where possible. * accessibility/anonymous-render-block-in-continuation-causes-crash-expected.txt: * accessibility/anonymous-render-block-in-continuation-causes-crash.html: * accessibility/aria-checkbox-sends-notification.html: * accessibility/aria-invalid.html: * accessibility/aria-switch-sends-notification.html: * accessibility/deleting-iframe-destroys-axcache.html: * accessibility/file-upload-button-with-axpress.html: * accessibility/frame-disconnect-textmarker-cache-crash-expected.txt: * accessibility/frame-disconnect-textmarker-cache-crash.html: * accessibility/gtk/aria-listbox-crash.html: * accessibility/heading-title-includes-links-expected.txt: * accessibility/heading-title-includes-links.html: * accessibility/image-map-update-parent-crash-expected.txt: * accessibility/image-map-update-parent-crash.html: * accessibility/insert-children-assert-expected.txt: * accessibility/insert-children-assert.html: * accessibility/ios-simulator/focus-change-notifications.html: * accessibility/label-element-press.html: * accessibility/loading-iframe-updates-axtree.html: * accessibility/mac/aria-expanded-notifications.html: * accessibility/mac/aria-listbox-selectedchildren-change.html: * accessibility/mac/aria-liveregion-on-image.html: * accessibility/mac/aria-liveregions-addedelement.html: * accessibility/mac/aria-liveregions-changedalt.html: * accessibility/mac/aria-liveregions-changedtext.html: * accessibility/mac/aria-liveregions-removedelement.html: * accessibility/mac/combobox-activedescendant-notifications-expected.txt: * accessibility/mac/combobox-activedescendant-notifications.html: * accessibility/mac/focus-setting-selection-syncronizing-not-clearing-expected.txt: * accessibility/mac/focus-setting-selection-syncronizing-not-clearing.html: * accessibility/mac/html-slider-indicator.html: * accessibility/mac/input-replacevalue-userinfo-expected.txt: * accessibility/mac/input-replacevalue-userinfo.html: * accessibility/mac/ordered-textmarker-crash-expected.txt: * accessibility/mac/ordered-textmarker-crash.html: * accessibility/mac/search-with-frames-expected.txt: * accessibility/mac/search-with-frames.html: * accessibility/mac/selection-boundary-userinfo.html: * accessibility/mac/selection-change-userinfo.html: * accessibility/mac/selection-element-tabbing-to-link.html: * accessibility/mac/selection-value-changes-for-aria-textbox.html: * accessibility/mac/stale-textmarker-crash-expected.txt: * accessibility/mac/stale-textmarker-crash.html: * accessibility/mac/textbox-role-reports-notifications-expected.txt: * accessibility/mac/textbox-role-reports-notifications.html: * accessibility/mac/value-change/value-change-user-info-contenteditable.html: * accessibility/mac/value-change/value-change-user-info-textarea.html: * accessibility/mac/value-change/value-change-user-info-textfield.html: * accessibility/media-element.html: * accessibility/menu-list-sends-change-notification.html: * accessibility/multiselect-list-reports-active-option.html: * accessibility/paragraph-with-linebreaks.html: * accessibility/platform-name.html: * accessibility/radio-button-group-members.html: * accessibility/radio-button-title-label.html: * accessibility/selection-states-expected.txt: * accessibility/selection-states.html: * accessibility/spinbutton-value.html: * accessibility/svg-bounds.html: * accessibility/table-cell-for-column-and-row-crash.html: * accessibility/table-cells-roles.html: * accessibility/table-roles-hierarchy.html: * accessibility/table-with-aria-role.html: * accessibility/textarea-insertion-point-line-number.html: * accessibility/textbox-role-reports-selection.html: * accessibility/title-ui-element-correctness.html: * accessibility/unknown-roles-not-exposed-expected.txt: * accessibility/unknown-roles-not-exposed.html: * accessibility/win/bstr-elements-role.html: * accessibility/win/detached-object-notification-crash.html: * accessibility/win/heading-elements.html: * accessibility/win/img-alt-attribute.html: * accessibility/win/linked-elements.html: * accessibility/win/list-item-role.html: * accessibility/win/list-marker-role.html: * accessibility/win/list-role.html: * accessibility/win/multiple-select-element-role.html: * accessibility/win/option-element-position-and-size.html: * accessibility/win/parent-element.html: * accessibility/win/select-element-role.html: * accessibility/win/selection-and-focus.html: * accessibility/win/single-select-children-changed.html: * accessibility/win/single-select-children.html: * accessibility/win/text-role.html: * platform/mac-wk1/accessibility/loading-iframe-updates-axtree-expected.txt: * platform/mac-wk2/accessibility/deleting-iframe-destroys-axcache-expected.txt: * platform/mac/accessibility/deleting-iframe-destroys-axcache-expected.txt: * platform/mac/accessibility/media-element-expected.txt: * platform/mac/accessibility/table-cells-roles-expected.txt: * platform/mac/accessibility/table-roles-hierarchy-expected.txt: Canonical link: https://commits.webkit.org/189300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217171 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-19 23:37:59 +00:00
<script src="../resources/js-test.js"></script>
AX: labelForElement is slow when there are a lot of DOM elements https://bugs.webkit.org/show_bug.cgi?id=97825 Reviewed by Ryosuke Niwa. Source/WebCore: Adds a DocumentOrderedMap to TreeScope that allows accessibility to quickly map from an id to the label for that id. This speeds up AccessibilityNode::labelForElement, which was a bottleneck in Chromium when accessibility was on. Tests: accessibility/title-ui-element-correctness.html perf/accessibility-title-ui-element.html * accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::labelForElement): * dom/DocumentOrderedMap.cpp: (WebCore::keyMatchesLabelForAttribute): (WebCore): (WebCore::DocumentOrderedMap::get): (WebCore::DocumentOrderedMap::getElementByLabelForAttribute): * dom/DocumentOrderedMap.h: (DocumentOrderedMap): * dom/Element.cpp: (WebCore::Element::insertedInto): (WebCore::Element::removedFrom): (WebCore::Element::updateLabel): (WebCore): (WebCore::Element::willModifyAttribute): * dom/Element.h: (Element): * dom/TreeScope.cpp: (WebCore::TreeScope::TreeScope): (WebCore::TreeScope::destroyTreeScopeData): (WebCore::TreeScope::addLabel): (WebCore): (WebCore::TreeScope::removeLabel): (WebCore::TreeScope::labelElementForId): * dom/TreeScope.h: (WebCore): (TreeScope): (WebCore::TreeScope::shouldCacheLabelsByForAttribute): Tools: Implement titleUIElement in the chromium port of DRT, and fix getAccessibleElementById so that it ensures the backing store is up-to-date. * DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp: (AccessibilityController::getAccessibleElementById): * DumpRenderTree/chromium/TestRunner/AccessibilityUIElementChromium.cpp: (AccessibilityUIElement::titleUIElementCallback): LayoutTests: Adds two new tests for titleUIElement that run on both Mac and Chromium. One tests correctness, the other tests speed. Fixes one test so that it passes on Chromium. Enables other tests that now pass on Chromium. * accessibility/secure-textfield-title-ui.html: * accessibility/title-ui-element-correctness-expected.txt: Added. * accessibility/title-ui-element-correctness.html: Added. * perf/accessibility-title-ui-element-expected.txt: Added. * perf/accessibility-title-ui-element.html: Added. * platform/chromium/TestExpectations: Canonical link: https://commits.webkit.org/117807@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-10-19 08:01:06 +00:00
<div id="container">
<div>
<label id="label1" for="control1">Label 1</label>
<input id="control1" type="text">
</div>
<div>
<label id="label2">
Label 2
<input id="control2" type="text">
</label>
</div>
<div>
<label id="label3">Label 3</label>
<input id="control3" type="text">
</div>
<div>
<input id="control4" type="text">
</div>
<div>
<label id="label5">
Label 5
</label>
<input id="control5" type="text">
</div>
<div>
<label id="label6b" for="control6">Label 6b</label>
<label id="label6c" for="control6">Label 6c</label>
<input id="control6" type="text">
</div>
</div>
<div id="console"></div>
<script>
description("This tests that titleUIElement works correctly even when things change dynamically.");
if (window.testRunner && window.accessibilityController) {
function hasTitleUIElement(axElement) {
var label1 = accessibilityController.accessibleElementById("label1");
var titleUIElement = axElement.titleUIElement();
if (titleUIElement == null)
return false;
return titleUIElement.role == label1.role;
}
function createLabelWithIdAndForAttribute(id, forAttributeValue) {
var labelElement = document.createElement("label");
labelElement.id = id;
labelElement.setAttribute("for", forAttributeValue);
labelElement.innerText = "Label for " + forAttributeValue;
return labelElement;
}
function reparentNodeIntoContainer(node, container) {
node.parentElement.removeChild(node);
container.appendChild(node);
}
function axElement(id) {
return accessibilityController.accessibleElementById(id);
}
shouldBe("axElement('control1').titleUIElement().isEqual(axElement('label1'))", "true");
shouldBe("axElement('control2').titleUIElement().isEqual(axElement('label2'))", "true");
// Test changing the "for" attribute dynamically.
shouldBe("hasTitleUIElement(axElement('control3'))", "false");
shouldBe("document.getElementById('label3').setAttribute('for', 'control3'); axElement('control3').titleUIElement().isEqual(axElement('label3'))", "true");
// Test unattached label element that's subsequently attached.
var label4Element = document.createElement("label");
label4Element.id = "label4";
label4Element.setAttribute("for", "control4");
label4Element.innerText = "Label 4";
shouldBe("var label4Element = createLabelWithIdAndForAttribute('label4', 'control4'); hasTitleUIElement(axElement('control4'))", "false");
shouldBe("document.getElementById('container').appendChild(label4Element); hasTitleUIElement(axElement('control4'))", "true");
shouldBe("axElement('control4').titleUIElement().isEqual(axElement('label4'))", "true");
// Test what happens when the label is detached.
shouldBe("label4Element.parentElement.removeChild(label4Element); hasTitleUIElement(axElement('control4'))", "false");
// Test label that gets a control reparented into it.
shouldBe("hasTitleUIElement(axElement('control5'))", "false");
shouldBe("reparentNodeIntoContainer(document.getElementById('control5'), document.getElementById('label5')); axElement('control5').titleUIElement() != null", "true");
shouldBe("axElement('control5').titleUIElement().isEqual(axElement('label5'))", "true");
// Make sure the first label is returned, even as labels are added and removed.
shouldBe("axElement('control6').titleUIElement().isEqual(axElement('label6b'))", "true");
shouldBe("newLabel6Element = createLabelWithIdAndForAttribute('label6a', 'control6'); document.body.insertBefore(newLabel6Element, document.body.firstChild); axElement('control6').titleUIElement().isEqual(axElement('label6a'))", "true");
shouldBe("document.body.removeChild(newLabel6Element); axElement('control6').titleUIElement().isEqual(axElement('label6b'))", "true");
document.getElementById('container').style.display = 'none';
}
</script>
</body>
</html>